create table test(com_no int, flow_id int)
go
insert into test values(1,1)
insert into test values(2,1)
insert into test values(3,1)
insert into test values(4,2)
insert into test values(5,2)
insert into test values(45,2)
insert into test values(60,2)
go
select identity(int,12345,1) id, com_no into test_bak from test ;
go
update test set flow_id = test_bak.id
from test, test_bak
where test.com_no = test_bak.com_no
go
select * from test
go
drop table test , test_bak
go
select identity(int,12345,1) id, com_no into test_bak from t_rm_payflow ;
运行以上SQL后,提示:无法使用 SELECT INTO 语句向表 'test_bak' 中添加标识列,该表中已有继承了标识属性的列 'com_no'。
#8
-- 原表已有 identity 了,把这个简单的加工一下
select identity(int,12345,1) id, com_no +0 com_no into test_bak from t_rm_payflow ;
#9
用sql server 2005,用row_number就方便很多。
#10
-- 原表已有 identity 了,把这个简单的加工一下
select identity(int,12345,1) id, com_no +0 com_no into test_bak from t_rm_payflow ;
感谢。
#1
create table test(com_no int, flow_id int)
go
insert into test values(1,1)
insert into test values(2,1)
insert into test values(3,1)
insert into test values(4,2)
insert into test values(5,2)
insert into test values(45,2)
insert into test values(60,2)
go
select identity(int,12345,1) id, com_no into test_bak from test ;
go
update test set flow_id = test_bak.id
from test, test_bak
where test.com_no = test_bak.com_no
go
select * from test
go
drop table test , test_bak
go
create table test(com_no int, flow_id int)
go
insert into test values(1,1)
insert into test values(2,1)
insert into test values(3,1)
insert into test values(4,2)
insert into test values(5,2)
insert into test values(45,2)
insert into test values(60,2)
go
select identity(int,12345,1) id, com_no into test_bak from test ;
go
update test set flow_id = test_bak.id
from test, test_bak
where test.com_no = test_bak.com_no
go
select * from test
go
drop table test , test_bak
go
update test set com_no= test_bak.id
from test, test_bak
where test.com_no = test_bak.com_no
#4
create table test(com_no int, flow_id int)
go
insert into test values(1,1)
insert into test values(2,1)
insert into test values(3,1)
insert into test values(4,2)
insert into test values(5,2)
insert into test values(45,2)
insert into test values(60,2)
go
select identity(int,12345,1) id, com_no into test_bak from test ;
go
update test set flow_id = test_bak.id
from test, test_bak
where test.com_no = test_bak.com_no
go
select * from test
go
drop table test , test_bak
go