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)
 query help needed

Author  Topic 

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-14 : 01:17:42
hi all
i have table which has a userid,email and other fields.
And i have a text file called email.txt,this text file has userid and email values corresponding to those in the table.And this file has only this userid and email fields separated by commas..

for example

1,jwalton@uswest.net
2,jeff@hmhr.com
3,james@hotmail.com

And i need to update the emailid field in table with the emailid in this text file.

ok tanx in advance...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-14 : 01:45:30
You can export the text file to a staging table in your database using DTS and then use Execute SQL task to update emailids in your table from staging table.
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-14 : 02:12:01
hi visakh,

is it possible thru query...
ok tanx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-14 : 02:19:26
Yup. You can use OPENROWSET and get text data to temporary table and use it to update your table.


INSERT INTO #Temp
SELECT * FROM OPENROWSET(BULK N'YourTextfilepath', SINGLE_BLOB)

UPDATE yt
SET yt.Email=t.Email
FROM YourTable yt
INNER JOIN #Temp t
ON t.userid=yt.userid
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-14 : 02:29:43
hi visakh,
tanx for ur help..
i have a doubt..i am using sql2000.
will ur query run in 2k also..

ok
tanx...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-14 : 02:34:01
Dont think you have BLOB option in 2000. You can also refer this:-

http://www.mssqltips.com/tip.asp?tip=1207
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-14 : 02:43:09
ok

then how can i do the above task in sql2k thru query.

can u help me....
ok tanx......
Go to Top of Page
   

- Advertisement -