declare @fieldname2 varchar(200)
declare @sqls nvarchar(4000)
declare @int2 int
set @int2=369029
select @fieldname2=ffieldname
from t_FieldDescription where ftableid=1400004 and fdescription='工令号' set @sqls=' select '+ @fieldname2 + 'from iCMrpResult where finterid ='+ @int +'
exec(@sqls)
只要加上后面的where条件语句就报错
where finterid='+@int+'应该怎样写,为什么运行报错啊?谢
ސސސ
declare @sqls nvarchar(4000)
declare @int2 int
set @int2=369029
select @fieldname2=ffieldname
from t_FieldDescription where ftableid=1400004 and fdescription='工令号' set @sqls=' select '+ @fieldname2 + 'from iCMrpResult where finterid ='+ @int +'
exec(@sqls)
只要加上后面的where条件语句就报错
where finterid='+@int+'应该怎样写,为什么运行报错啊?谢
ސސސ
exec(@sqls)
其次,把@int改成CAST(@INT AS VARCHAR(10))
where finterid='+@int+'
后面多了一个+'号~