Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to update more columns at a time

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-07-10 : 04:01:40
Hi Team, I have a table with 150 columns and around 6 million records.
But the problem is each and every data in the coulmn is marked with double quotes.

Col1 Col2 Col3.........Col150
"abc" "de" "c" ......"kjh"
"jkl" "dn" "g".........."kjl"

Can any one give query to update all the columns by replacing the double quote in the data.

The below query is for one column.
Update table set col1 = col.replace(""","")


G. Satish

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-10 : 04:03:22
[code]
Update
table
set
col1 = replace(col1, '"', ''),
col2 = replace(col2, '"', '')
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-10 : 04:05:38
quote:
Originally posted by satish.gorijala

Hi Team, I have a table with 150 columns and around 6 million records.
But the problem is each and every data in the coulmn is marked with double quotes.

Col1 Col2 Col3.........Col150
"abc" "de" "c" ......"kjh"
"jkl" "dn" "g".........."kjl"

Can any one give query to update all the columns by replacing the double quote in the data.

The below query is for one column.
Update table set col1 = col.replace(""","")


G. Satish


How did you get double quotes?
Imported from file?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-07-10 : 04:11:32
I'm guessing you want an automated script?

You can do this with dynamic SQL, but if it is a one off, it really isn't worth the time writing the code.

If this is an imported file, get rid of the quotes before importing it, most import methods allow you to ignore double quotes when importing.
Go to Top of Page

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-07-10 : 06:02:29
Yes, i imported data from some text files. I am unable to open those text files because they are in size GB's. That's why double quotes came in to datatables.

quote:
Originally posted by madhivanan

quote:
Originally posted by satish.gorijala

Hi Team, I have a table with 150 columns and around 6 million records.
But the problem is each and every data in the coulmn is marked with double quotes.

Col1 Col2 Col3.........Col150
"abc" "de" "c" ......"kjh"
"jkl" "dn" "g".........."kjl"

Can any one give query to update all the columns by replacing the double quote in the data.

The below query is for one column.
Update table set col1 = col.replace(""","")


G. Satish


How did you get double quotes?
Imported from file?

Madhivanan

Failing to plan is Planning to fail



G. Satish
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-07-10 : 06:34:10
How did you import them? You can ignore double quotes in your import routine, you never need to open the file.
Go to Top of Page
   

- Advertisement -