举例: 申明游标等…… declare @id varchar(50) fetch next from my_cursor into @id update tablename01 set 总数=sum(数量) from tablename02 …… where 数量 like @id+'%' 可是like后面的都要在单引号之中才行啊,应该怎么写啊?
蝴蝶不菲
浏览 398回答 2
2回答
开心每一天1111
declare @sql varchar(1000)set @sql = 'update tablename01 set 总数=sum(数量) from tablename02……where 数量 like ''' + cast(@id as varchar(10) + '%'''EXEC(@sql)