Click here to Skip to main content
15,915,742 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
Hii All,

I am Working In a Dynamic Stored Procedure Which Takes Paramter with DataType "TABLE" .This Table Contains Normal SQL Statments Example " Insert Into Table Name(--) Values(-----),"

My Problem Here Is How Can i Execute All These SQL Statment Which Inside The Table's Rows,

Any Suggestion

Thanks,
Posted

1 solution

Why put the statements inside a TABLE?

Easiest way to execute multiple statements is to execute them all at once in a single statement, like:
SQL
BEGIN
 INSERT INTO ....
 INSERT INTO ....
 ...
END


If you really want to execute statements from a TABLE, use sp_executesql, here is a nice example:
Building Dynamic SQL In a Stored Procedure[^]

Regards
Espen Harlinn
 
Share this answer
 
Comments
moral_2011 6-Feb-11 5:55am    
Thanks You So Much It is Working Now
fjdiewornncalwe 6-Feb-11 11:16am    
+5. Great Answer.
Espen Harlinn 6-Feb-11 11:23am    
Thanks Marcus!
Sandeep Mewara 6-Feb-11 11:29am    
++5. Great answer.
Espen Harlinn 6-Feb-11 12:00pm    
Thanks Sandeep Mewara!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900