存储过程 怎么把sql语句查到的值赋给变量
存储过程怎么把sql语句查到的值赋给变量,如下:select@idcount=selectclickfromtv_clickwhereid=@id我知道像我这样写肯定是错...
存储过程 怎么把sql语句查到的值赋给变量,如下:select @idcount= select click from tv_click where id =@id
我知道像我这样写肯定是错误的,但是我只是想表达这个意思。
CREATE PROCEDURE [dbo].tv_click
@id int
AS
BEGIN
declare @idcount bigint,@topidcount bigint,@clickcount bigint
select @idcount= select click from tv_click where id =@id
select @topidcount=select click from tv_click where topid =@id
select @clickcount=@idcount+@topidcount
print @clickcount
END 展开
我知道像我这样写肯定是错误的,但是我只是想表达这个意思。
CREATE PROCEDURE [dbo].tv_click
@id int
AS
BEGIN
declare @idcount bigint,@topidcount bigint,@clickcount bigint
select @idcount= select click from tv_click where id =@id
select @topidcount=select click from tv_click where topid =@id
select @clickcount=@idcount+@topidcount
print @clickcount
END 展开
展开全部
添加上存储过程的参数试试,可参考如下程序:
create proc getJobInfo
@eid varchar(50),
@dname varchar(50) output,
@pname varchar(50) output,
@manager varchar(50) output,
@status varchar(50) output,
@joindate varchar(50) output
as
declare @parentid varchar(50)
select @parentid=b.parentid from employee a ,position b where a.eid=@eid and a.pid=b.pid
select @dname=dname from employee a,dept b where a.eid=@eid and a.did =b.did
--print @dname
select @pname =pname from employee a,position b where a.eid=@eid and a.pid=b.pid
--print @pname
select @manager=ename from employee where pid=@parentid
--print @manager
select @status =b.sttus_name from employee a,status b where eid=@eid and a.status=b.status_id
--print @status
select @joindate =joindate from employee where eid=@eid
--print @joindate
go
create proc getJobInfo
@eid varchar(50),
@dname varchar(50) output,
@pname varchar(50) output,
@manager varchar(50) output,
@status varchar(50) output,
@joindate varchar(50) output
as
declare @parentid varchar(50)
select @parentid=b.parentid from employee a ,position b where a.eid=@eid and a.pid=b.pid
select @dname=dname from employee a,dept b where a.eid=@eid and a.did =b.did
--print @dname
select @pname =pname from employee a,position b where a.eid=@eid and a.pid=b.pid
--print @pname
select @manager=ename from employee where pid=@parentid
--print @manager
select @status =b.sttus_name from employee a,status b where eid=@eid and a.status=b.status_id
--print @status
select @joindate =joindate from employee where eid=@eid
--print @joindate
go
参考资料: http://zhidao.baidu.com/question/45667622.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
CREATE PROCEDURE [dbo].tv_click
@id int
AS
BEGIN
declare @idcount bigint,@topidcount bigint,@clickcount bigint
select @idcount= click from tv_click where id =@id
select @topidcount= click from tv_click where topid =@id
set @clickcount=@idcount+@topidcount
print @clickcount
END
@id int
AS
BEGIN
declare @idcount bigint,@topidcount bigint,@clickcount bigint
select @idcount= click from tv_click where id =@id
select @topidcount= click from tv_click where topid =@id
set @clickcount=@idcount+@topidcount
print @clickcount
END
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询