请教问题,保存变量

cattycat 2010-04-23 04:35:34
sql存储过程中一条select语句选择了两个值,如何把这个赋给两个变量。

我声明了个变量

declare @tzjh numeric(19, 2)
declare @tzjl numeric(19, 2)

--然后有一个语句
select tzjh,tzjl from tzujin where year(tdtfrom)=year(getdate())
set @tzjh=tzjh
set @tzjl=tzjl

这个select可以不关心,但赋值不成功啊
...全文
104 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cattycat 2010-04-23
  • 打赏
  • 举报
回复
谢谢各位,我怎么没想到呢。
dawugui 2010-04-23
  • 打赏
  • 举报
回复
declare @tzjh numeric(19, 2)
declare @tzjl numeric(19, 2)

select @tzjh = tzjh,@tzjl = tzjl from tzujin where year(tdtfrom)=year(getdate())
sql_sf 2010-04-23
  • 打赏
  • 举报
回复
declare @tzjh numeric(19, 2)
declare @tzjl numeric(19, 2)

--然后有一个语句
select @tzjh=tzjh,@tzjl=tzjl from tzujin where year(tdtfrom)=year(getdate())
feixianxxx 2010-04-23
  • 打赏
  • 举报
回复
select @tzjh=tzjh,@tzj=tzjl from tzujin where year(tdtfrom)=year(getdate())

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧