1、数据情况
两个数据库字段是一致的,其中OBJECTID是主键字段,而且两个表都是从1自增排序
2、需求
现在需要将另一个数据库中的数据,通过sqlserver语句的方法,来插入数据,保持自增字段是自增的
解决方法
sqlserver语句
SET IDENTITY_INSERT tablename2 OFF;
INSERT INTO tablename2 (SHAPE, Lng, Lat, MC, Address, Type, SystemID, State, UpdateTime, Province, City, County, Town, Village, Other, PoliceStationName, MC_X, MC_Y)
SELECT Shape, Lng, Lat, MC, Address, Type, SystemID, State, UpdateTime, Province, City, County, Town, Village, Other, PoliceStationName, MC_X, MC_Y
FROM tablename1
SET IDENTITY_INSERT tablename2 ON;