加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

如何使用T-SQL在一行中设置多个局部变量?

发布时间:2020-12-12 16:09:00 所属栏目:MsSql教程 来源:网络整理
导读:declare @inserted bitdeclare @removed bit 我知道可以将它们设置如下: SELECT @inserted = 0,@removed = 0 但是有可能使这更简单,并且使用如下: SET @inserted,@removed = 0 非常感谢 解决方法 怎么样: declare @inserted BIT = 0,@removed BIT = 0 在S
declare @inserted bit
declare @removed bit

我知道可以将它们设置如下:

SELECT @inserted = 0,@removed = 0

但是有可能使这更简单,并且使用如下:

SET @inserted,@removed = 0

非常感谢

解决方法

怎么样:
declare @inserted BIT = 0,@removed BIT = 0

在SQL Server 2008和以上(您没有指定哪个版本的SQL Server ….)

更新:好的,所以你坚持SQL Server 2005 – 在这种情况下,我相信这是最好的你可以做:

DECLARE @inserted BIT,@removed BIT
SELECT @inserted = 0,@removed = 0

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读