当前位置: 代码迷 >> Sql Server >> 语句没有梳理清楚,该怎么解决
  详细解决方案

语句没有梳理清楚,该怎么解决

热度:57   发布时间:2016-04-27 14:22:03.0
语句没有梳理清楚

declare @Purviewsub varchar(1000)
declare @PSysM1d18sub varchar(20)
set @Purviewsub='select * from PSysM001 where PSysM0a01=1'
set @PSysM1d18sub='001'


SELECT @[email protected]+' AND PHumM0a07>[email protected]+''''

print @Purviewsub+'@@@@@'


[email protected] [email protected]+''' 不理解 求高手指教下



------解决方案--------------------
动态拼接的字符串里,字符类型的数据因为有引号,拼接字符串时两个'表示一个,所以会出现 [email protected]

类似 @sql = 'select * from tb where name = '''+张三+''' order by name'

红色部分是为了表示 '张三' 左右两边的引号。
  相关解决方案