Click here to Skip to main content
12,511,383 members (55,383 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: SQL-Server
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 8-Jan-13 21:51pm
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

U can Write.

follow this sample SP

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...
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100