--AB:数据库

--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

posted on 2012-11-08 16:15  Roamman  阅读(229)  评论(0编辑  收藏  举报