Nidheesh N Namboodhiri
Nidheesh N Namboodhiri

Reputation: 199

Identity column

Stored Procedure

CREATE PROCEDURE [dbo].[Insert_Customer]
@id int,
@FName  varchar(50) ,
@MName  varchar(50) ,
@LName  varchar(50) ,
@Age    int ,
@Citizen varchar(50),
@Gender varchar(50) ,
@DOB    varchar(50) ,
@Status varchar(50) ,
@Nationality    varchar(50) ,

@Country    varchar(50) ,
@State  varchar(50) ,
@City   varchar(50) ,
@Address    varchar(MAX)    ,
@Pin    varchar(50) ,
@AccNo int IDENTITY (100,1),
@Branch varchar(50) ,

@IDProof    varchar(50) ,
@IDNo   varchar(50) ,
@IDName varchar(50) ,
@DOI    varchar(50) ,
@Date datetime
AS
BEGIN

Insert into tbl_Customer1   
values(@id,@FName,@MName,@LName,@Age,@Citizen,@Gender,@DOB,@Status,@Nationality)

Insert into tbl_Customer2 
values(@id,@Country,@State,@City,@Address,@Pin,@accno ,@Branch)

Insert into tbl_Customer3 
values(@id,@IDProof,@IDNo,@IDName,@DOI,@Date)

END

Here the error is

Msg 156, Level 15, State 1, Procedure Insert_Customer, Line 28
Incorrect syntax near the keyword 'IDENTITY'.
Msg 137, Level 15, State 2, Procedure Insert_Customer, Line 42
Must declare the scalar variable "@accno".
Msg 137, Level 15, State 2, Procedure Insert_Customer, Line 44
Must declare the scalar variable "@IDProof".

Upvotes: 0

Views: 541

Answers (2)

Diego
Diego

Reputation: 36146

@AccNo int IDENTITY (100,1),

you cant set a parameter as identity. Why do you need it in the first place?

This should be only on your table.

Can you explain why do you need it so we can help you?

Upvotes: 0

Umut Derbentoğlu
Umut Derbentoğlu

Reputation: 1196

You cannot declare INT IDENTITY variable / parameter. If particular column defined as IDENTITY column, you don't have to add it's value insert statement. If you don't specify column value, identity number automatically will set.

Upvotes: 1

Related Questions