Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Identity columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-17 : 09:38:51
Sira writes "Can someone explain how to work with data of identity columns? For example Can you add an identity to an existing table without dropping the structure or what to do if it is the primary key as well? What do you do when copying data/appending from one table to another...Does something need to be turned off and set max + 1 and how to do it thru an example...like in Query Analyzer or Enterprise Manager?"

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2002-04-17 : 11:10:23
In a basic sense, the identity column is used to automatically create a unique value for each row based on the Identity Seed (what number it starts at) and Increment (how much it adds every time). For most tables, both of these would be 1.

You can (at least in SS7), add an identity column to an existing table, and the server will automatically number the existing rows based on the seed and increment values.

When you're inserting records, you can let the server assign the identity columns for you (just leave the column out of your INSERT statement), or you can explicitly define the contents of the identity column (you just need to execute a SET IDENTITY_INSERT OFF, execute your insert statement, then turn it back on with SET IDENTITY_INSERT ON).

Hope this helps....



Go to Top of Page

Sira
Starting Member

5 Posts

Posted - 2002-04-24 : 14:54:40
I was referring to updating columns thru dts and they have an option to disable identity so I was wondering if you are thus appending records what to do?

Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-04-24 : 17:16:41
Sira,

We have a number of article relating to IDENTITY columns (http://www.sqlteam.com/FilterTopics.asp?TopicID=131). You might take a second to read through them as they answer the questions you raised.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
   

- Advertisement -