Results 1 to 3 of 3

Thread: TSQL and the RETURN Function **SOLVED**

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Resolved 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
    Last edited by Sgt-Peppa; Jun 24th, 2005 at 06:22 AM. Reason: SOLVED
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016

    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
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: TSQL and the RETURN Function **SOLVED**

    Thanks a lot again! **Hope that was my last TSQL Question**

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width