Returning the identitt

Results 1 to 3 of 3

Thread: Returning the identitt

  1. #1
    Join Date
    Dec 1969

    Default Returning the identitt

    I want to create a procedure that outputs the identity when a new record has been created. The code below is giving me a Incorrect syntax near &#039;@intNo&#039;. error. Any help would be much appreciated.<BR><BR>Ray<BR><BR>CREATE PROCEDURE dbo.spIDTest<BR>(@intNo int output)<BR>AS <BR>Begin<BR>Insert into tblPrograms (ProgName)<BR>VALUES(&#039;NewProg1&#039;)<BR>--Return @@identity<BR>@intNo= @@identity<BR>END

  2. #2
    Join Date
    Dec 1969

    Default RE: Returning the identitt

    CREATE PROCEDURE dbo.spIDTest<BR>(@intNo int output)<BR>AS<BR>set nocount on<BR>Insert into tblPrograms (ProgName)<BR>VALUES(&#039;NewProg1&#039;)<BR>--Return @@identity<BR>set @intNo= @@identity<BR>

  3. #3
    Join Date
    Dec 1969

    Default But, it's actually easier..

    .. to return that as a recordset, instead of using output parameters.<BR><BR>If you use output parameters, then you&#039;ve got to use a Command object.

Posting Permissions

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