Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to update multiple tables in single statement .please not tell me multiple update query..
Posted
Comments
Abhijit Parab 28-Sep-12 6:31am    
Use Trigger...........
bhargavpp 2-Oct-12 8:15am    
i want in stored procedure but not with multiple statement

The simplest way is to use a stored procedure: you hand it all the parameters, and it fills in the table updates. It would also be a good idea to do this within a transaction, so if any part of the update fails, the whole update can be rolled back - you can do the transaction within the procedure.

SQL stored Procedures[^]
 
Share this answer
 
Comments
bhargavpp 1-Oct-12 6:55am    
i want like update tbl1,tbl2 set tbl1.col=test,tbl2.col2=test where condition
is this possible
_Amy 1-Oct-12 7:16am    
Deserves +5!
 
Share this answer
 
Comments
bhargavpp 1-Oct-12 6:56am    
i want like update tbl1,tbl2 set tbl1.col=test,tbl2.col2=test where condition
is this possible
[no name] 1-Oct-12 7:04am    
check this link..hope u can do..
http://stackoverflow.com/questions/2044467/how-to-update-two-tables-in-one-statement-in-sql-server-2005[^]

the way u r asking it's better to go for stored procedure or join query..
Why do you need the complex queries rather Microsoft already given you a better option with Stored Procedure[^].

Being a developer you should think to minimize the code and maximize the performance. But you are not clearly aware about the advantages of using such things. Read SQL SERVER – Stored Procedures Advantages and Best Advantage[^].



--Amit
 
Share this answer
 
Comments
bhargavpp 2-Oct-12 8:14am    
i want same thing in stored procedure but i dont want multiple execution

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