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

    Red face Unanswered: how do i use the identity

    i set the identity at the column to yes. i thought its suppose to auto generate number, by when i try to add some data into the table this error message appear

    Cannot insert explicit value for identity column in table 'LoanItem' when IDENTITY_INSERT is set to OFF.

    i did not add any value into the column that auto generate number

  2. #2
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    To force value, the IDENTITY_INSERT needs to be set ON:

    SET IDENTITY_INSERT LoanITem ON
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  3. #3
    Join Date
    Mar 2004
    Posts
    21
    where do i put this statment

    SET IDENTITY_INSERT LoanITem ON [/SIZE][/QUOTE]

  4. #4
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    From Query analyzer before adding the data and you can execute it at runtime in your SPs.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

Posting Permissions

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