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)
 pass datatable to sp in sql 2005

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-09-06 : 10:44:30
Hi,

How can we pass a datatable to insert/update/delete stored procedures in sql server 2005?

Thanks

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-06 : 11:27:11
You mean the name of a table?
Pass it as parameter like other parameters.
But to use it in a query you have to use dynamic sql.
Example:
exec('delete from '+@tablevar+' where bla=4711')


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-09-06 : 13:49:29
can i ask why you need to pass table name as a parameter? why does table change dynamically?
Go to Top of Page

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-09-07 : 03:28:35
Hi,

Not the table name. I need to pass an array or datatable to the sp.

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
Go to Top of Page
   

- Advertisement -