Error in stored procedure

Posted by Klbaiju under Sql Server on 5/13/2014 | Points: 10 | Views : 890 | Status : [Member] | Replies : 1
HI all,

following is working code

create procedure [dbo].[Sp_addbusdetails]
@bus_id nvarchar(50),
@tour_date nvarchar(50),
@tour_id nvarchar(50),
--tour_date,bus_id,source,destination,fare,status
@bookby nvarchar(50),
@source nvarchar(50),
@destination nvarchar(50),
@fare nvarchar(50),
@status nvarchar(50),
@book_date nvarchar(50),
@advance nvarchar(50),
@balance nvarchar(50),
@tourtype nvarchar(50),
@startid nvarchar(50),
@ndays int
as
declare @count int

if(ndays =0)

begin
select @count=COUNT(*) from Busdetails where tour_date=@tour_date and bus_id=@bus_id
if @count=0
begin
insert into busdetails(tour_id,tour_date,bus_id,bookby,source,destination,fare,status,book_date,advance,balance,tourtype,startid,ndays) values(@tour_id,@tour_date,@bus_id,@bookby,@source,@destination,@fare,@status,@book_date,@advance,@balance,@tourtype,@startid,@ndays)
end

else

begin

end

My requirement is in the else condition i want to add multiple records suppose ndays =3 and tour_id=100-20-may-2014,then i want to add records with

tour_id=100-20-may-2014,100-21-may-2014,100-22-may-2014 how it is possible

Regards

Baiju




Responses

Posted by: Sheonarayan on: 5/14/2014 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
The code that you have written in the post is not easily understandable as it is not in the Code block. However based on your question, in the ELSE block you can keep multiple insert statement.

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response