TSQL and the RETURN Function **SOLVED**
Hi all,
me again, still working on my Database script. I have a Problem using the Return Function of TSQL. I am using MS SQL Server 2000.
Heres my Table that I create:
Code:
CREATE TABLE Log
(
logId integer Identity(1,1) Primary Key Not Null,
created dateTime,
message varchar(50)
)
Go
Then I have a Stored Procedure:
Code:
CREATE Procedure spCreateLogEntry(@logId integer OUTPUT)
AS
INSERT INTO Log VALUES(GETDATE(),'blah')
SET @logIdId = RETURN(@@IDENTITY)
Go
GRANT EXEC ON spCreateLogEntry TO PUBLIC
Go
When I paste that into my Query Analyzer it says Incorrect syntax near the keyword 'Return'
The RETURN Function is supposed to return the created logId, since this is an autoincrement field in my Table. I need that value as return value of my Stored Procedure. Any ideas on how I can get this to work?
Thanks for your help,
Stephan
Re: TSQL and the RETURN Function
You don't need to use return there:
Code:
CREATE Procedure spCreateLogEntry(@logId integer OUTPUT)
AS
INSERT INTO Log VALUES(GETDATE(),'blah')
SET @logIdId = @@IDENTITY
Go
GRANT EXEC ON spCreateLogEntry TO PUBLIC
Go
Re: TSQL and the RETURN Function **SOLVED**
Thanks a lot again! **Hope that was my last TSQL Question**
Stephan