当前位置: 代码迷 >> Sql Server >> 不知怎么写,请帮小弟我 多谢
  详细解决方案

不知怎么写,请帮小弟我 多谢

热度:84   发布时间:2016-04-27 15:14:00.0
不知如何写,请帮我 谢谢
如,我想得到这样的效果
MS   2005中

declare   @temp   int
declare   @TempSql   =   '   aa <> ' '休假 ' '   and   bb <> ' '请假 ' ' '

exec   ( 'select   @temp=1   from   uds_style   where   '[email protected])

总是报错,[email protected]

不知道如何办,我就是想得到判断这个SQL能不能查到都东西了,


谢谢

------解决方案--------------------
top 1應該不是樓主的需求。

輸出參數使用sp_executesql

declare @temp int
declare @TempSql Nvarchar(100), @Sql Nvarchar(1000)
Select @TempSql = ' aa <> ' '休假 ' ' and bb <> ' '请假 ' ' '
Select @Sql = 'select @temp=1 from uds_style where '[email protected]
EXEC sp_executesql @Sql,N '@temp int output ',@temp output
  相关解决方案