日期:2014-05-19  浏览次数:20452 次

执行动态语句,单引号问题
做个查询,条件比较多,
大致意思如下:
declare   @strSQL   varchar(1000)

--select   *   from   table   where   col1   =   ' '   and   col2   =   ' '

select   @strSQL   =   ?
querry语句   是注释那条.@strSQL   该怎么写。
exec   @strSQL


------解决方案--------------------
declare @strSQL varchar(1000)
--select * from table where col1 = ' ' and col2 = ' '
select @strSQL = 'select * from table where col1 = ' ' ' ' and col2 = ' ' ' ' '
exec(@strSQL)
------解决方案--------------------
declare @strSQL varchar(1000)
select @strSQL = 'select * from table where col1 = ' ' ' ' and col2 = ' ' ' ' '
exec(@strSQL)