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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-03-02 : 08:51:27
|
Pramod writes "I want to change the primary key field of my database to Identity seed. the table is with data. data should be securedthis is the structure'=================================CREATE TABLE [tblStock] ( [StockId] [numeric](18, 0) NOT NULL , [ItemID] [numeric](18, 0) NULL , [Batch] [varchar] (50) NULL , [Qty] [float] NULL , [Prate] [float] NULL , [SRate] [float] NULL , [Mrp] [float] NULL , [PTR] [float] NULL , [batchid] [numeric](18, 0) NULL , [BatchCode] [varchar] (50) NULL , CONSTRAINT [PK_tblStock] PRIMARY KEY NONCLUSTERED ( [StockId] ) ON [PRIMARY] , CONSTRAINT [IX_tblStock] UNIQUE NONCLUSTERED ( [ItemID], [Batch], [Prate] ) ON [PRIMARY] ) ON [PRIMARY]===================================How do i use alter table with identity seedALTER TABLE tblStock alter column StockID Numeric IDENTITY (1, 1)how the p[rimary key affectsPlease help me" |
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-03-03 : 05:25:50
|
make sure the seed is the max value you have on the identity field... otherwise you get pk duplicate errortry it out, create a duplicate table with different name and issue the command you mentionedhth--------------------keeping it simple... |
|
|
|
|
|
|
|