27,579
社区成员
发帖
与我相关
我的任务
分享
declare @a nvarchar(200)
select @a = parts from table2
print @a -->'电修','机修'
exec('select SUM(mony) from table1 where part not in ('''+@a+''')')
或者:
declare @a nvarchar(200)
select @a = parts from table2
print @a -->'电修','机修'
EXEC('select SUM(mony) from table1 where part not in ('+@a+')')
declare @a nvarchar(200)
select @a = parts from table2
print @a -->'电修','机修'
exec('select SUM(mony) from table1 where part not in ('+@a+')')
declare @a nvarchar(200)
select @a = parts from table2
print @a -->'电修','机修'
select SUM(mony) from table1 where charindex(','+part+',',','+@a+',')=0