日期:2014-05-17 浏览次数:20563 次
----有自增列的话 这样 set identity_insert tablename on INSERT INTO A SELECT * FROM B WHERE ... set identity_insert tablename off
------解决方案--------------------
IF OBJECT_ID('TB1') IS NOT NULL DROP TABLE TB1 IF OBJECT_ID('TB2') IS NOT NULL DROP TABLE TB2 GO CREATE TABLE TB1(COL1 INT,COL2 INT,COL3 INT,COL4 INT,COL5 INT) CREATE TABLE TB2(COL1 INT,COL2 INT,COL3 INT,COL4 INT,COL5 INT) INSERT INTO TB1 SELECT 1,2,3,4,5 DECLARE @NAME1 VARCHART