舉例:申明游標(biāo)等……declare @id varchar(50)fetch next from my_cursor into @idupdate tablename01 set 總數(shù)=sum(數(shù)量) from tablename02……where 數(shù)量 like @id+'%'可是like后面的都要在單引號之中才行啊,應(yīng)該怎么寫啊?
2 回答

開心每一天1111
TA貢獻(xiàn)1836條經(jīng)驗 獲得超13個贊
declare @sql varchar(1000)
set @sql = 'update tablename01 set 總數(shù)=sum(數(shù)量) from tablename02
……
where 數(shù)量 like ''' + cast(@id as varchar(10) + '%'''
EXEC(@sql)

三國紛爭
TA貢獻(xiàn)1804條經(jīng)驗 獲得超7個贊
declare @id varchar(50)
fetch next from my_cursor into @id
update tablename01 set 總數(shù)=sum(數(shù)量) from tablename02
……
where 數(shù)量 like ‘@id+‘%’’
添加回答
舉報
0/150
提交
取消