读书人

执行动态语句单引号有关问题

发布时间: 2012-03-09 21:42:52 作者: rapoo

执行动态语句,单引号问题
做个查询,条件比较多,
大致意思如下:
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)

读书人网 >SQL Server

热点推荐