ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   SQL server - SQL extracts (https://www.scoobynet.com/computer-and-technology-related-34/840997-sql-server-sql-extracts.html)

tarmac terror 08 July 2010 07:49 PM

SQL server - SQL extracts
 
I need to extract data from a SQL server database to a file, problem is I need the file to be CSV with columns separated by either commas or colons.

One of the fields I need to extract allows users to type 'free text' so punctuation marks and carriage returns will be present in the extracted data, however I need to remove them. The punctuation marks are easily dealt with, but I have no idea how to remove the unwanted carriage returns.

Can anyone advise if there is an easy and efficient way to do this.

bioforger 08 July 2010 08:08 PM

Do you know of a site called google? :idea: :)

select
*
from
authors
where
au_lname = char(10) + char(13)

--update the column with the cr/lf with an empty string

update
authors
set
au_lname = stuff(au_lname, patindex(char(10)+ char(13), au_lname), 2, '')
where
patindex(char(10) + char(13), au_lname) > 0

--look for the row with the cr/lf in it (should be gone)

select
*
from
authors
where
au_lname = char(10) + char(13)


All times are GMT +1. The time now is 05:33 PM.


© 2024 MH Sub I, LLC dba Internet Brands