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
 Transact-SQL (2000)
 Identity column

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-28 : 14:12:46
Deva writes "By using query, how to alter identity column field to some other datatype like int or char without using enterprise manager."

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-28 : 14:17:19
If the column is not the PK, then you can use ALTER TABLE ALTER COLUMN. If it is the PK, then you'll need to create a table that has the layout that you want, move your data from your table to this new table, then drop your table, then rename your new table to your table's name. Don't forget the constraints and indexes too.

If you want to see the code for this, you can make the change inside Enterprise Manager, but instead of saving the change, hit the save change script button and then close the table without saving. Now open the script in Query Analyzer to view the details.

Tara
Go to Top of Page
   

- Advertisement -