Hi everyBody,
I Tried to use "OutPut" clause in insert statment as fallows:
insert into test
OUTPUT Inserted.Name,Inserted.LastName
values ('John','kransky')
The Error:
Line 2: Incorrect syntax near 'OUTPUT'.
but I face with this error,I checked MSDN and the other sources, it seems everything is ok. But when I run it ,I face with that error message.I would be appriciate if someone help me on it.
OUTPUT values MUST be 'captured' in some fashion. Typically, the OUTPUT values are captured in a @.Temp table.
For Example, this might work for you:
Code Snippet
DECLARE @.NewRows table
( [Name] varchar(20),
LastName varchar(20)
);
INSERT INTO Test
OUTPUT Inserted.Name, Inserted.LastName
INTO @.NewRows
VALUES ( 'John', 'kransky' );
Then you can use the data in the @.NewRows table however you wish.
No comments:
Post a Comment