读书人

如在createID表中的ID字段原来为100

发布时间: 2012-09-09 09:27:54 作者: rapoo

如在createID表中的ID字段,原来为10000起, 现在想改为2600000起 ,用语句怎么写
在SQL Server2005中,如在createID表中的ID字段,原来为10000起, 现在想改为2600000起 ,用语句怎么写

[解决办法]

SQL code
if OBJECT_ID('tb_test','u') is not null drop table tb_testgocreate table tb_test (    id int identity(10000,1),    name varchar(50))goinsert into tb_test(name)select 'ab' union allselect 'cd' union allselect 'ef'goselect * from tb_test/*id          name----------- --------------------------------------------------10000       ab10001       cd10002       ef(3 row(s) affected)*/go--通过 DBCC CheckIdent(TB_Name,RESEED,StartNum) 方法改变dbcc CHECKIDENT(tb_test,reseed,2600000)goinsert into tb_test(name)select 'gh' union allselect 'ii' union allselect 'gg'goselect * from tb_testgo/*id          name----------- --------------------------------------------------10000       ab10001       cd10002       ef2600001     gh2600002     ii2600003     gg(6 row(s) affected)*/
[解决办法]
探讨

SQL code

if OBJECT_ID('tb_test','u') is not null drop table tb_test
go
create table tb_test
(
id int identity(10000,1),
name varchar(50)
)
go
insert into tb_test(name)
select 'ab' union al……

[解决办法]
搂主ID字段是否自增字段,是不是需要以下语句?


SQL code
DBCC CHECKIDENT ("DBNAME.TABLENAME", RESEED, 2600000);
[解决办法]
探讨
SQL code


if OBJECT_ID('tb_test','u') is not null drop table tb_test
go
create table tb_test
(
id int identity(10000,1),
name varchar(50)
)
go
insert into tb_test(name)
select 'a……

[解决办法]
探讨

SQL code

if OBJECT_ID('tb_test','u') is not null drop table tb_test
go
create table tb_test
(
id int identity(10000,1),
name varchar(50)
)
go
insert into tb_test(name)
select 'ab' union al……

读书人网 >SQL Server

热点推荐