This is the sample procedure I am using.
create procedure PRO_ProcName
@description varchar(max),
@txn_no varchar
as
begin
declare @txn table (
id bigint,
description varchar(max),
txn_no varchar
);
declare @txn_id bigint;
insert into transactions
(
description,
txn_no
)
output
inserted.description,
inserted.txn_no
into @txn
values
(
@description,
@txn_no
)
select @txn_id = id from @txn;
end
I am getting an error like:
Column name or number of supplied values does not match table definition.
I know that it is because I have id field in my temporary table and it is not getting inserted in the insert into statement. I cannot give value for id because it is the auto increment primary key.
How can I tackle this situation and get id of inserted record into a variable?