帮忙看下语句还是报错 declare @m_t varchar(50)
declare @m_t1 varchar(50)
set @m_t='book'
set @m_t1='张三'
update tj set 总金额=(select sum(价格) from '+@m_t+' where 价格>=50 and
账号 in (select 编号 from buy_book where name='''+@m_t1+''')
declare @m_t1 varchar(50)
set @m_t='book'
set @m_t1='张三'
declare @str varchar(max)
set @str='
update tj set 总金额=(select sum(价格) from '+@m_t+' where 价格>=50 and
账号 in (select 编号 from buy_book where name='''+@m_t1+''')
'
exec( @str)
------解决方案-------------------- declare @m_t varchar(50)
declare @m_t1 varchar(50)
declare @sql varchar(max)
set @m_t='book'
set @m_t1='张三'
set @sql='update tj set 总金额=(select sum(价格) from '+@m_t+' where 价格>=50 and
账号 in (select 编号 from buy_book where name='''+@m_t1+''')'
exec(@sql)
------解决方案--------------------
declare @m_t varchar(50)
declare @m_t1 varchar(50)
set @m_t='book'
set @m_t1='张三'
DECLARE @sql VARCHAR(max)
SET @sql='update tj set 总金额=(select sum(价格) from '+@m_t+' where 价格>=50 and
账号 in (select 编号 from buy_book where name='''+@m_t1+'''))'