Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
ALTER proc [dbo].[InsertUserIdMap]
@userid varchar(50),
@type varchar(50),
@typeid varchar(50),
@exists int=1 output
as
declare @match varchar(500)
set @match =(select User_ID from UserIDMapping where User_ID =@userid and TypeId=@typeid)
begin
if(@type='ADMIN')
begin
if exists  (@match) 
select @exists
else
insert into UserIDMapping (User_ID ,Table_Ref ,TypeId ) values (@userid ,'adminb2b' ,@typeid )
set @exists=0
end

there is an error incorrect syntax @match
Posted
Updated 15-Mar-12 0:28am
v2

begin and end tags are not matching in the SP. you can re-write this as follows:
SQL
ALTER proc [dbo].[InsertUserIdMap]
@userid varchar(50),
@type varchar(50),
@typeid varchar(50),
@exists int=1 output
as
begin
if(@type='ADMIN')
begin
	if exists  (select User_ID from UserIDMapping where User_ID =@userid and TypeId=@typeid) 
		SET @exists = 1
	else
	begin
		insert into UserIDMapping (User_ID ,Table_Ref ,TypeId ) values (@userid ,'adminb2b' ,@typeid )
		set @exists=0
	end
end
end
 
Share this answer
 
you forget to write begin and end keyword in the procedure

SQL
ALTER proc [dbo].[InsertUserIdMap]
@userid varchar(50),
@type varchar(50),
@typeid varchar(50),
@exists int=1 output
as
begin
declare @match varchar(500)
set @match =(select User_ID from UserIDMapping where User_ID =@userid and TypeId=@typeid)

if(@type='ADMIN')
begin
if exists  (@match)
select @exists
else
insert into UserIDMapping (User_ID ,Table_Ref ,TypeId ) values (@userid ,'adminb2b' ,@typeid )
set @exists=0
end
end
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900