重置SQL Server表中的默认值和自动递增主键 [英] reset default value and autoincrement primary key in sql server table

查看:198
本文介绍了重置SQL Server表中的默认值和自动递增主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的数据库中有一个表,其主键允许为空``NO'',默认值设置为``((0))'',身份标识设置为``No''.

我需要主键来自动递增.因此请清除默认值,并将身份规范设置为是".

但是我需要它可以自动增加我的主列并删除默认值的sql查询.

谢谢,
KK

Hi all,

I have table in my database with primary key allow null ''NO'', default value set to ''((0))'' and identity specification to ''No''.

I need primary key to auto increment. so blank out default value and set identity specification to ''Yes''.

but i need sql query for that which can auto increment my primary column and remove default value.

Thanks,
KK

推荐答案



我找到了部分解决方案.我可以通过以下查询重置默认值.

ALTER TABLE tblname DROP CONSTRAINT约束.

但是自动增加我现有的主键的脚本将是什么?

谢谢,
kk
Hi,

I found partially solution. i can reset the default value by below query.

ALTER TABLE tblname DROP CONSTRAINT constraint.

but what will be the script to auto increment my existing primary key?

thanks,
kk


这篇关于重置SQL Server表中的默认值和自动递增主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆