Hi,
I see several errors Fixed the error and here is the code.
few errors I see
- int identity passing as input parameter
- comma after the last input parameter
- proid in insert statement ( no @)
- declaration of @proid multiple times
You can now charge the sp without any issue, but you need to look into the scrip that you have written everything correctly.
check the line - set @proid=SCOPE_IDENTITY()
looks incorrect
Create PROCEDURE [dbo].[InsertDetails_SP]
(
@custid varchar(50),
@custname varchar(50),
@custadd varchar(200),
@proid int,
@prodname varchar (50),
@price int ,
@brandname varchar (100)
)
as
begin
set nocount on;
begin transaction
insert into custdetails
(
custid,custname,custadd,proid
)
values
(
@custid,@custname,@custadd,@proid
)
set @proid=SCOPE_IDENTITY()
If @@ERROR=0
Begin
insert into proddetails
(
proid,prodname,price
)
values
(
@proid,@prodname,@price
)
end
if @@Error=0
begin
insert into branddetails(
proid,brandname
)
values
(
@proid,@brandname
)
IF @@ERROR = 0
BEGIN
COMMIT TRANSACTION
END
ELSE
BEGIN
ROLLBACK TRANSACTION
END
END
ELSE
BEGIN
ROLLBACK TRANSACTION
END
END
Hope this helps