简体   繁体   English

改变mssql列以在没有t-sql的情况下添加自动增量

[英]alter mssql column to add auto increment without t-sql

It is possible to alter existing MSSQL column to add auto increment option to this column (it is primary key, but not auto increment) without writing t-sql code, but just with alter stratements? 可以改变现有的MSSQL列,在没有编写t-sql代码的情况下向该列添加自动增量选项(它是主键,但不是自动增量),但只是改变了吗?

I can find solution with t-sql, but I need without it. 我可以用t-sql找到解决方案,但我需要没有它。

according to this link http://social.msdn.microsoft.com/Forums/sqlserver/en-US/04d69ee6-d4f5-4f8f-a115-d89f7bcbc032/how-to-alter-column-to-identity11 "You can't alter the existing columns for identity." 根据这个链接http://social.msdn.microsoft.com/Forums/sqlserver/en-US/04d69ee6-d4f5-4f8f-a115-d89f7bcbc032/how-to-alter-column-to-identity11 “你不能改变现有列的身份。“ It provides a couple of possible solutions. 它提供了几种可能的解决方案。 Relevant commands are: 相关命令是:

alter table YourTable drop column OldId
alter table YourTable add NewId int identity(1,1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM