hi guys,

i've solve that problem using sp via. so use that one i given below.

if exists (select name from sysobjects where name = 'CustomerInsert'

and type = 'p')

drop procedure CustomerInsert

go

create procedure CustomerInsert(@CustomerName varchar(10),@Address
varchar(20),

@City varchar(10),@Pincode numeric(6),@Result int)

as

declare @CustomerNo int

set nocount on

if exists(select CustomerName from CustomerDetails where

CustomerName = @CustomerName)

begin

raiserror('The Customer Name already Exists',10,1)

select @Result = 2

end

else

begin

begin transaction

select @CustomerNo = max(CustomerNo)+1 from CustomerDetails

insert into CustomerDetails (CustomerNo,CustomerName,Address,City,Pincode)

values(@CustomerNo,@CustomerName,@Address,@City,@Pincode)

select @Result = 1

commit transaction

end

print @Result

set nocount off

go

exec CustomerInsert 'Viji','25,Senthil Nagar','Chennai',600005,NULL

Reply via email to