Identity Columns

Results 1 to 2 of 2

Thread: Identity Columns

  1. #1
    Join Date
    Dec 1969

    Default Identity Columns

    How do i do an insert into an SQL Server table that has an Identity column but I want to insert several entries overiding the Identity value (manually). Is there a way to do this? Thanks for your help.

  2. #2
    Join Date
    Dec 1969

    Default RE: Identity Columns

    what you want to do sounds bad to me since it goes against the intended use of identity property but anyway... Here is some ideas that might help you:<BR><BR>1) to insert values into identity column you have to use the SET_IDENTITYINSERT option. Some restrictions apply on this so see TSQL help for details. You would also need to use the INCREMENT option on the IDENTITY column in order to leave &#039gaps&#039 between automatically assigned values. Then you could insert values between the gaps.<BR><BR>2) you could use an INT column to store the actual values, then you can put in whatever you like. You could have an additional column that has IDENTITY property. You could then use the identity values as defaults for the int field, but overwrite them with specific values as needed. Maybe you could set up a trigger or stored procedure to do this work for you.<BR><BR>good luck<BR>Tim

Posting Permissions

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