Wednesday, March 26, 2014

Insert Franchise inquery

-- Author:  Javed khan                                                    
-- Create date: 24/12/2013                                                  
-- Description: For Insert Inquery of user
---==========================================

Create proc [dbo].[lsp_enqinsert]    
(    
 @usrid bigint,    
 @frnchid bigint,    
 @enqcomnt varchar(1500),    
 @enqtype bit,    
 @n int output    
)    
as    
begin    
declare @isenq bit    
declare @comid varchar(max)  
if((select count(*) from tblbusfrnchenq where usrid= @usrid and frnchid=@frnchid and isdelsts=0)>0)    
begin    
set @isenq=0  
set @comid=(select distinct comid from tblbusfrnchenq where  usrid= @usrid and frnchid=@frnchid and isdelsts=0)  
end  
else  
begin  
if((select count(*) from  tblbusfrnchenq)=0)
set @comid=100
else
set @comid=(select max(comid)+1 from tblbusfrnchenq)--convert(varchar(max), @frnchid)+convert(varchar(max), @usrid)  
set @isenq=1    
 
end  
insert into tblbusfrnchenq(usrid,frnchid,enqcomnt,enqtype,isenq,comid) values(@usrid,@frnchid,@enqcomnt,@enqtype,@isenq,@comid)    
set @n=1    
end 

No comments:

Post a Comment