?
Solved

stored  procedure insert

Posted on 2004-09-02
3
Medium Priority
?
289 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

764 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