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 |
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2012-03-07 : 04:58:36
|
I have table value parameter @tvpMyKeys.I am filling it through a select statement.After filling it I have to loop through each entry of my table value parameter tvpMyKeys and perform some deletion.How can I loop through all records of a table value parameterKamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-07 : 05:07:47
|
You can delete from a table with joining @tvpMyKeys.Think set based! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2012-03-07 : 05:38:27
|
problem solvedKamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-07 : 05:38:30
|
Something like this but you have to work out what to do in case of error / rollback and so on...while exists(select * from @YourTablevar)begin begin transaction set @MyID = (select top 1 @YourTablevar.Column from @YourTablevar) delete from table1 where id=@MyID ... commit transaction delete from @YourTablevar where @YourTablevar.Column = @MyIDend No, you're never too old to Yak'n'Roll if you're too young to die.edit: For those who can't understand why I have posted this kind of "solution": it was a direct answer to a post which is now deleted, done by kamii47 |
 |
|
|
|
|