Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    205

    Unanswered: Returning cluase ?

    Hi,

    In Oracle, the below query is valid :

    insert into test(sno,sno1) values(1,2) returning id into val_ret;

    // The above query in Oracle returns the affected row id's to the PL/SQL or host vriable(val_ret)

    Is there any equivalent for the above in SQL Server ?

    Please advice,

    Thanks,
    Sam

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    insert into test(sno,sno1) values(1,2)
    select val_ret = @@identity
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Quote Originally Posted by r937
    insert into test(sno,sno1) values(1,2)
    select val_ret = @@identity
    rudy ... rudy ... rudy ... @@identity is so 5 minutes ago. How about select val_ret = scope_identity()

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sure, i hear that will work too

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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