declare @pid varchar(200),@strWhere varchar(800)
exec('select ' +@pid+'=picid from t_classpicture where 1=1 ' +@strWhere+')')这段SQL拼凑语句出错,报“消息 102,级别 15,状态 1,第 1 行
'=' 附近有语法错误。”这种错误,求解,不胜感激
exec('select ' +@pid+'=picid from t_classpicture where 1=1 ' +@strWhere+')')这段SQL拼凑语句出错,报“消息 102,级别 15,状态 1,第 1 行
'=' 附近有语法错误。”这种错误,求解,不胜感激
print 'select ' +@pid+'=picid from t_classpicture where 1=1 ' +@strWhere+')'
exec('select ' +@pid+ '=picid from t_classpicture where 1=1 ' +@strWhere+')')
你最好在用前先set @变量=''
insert into t_classpicture
select '100','bill' union all
select '200','james'declare @pid varchar(200)
set @pid = '100'
declare @strWhere varchar(800)
set @strWhere = ' and createper = ''james'''
exec ('select '''+@pid+''' = picid from t_classpicture where 1=1 '+@strWhere+'')