2008R2更新链接服务器(SQL2000)慢的问题

15秒跟2秒之间的区别    

      UPDATE    a   SET       flag = 1   FROM      LINK_39.test_01.dbo.NSB_test AS a   WHERE     bh IN ( SELECT TOP 500                             bh                     FROM    LINK_39.test_01.dbo.NSB_test                     WHERE   bh IS NOT NULL                     ORDER BY bh )

DECLARE @bh VARCHAR(MAX)= ''

  SELECT    @bh = @bh + ',' + CAST(CAST(bh AS INT) AS VARCHAR(10))   FROM      (               SELECT TOP 500                         bh               FROM      LINK_39.test_01.dbo.NSB_test               WHERE     bh IS NOT NULL               ORDER BY  bh             ) s         --SELECT  RIGHT(@bh, LEN(@bh) - 1)

DECLARE @sql VARCHAR(MAX)   SET @sql = '   UPDATE    a   SET       flag = 1   FROM      LINK_39.test_01.dbo.NSB_test AS a   WHERE     bh IN ('     SET @sql = @sql + RIGHT(@bh, LEN(@bh) - 1) + ') '   PRINT @sql   EXEC( @sql)  

posted @ 2012-06-28 17:27  qanholas  阅读(1391)  评论(0编辑  收藏  举报