Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

SQL server - SQL extracts

Thread Tools
 
Search this Thread
 
Old 08 July 2010, 07:49 PM
  #1  
tarmac terror
Scooby Regular
Thread Starter
iTrader: (2)
 
tarmac terror's Avatar
 
Join Date: May 2005
Location: Northern Ireland
Posts: 2,498
Received 0 Likes on 0 Posts
Default 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.
Old 08 July 2010, 08:08 PM
  #2  
bioforger
Scooby Regular
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

Do you know of a site called google?

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)
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Uncle Creepy
Other Marques
43
27 December 2015 04:02 PM
Hoppy
Non Scooby Related
10
07 March 2001 05:55 PM
Markus
Non Scooby Related
0
30 November 2000 10:11 AM



Quick Reply: SQL server - SQL extracts



All times are GMT +1. The time now is 12:02 AM.