Click here to Skip to main content
15,924,402 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when 1st query execute and result is true than only i want to execute 2nd query at that time
Posted

Hi ,
Check this link
how can i insert data in multiple table in one store procedure?[^]
Best Regards
M.Mitwalli
 
Share this answer
 
Comments
raksha dongre 26-May-12 8:28am    
thanks for your valuable suggestions...
Mohamed Mitwalli 26-May-12 14:54pm    
Your welcome
After executing the first statement please check for error then based on the success execute the second statement. Use @@error global variable

@@error
After each Transact-SQL statement, the server sets the value of this variable to an integer value:


0 If the statement was successful

Error number If the statement has failed
 
Share this answer
 
 
Share this answer
 
SQL
BEGIN try
 -- execute your first query 
END try
BEGIN CATCH
return --- if error occur then return
END CATCH
-- execute your second query if no error 
 
Share this answer
 

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