A表和B表结构是一样的,但是如下语句出错,多谢高人指点!
INSERT INTO A
SELECT * FROM B WHERE ...
------解决方案--------------------
A表是不是有自增字段,是不是有主键,是不是A,B表中字段顺序一致?
------解决方案--------------------
- SQL code
----有自增列的话 这样set identity_insert tablename onINSERT INTO A SELECT * FROM B WHERE ... set identity_insert tablename off
------解决方案--------------------
------解决方案--------------------
设了on时,要用insert into table(fields...)values(value...)句式
------解决方案--------------------
- SQL code
IF OBJECT_ID('TB1') IS NOT NULL DROP TABLE TB1IF OBJECT_ID('TB2') IS NOT NULL DROP TABLE TB2GOCREATE 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 TB1SELECT 1,2,3,4,5DECLARE @NAME1 VARCHART