August 21, 2008 at 9:41 pm
Hi guys
I have got a column in my table which is enclosed in the double quotes. I need to remove these quotes from the entire column. How do I do that through a query??
Sample
column_A
"1233"
"4445"
"876"
.
.
.
Thanks Guys
Cheers
August 21, 2008 at 10:02 pm
Nuts (8/21/2008)
Hi guysI have got a column in my table which is enclosed in the double quotes. I need to remove these quotes from the entire column. How do I do that through a query??
Sample
column_A
"1233"
"4445"
"876"
.
.
.
Thanks Guys
Cheers
you can use
select replace(column_A, """"",'')
from tableA
August 21, 2008 at 10:41 pm
It doesnt work with this query!
The column remains unchanged (enclosed with the double quotes)
August 21, 2008 at 10:52 pm
how about this
select replace(column A, '"','')
August 21, 2008 at 11:12 pm
Thanks
This query works but how do I save these changes I mean when I run this query, it just displays the result into the window but how do I actually update the table??
Thanks
August 22, 2008 at 12:00 am
update table
set column_A = replace(column_A, '"','')
August 24, 2008 at 3:38 pm
Thanks a lot
It works well
Cheers:D
August 24, 2008 at 4:03 pm
I guess a better question would be, how did the double quotes get there in the first place? Did you import some text-qualified CSV or something? If so, what did you use? And, if so, can you attach one of the files so we can show you how to import the data without including the double quotes? 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
August 24, 2008 at 6:33 pm
Hi
I had to import a txt file into sql server . I have attached the sample file for your reference.
It would be really good to know how to import it without including the double quotes.
Cheers
August 24, 2008 at 6:57 pm
Nuts (8/24/2008)
HiI had to import a txt file into sql server . I have attached the sample file for your reference.
It would be really good to know how to import it without including the double quotes.
Cheers
Oh my... they certainly didn't do you any favors. The header uses different delimiters than the body of the file which makes it just about impossible to do in a straight forward manner with BCP or Bulk Insert. Lemme see what I can churn up...
--Jeff Moden
Change is inevitable... Change for the better is not.
August 26, 2008 at 2:50 am
The file looks like a complete dogs dinner, seems like a mixture of comma, tab and pipe delimited with an apparent header row in a different format pasted in for good measure. Personally I would bounce it back to whoever provided it to you and ask them nicely, but firmly to provide the file again, but in a recognisable format and with a file layout (Fixed width would be nice).
To strip out the double quotes you could try using replace([Your column name], char(34), '') in your update statement, but I think the data would still contain allsorts of garbage.
August 26, 2008 at 6:37 am
import the txt file into excel through import data option. select the column delimeter as tab and save it is as excel worksheet. now import the data into sql server from excel sheet. while importing the data remember to change the column length while importing the data.
Note: if you are using excel 97-2003 you have to split the file into two excel files as it doesn't support rows more than 65336. Import the data from two excel files and then merge it.
My honest advice, ask the generator of file to make column headings more readable without any special characters. No doubt sql server will accept it but you'll be in more troubles while processing the data later on in sps or udfs. you could ask for mapping document with more info about the columns along with data file.
August 26, 2008 at 10:15 am
Fishbarnriots (8/26/2008)
The file looks like a complete dogs dinner
my my, as tasty as that 😀 :Whistling:
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
August 26, 2008 at 2:50 pm
Thanks for your help guys!
Will definately follow your advise
August 26, 2008 at 5:56 pm
Sorry... new job has kept me busy... I think I may have a solution soon. Yep, I know you already have one using REPLACE on the quotes... there's just gotta be a better way.
I do agree with FishBarnRiots... to an extreme... get your bat, slingshot, and trebuchet and convice the providers of this horribly formatted file to fix it.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply