Quantcast
Channel: Solved » sql-server
Viewing all articles
Browse latest Browse all 48

Adding Identity Property to Existing Column

$
0
0

In SQL Server (in my case, 2005) how can I add the identity property to an existing table coulumn using t-sql?

something like:

alter table tblFoo alter column bar identity(1,1)

Solution

I don’t beleive you can do that. Your best bet is to create a new identity column and copy the data over using an identity insert command (if you indeed want to keep the old values).

Here is a decent article describing the process in detail:
http://www.mssqltips.com/tip.asp?tip=1397

The post Adding Identity Property to Existing Column appeared first on Solved.


Viewing all articles
Browse latest Browse all 48

Trending Articles