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)
 Read text file

Author  Topic 

dani2
Starting Member

32 Posts

Posted - 2008-01-08 : 08:10:50
Hi
Is it possible to open and read a text (.csv) file and use the information to update a table, all this in a stored procedure?
If so can you point me in the right direction?

thank you

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 08:22:59
Read about bulk insert in sql server help file

Madhivanan

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

dani2
Starting Member

32 Posts

Posted - 2008-01-08 : 08:27:59
But I want to perform only updates.
Is there something like BULK UPDATE? :)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 08:31:12
quote:
Originally posted by dani2

But I want to perform only updates.
Is there something like BULK UPDATE? :)


Insert into a staging table and update from that table

Bulk insert to stage_table

Update T
set col1=S.col1,col2=S.col2,....
from target_table T inner join Stage_table S
on T.keycol=S.keycol

Drop table Stage_table


Madhivanan

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

dani2
Starting Member

32 Posts

Posted - 2008-01-08 : 08:35:13
quote:
Originally posted by madhivanan
Insert into a staging table and update from that table

Bulk insert to stage_table

Update T
set col1=S.col1,col2=S.col2,....
from target_table T inner join Stage_table S
on T.keycol=S.keycol

Drop table Stage_table


Madhivanan

Failing to plan is Planning to fail




Good enough. Thanks!
Go to Top of Page
   

- Advertisement -