Solved

stored  procedure insert

Posted on 2004-09-02
3
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

705 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