SCOPE_IDENTITY

  • Hi all,

    I am using sql server 2000. I have two table like t1 and t2. Iam using the trigger for the table t2. Now the problem is i want to get the last insert identity value. If i am using @@identity it was give the trigger table value.

    Then i try to use SCOPE_IDENTITY (). But it throws the error like 'SCOPE_IDENTITY' is not a recognized function name. Please help me on this.

  • That sounds strange. scope_identity function does exist in SQL Server 2000. Could it be that the database's compatibility level is set to an earlier version that didn't have this function?

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Adi is correct, it's valid in 2000. http://msdn.microsoft.com/en-us/library/aa259185(SQL.80).aspx

    Can you post the code you're using?

    Also, double check the instance you are on is SQL 2000. Select @@version. And look at the database properties (options tab) for the db level. I suspect it's at 7 or earlier, as Adi mentioned.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply