--exec(@sql) 
print (@sql)打印出来看,慢慢理解

解决方案 »

  1.   

    但打印出来的只是最终的SQL语句,我想知道为什么要这样写
    对了,再有就是我要想调试的话,还有什么语句或者方法可以用呢?
    谢谢小楼,呵
      

  2.   

    动态SQL,一般就是用print调试。declare @name sysname
    set @name = 'sysobjects'
    print ('select * from sysobjects where name = '+ @name)
    print ('select * from sysobjects where name = '''+ @name + '''')
      

  3.   

    哈,明白了,
    用print''''这个在查询分析器里试试就知道了,呵