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.
| Author |
Topic |
|
jkeogh
Starting Member
2 Posts |
Posted - 2010-01-12 : 10:24:50
|
| Hi,am hoping someone can help with what I presume (and hope) is a relatively simple question. (they always are when you know the answer!)I need to update an existing table within a SQL 2005 DBThe table contains personal contact details, and I need to change a date field on approx 200 of the records (out of about 10,000).I have a list of e-mail address in csv/txt format and I am looking for the code to do this...update dbo.tablenameset date to 20/12/2010 (the updated date is the same for each record)where emailcolumnname = look in my text file....any clues, pointers would be greatly appreciated. I have had a mooch about trying to find the answer, but keep running in to Bulk Insert queries which didn't look quite rightmany thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-12 : 10:33:31
|
something like below ( i dont know text file format so make sure you use appropriate col name)update tset t.date='2010-12-20'from dbo.tablename tinner join (select * from OpenRowset('MSDASQL','Driver={Microsoft Text Driver (*.txt; *.csv)}; DefaultDir={your directory}','select * from junk.txt'))t1on t.emailcolumnname = t1.emailcol |
 |
|
|
jkeogh
Starting Member
2 Posts |
Posted - 2010-01-13 : 08:33:18
|
| Hi,thanks for that, it works perfectly. This has saved us about 12 hours of mind numbing data input!thanks again |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-13 : 08:35:19
|
welcome |
 |
|
|
|
|
|