Solved

stored  procedure insert

Posted on 2004-09-02
3
281 Views
Last Modified: 2010-04-17
can we use two insert statements in one stored procedure. if so what is the syntax.

thanks

sandeep
0
Comment
Question by:sandeep437
3 Comments
 
LVL 3

Accepted Solution

by:
swarnajyothirmayi123 earned 50 total points
ID: 11968763
Sure you can how many ever statements you want in a stored procedure.

CREATE PROCEDURE sp_add_department
            @Department_Name Nvarchar(50),
            @Department_Desc NVarchar(500),
            @Created_By integer,
            @active integer,
            @Message varchar(100) OUT
AS
Declare @RowCount as Integer
Declare @RowCount1 as Integer
Select @RowCount=count(*) from department where department_name=@Department_Name;

      if(@RowCount>0)
      Begin
            set @Message= 'The Department already exists. Please enter a different departmentname'
            return;
      End

      if(@RowCount=0)
      Begin
            insert into Department(Department_Name,Department_Desc,Created_By,active) values(@Department_Name,@Department_Desc,@Created_By,@active);
insert into table2(a,b,c) values('a','b','c');
insert into table3(a,b,c) values('a','b','c');
insert into table2(a,b,c) values('a','b','c');
      End
GO


I am just posting a sample code. You can infact add any sql statement in the stored procedure.
If you want further information you can contact me.

Swarna
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
EvenOdd challenge 10 83
powerN  challenge 3 47
pairs challenge 5 44
What is Python programming? 3 66
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now