select @Variable1 = ip ,@Variable2 = apps from tablea where id = 23执行上面语句,下面错误提示 sqlserver 数据库
消息 141,级别 15,状态 1,第 11 行
向变量赋值的 SELECT 语句不能与数据检索操作结合使用。
求解决方案 , 怎么赋值?
消息 141,级别 15,状态 1,第 11 行
向变量赋值的 SELECT 语句不能与数据检索操作结合使用。
求解决方案 , 怎么赋值?
create table tablea(id int,ip varchar(15),apps varchar(10))
insert into tablea select 23,'127.0.0.1','aaa'
go
declare @Variable1 varchar(15),@Variable2 varchar(10)
select @Variable1 = ip ,@Variable2 = apps from tablea where id = 23select @Variable1,@Variable2
/*
--------------- ----------
127.0.0.1 aaa(1 行受影响)*/
go
drop table tablea
create table tablea(id int,ip varchar(15),apps varchar(10))
insert into tablea select 23,'127.0.0.1','aaa'
insert into tablea select 23,'127.0.0.2','abb'
go
declare @Variable1 varchar(15),@Variable2 varchar(10)
select @Variable1 = ip ,@Variable2 = apps from tablea where id = 23select @Variable1,@Variable2
/*
--------------- ----------
127.0.0.2 abb(1 行受影响)*/
go
drop table tablea
@userup = sum(case uid when 0 then 0 else 1 end ) ,
@countsize sum(filesize ) ,
@countip count (distinct(uploadip)) ,
@countdown = sum(downcount)
from up_fileinfo where CONVERT(char(8) , uploadtime, 112 ) = @timechar