Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all. Is there any way to write an Update query and an Insert query in a single Stored Procedure? If So,please tell me how.

Thanks in Advance.
Posted
Comments
josh-jw 9-Jan-13 3:55am    
CREATE PROCEDURE PROCEDURE_NAME
AS
BEGIN
//your insert query
//your update query
end
Jagan911 15-Jan-13 0:15am    
Hi Josh-JW, Thanks for your reply.It helped me to resolve my requirement.

1 solution

U can Write.

follow this sample SP

SQL
CREATE PROCEDURE PROCEDURE_NAME
(
   @Trans_Type VARCHAR(100),
   --whatever u want  u add parameters on here
)
AS
BEGIN
   IF @Trans_Type='INSERT'
   BEGIN
     --UR INSERT QUERY
   END
   ELSE IF @Trans_Type='UPDATE'
   BEGIN
      --UR UPDATE QUERY
   END
END


I think this might help you...
 
Share this answer
 
Comments
Jagan911 15-Jan-13 0:16am    
Hello PranathiS012, thanks for responding to my question.Your answer helped me a lot.

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