sql 语句中where子句后面like的条件如果有变量怎么写表达式?举例:申明游标等……declare @id varchar(50)fetch next from my_cursor into @idupdate tablename01 set 总数=sum(数量) from tablename02 ……where 数量 like @id

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/25 10:28:26
sql 语句中where子句后面like的条件如果有变量怎么写表达式?举例:申明游标等……declare @id varchar(50)fetch next from my_cursor into @idupdate tablename01 set 总数=sum(数量) from tablename02 ……where 数量 like @id
xMKAǿ\b] Ԡ۪AŸ(L׃ &(^ (M;z+43[Pe3_I i) ~tY6A)i&iQ أs|v{em^'i+d8$7iCr l$c`ruGtMᶜS =˪sJ 0BFАH~L̻K{:uk}"fb]y9[ +_Hx n +W1 ;vP&g{=\6ƣ=*QXvڗؼXO5gЙcGaɧ=1~{. @ax`F M_plE6=̓(4fB,7-

sql 语句中where子句后面like的条件如果有变量怎么写表达式?举例:申明游标等……declare @id varchar(50)fetch next from my_cursor into @idupdate tablename01 set 总数=sum(数量) from tablename02 ……where 数量 like @id
sql 语句中where子句后面like的条件如果有变量怎么写表达式?
举例:
申明游标等……
declare @id varchar(50)
fetch next from my_cursor into @id
update tablename01 set 总数=sum(数量) from tablename02
……
where 数量 like @id+'%'
可是like后面的都要在单引号之中才行啊,应该怎么写啊?

sql 语句中where子句后面like的条件如果有变量怎么写表达式?举例:申明游标等……declare @id varchar(50)fetch next from my_cursor into @idupdate tablename01 set 总数=sum(数量) from tablename02 ……where 数量 like @id
declare @sql varchar(1000)
set @sql = 'update tablename01 set 总数=sum(数量) from tablename02
……
where 数量 like ''' + cast(@id as varchar(10) + '%'''
EXEC(@sql)