重置SQL Server表中的默认值和自动递增主键-开发者之家

您所在的位置:网站首页 sql设置自动递增 重置SQL Server表中的默认值和自动递增主键-开发者之家

重置SQL Server表中的默认值和自动递增主键-开发者之家

2023-03-30 06:44| 来源: 网络整理| 查看: 265

问题描述

大家好, 我的数据库中有一个表,其主键允许为空``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



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3