存储过程的变量赋值问题

jadesun 2002-01-22 05:33:17
declare @sp_card_number varchar(50) 我在存储过程中设定一个变量

运行这句SELECT语句
select top 1 card_number from card_data where left(card_number,2) = @card_type and no_send='1' and no_employ='1'

然后想把得出的结果card_number赋值给sp_card_number,该怎么写呢?

注:同在一个存储过程中完成
...全文
144 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wylyf 2002-01-22
  • 打赏
  • 举报
回复
select @sp_card_number = (select top 1 card_number from card_data where left(card_number,2) = @card_type and no_send='1' and no_employ='1')
Robin_Fang 2002-01-22
  • 打赏
  • 举报
回复
select top 1 @sp_card_number = card_number from card_data where left(card_number,2) = @card_type and no_send='1' and no_employ='1'
lyl_rabbit 2002-01-22
  • 打赏
  • 举报
回复
同一楼上的
windindance 2002-01-22
  • 打赏
  • 举报
回复
select top 1 @sp_card_number = max(card_number) from card_data where left(card_number,2) = @card_type and no_send='1' and no_employ='1'

34,576

社区成员

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

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