Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / July 2008

Tip: Looking for answers? Try searching our database.

TSQL - Carriage control characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DXC - 14 Jul 2008 14:41 GMT
SQL Server 2000 SP4.
I have this problem. I have a text column coming out in Some data Extract
for a client.
They need us to remove (replace) the carriage control characters in the
extract.
'--- vbCrLf & Chr(9)
I cannot convert to varchar because it will not fit.
What's my alternative.

Thanks for any help
Roy Harvey (SQL Server MVP) - 14 Jul 2008 15:13 GMT
declare @x varchar(30)
SET @x = 'banana' + char(13) + char(10) + 'split'
SELECT @x, REPLACE(@x, char(13) + char(10), '??')

------------------------------ --------------------------------------
banana
split                  banana??split

Roy Harvey
Beacon Falls, CT

>SQL Server 2000 SP4.
> I have this problem. I have a text column coming out in Some data Extract
[quoted text clipped - 6 lines]
>
>Thanks for any help
DXC - 14 Jul 2008 15:27 GMT
Thanks for the quick response Roy but Replace does not work on text fields.

> declare @x varchar(30)
> SET @x = 'banana' + char(13) + char(10) + 'split'
[quoted text clipped - 17 lines]
> >
> >Thanks for any help
TheSQLGuru - 14 Jul 2008 20:47 GMT
SUBSTRING does work on text IIRC, and inconjunction with patindex you should
be able to do what you need to do.

Also, if they are small text fields you can also first convert to varchar
and then process as Roy suggested.  If they are large you will need to do
them in chunks of 8000 or so at a time.

Signature

Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net

> Thanks for the quick response Roy but Replace does not work on text
> fields.
[quoted text clipped - 21 lines]
>> >
>> >Thanks for any help
DXC - 15 Jul 2008 13:56 GMT
Thanks......................

> SUBSTRING does work on text IIRC, and inconjunction with patindex you should
> be able to do what you need to do.
[quoted text clipped - 28 lines]
> >> >
> >> >Thanks for any help
Aaron Bertrand [SQL Server MVP] - 15 Jul 2008 17:48 GMT
What runs the extract?  If you pull the data into a client language first
(VBScript, C#, VB.Net, etc) you can easily handle replace() before writing
to the file, and without having to deal with the limitations of TEXT.

On 7/14/08 9:41 AM, in article
7689CD4A-47FD-41B2-A5BB-495D86070AB0@microsoft.com, "DXC"

> SQL Server 2000 SP4.
>  I have this problem. I have a text column coming out in Some data Extract
[quoted text clipped - 6 lines]
>
> Thanks for any help
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.