2017-04-12 85 views
-1

我想從SQL Server CE中刪除列的自動增量。無論我做什麼,我都無法刪除自動增量。可以通過更改表格嗎?誰能幫幫我嗎?SQL Server CE自動增加問題

+0

你已經試過了什麼?它給出了錯誤或其他? – GuidoG

+1

創建新列,複製值,刪除ident列,重命名新列 –

+0

是sql-server還是sql-ce? – Kritner

回答

1
 The easiest way would be: 

     1) Open SQL Server Management Studio. 
     2) Locate Server > DataBase > Table. 
     3) Right Click on the Table > Select Design. 
     4) In the design window, Highlight the column you want to modify. 
     5) In the Column Properties Window browse to Identity Specification > Is Identity And set to No. 

-- OR BY ALtering The Table You Can remove the auto-increment column 

     CREATE TABLE test(col1 INT IDENTITY (1,1) NOT NULL, col2 VARCHAR(10) NULL); 

     ALTER TABLE test ADD col3 INT NULL; 

     UPDATE test SET col3 = col1; 

     ALTER TABLE test DROP COLUMN col1; 

     EXEC sp_rename 'dbo.test.col3', 'col1', 'COLUMN'; 
+0

如果col1標記爲主鍵,那麼放置列是否可以工作? – GuidoG

+0

@GuidoG是的會的 –