@@IDENTITY

  • i am trying to get the @@identity in sql server mobile 05 once i have done an insert in query analyser.

    insert PHCR_Record (Patient_FName,Patient_SName) values('a','b')

    SELECT @@IDENTITY AS 'IDENTITY'

    can anyone advise me as it does not seem to work

    thanks

    adam

  • When you say that it doesn't work what exactly do you mean?

    Presumably PHCR_Record has an identity column?

    Is @@IDENTITY returning an incorrect value? If so use SCOPE_IDENTITY() instead.

  • Don't be offended if this is blindingly obvious to you, but does the PHCR_Record table have an IDENTITY column defined?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Major Error 0x80040E14, Minor Error 25501

    > insert PHCR_Record (Patient_FName,Patient_SName)values('a','b')

    SELECT @@IDENTITY AS 'IDENTITY'

    There was an error parsing the query. [ Token line number = 2,Token line offset = 1,Token in error = SELECT ]

    ColumnName - PCRNo             

    Data Type -  int   

    Size  - 4

    Allow Nulls - No

    Unique - Yes

    Primary Key - Yes

    Identity - Yes

    IdentityIncrement - 1

    IdentitySpeed - 1

     

    It works ok on a sql server 05 table but not sql server mobile 05.

    If i do a select statement in query analyser after doing an insert i must user a semi column after the insert statement and the select statement or it fails i.e.

    insert

    PHCR_Record (Patient_FName,Patient_SName)values('a','b');

    SELECT

    * from PHCR_Record

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

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