Thursday, August 4, 2011

Stored Procedure For Insert With Check Duplicasy

Create procedure insertuser
@id int,
@uname nvarchar(max),
@pas nvarchar(max),
@name nvarchar(max),
@ponnumber nvarchar(max),
@add nvarchar(max),
@emailid nvarchar(max),
@regtime nvarchar(max)
as
declare @ss as int
declare @msg as nvarchar(50)
set @ss=(select count(*) from ulogin where emailid=@emailid)

if @ss>0
begin
set @msg=('Email Address Already Exists.')
select @msg as sts
end
else
begin
insert into ulogin values(@id,@uname,@pas,@name,@ponnumber,@add,@emailid,@regtime)
set @msg=('Registration Sucessfully.')
select @msg as sts
end
return

Execute Store Procedure

execute insertuser @id=1,@uname=asd,@pas=asdd,@name=qwewe,@ponnumber=awqwewq,@add=sdadad,@emailid=14,@regtime=sdd

No comments:

Post a Comment