Hi,
Following is my stored procedure
Create procedure [dbo].[USp_Routeselconductor]
@tourdate nvarchar(50),
@busid nvarchar(50),
@uname nvarchar(50)
as
declare @conductorid nvarchar(50)
select @conductorid=conductor_id2 from routeBusdetails where tour_date=@tourdate and bus_id=@busid and uname=@uname
if(@conductorid <>0)
begin
select conductor_id,cname from routeconductormaster where uname=@uname and conductor_id not in(select conductor_id from routeBusdetails where uname=@uname and tour_date = @tourdate and conductor_id is not null
union all
select conductor_id2 from routeBusdetails where uname=@uname and tour_date =@tourdate and conductor_id2 is not null)
end
else
begin
select conductor_id,cname from routeconductormaster where uname=@uname and conductor_id not in(select conductor_id from routeBusdetails where uname=@uname and tour_date = @tourdate and conductor_id is not null
end
select c.cname,b.startid,b.ndays as ndays from routeconductormaster c,routebusdetails b where c.conductor_id=b.conductor_id2 and b.uname=@uname and tour_date=@tourdate and b.bus_id=@busid
when i execute iam getting an error like this
Msg 156, Level 15, State 1, Procedure Sp_Routeselconductor, Line 19
Incorrect syntax near the keyword 'end'.
what is the error and how to solve
Regards
Baiju