--A、B:数据库
--Table1 表
SELECT * INTO #mytable1 FROM A.dbo.Table1 su WHERE su.code IN(SELECT su2.code FROM B.dbo.Table1 su2)
SELECT * from #mytable1
--DROP TABLE #mytable1
DECLARE myc CURSOR FOR SELECT * from #mytable1
OPEN myc
FETCH NEXT from myc
WHILE @@FETCH_STATUS=0
BEGIN
INSERT INTO Table1
(
setid,
code,
dname,
issys,
menucodes,
ddesc
)
SELECT setid,
code,
dname,
issys,
menucodes,
ddesc
FROM #mytable1
END
CLOSE myc
DEALLOCATE myc