开发者

Can we assign more than one variable in on SELECT Statement in SQL Server? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, 开发者_运维问答overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Can we assign more than one variable in on SELECT Statement ?

Like:

SELECT @variable1 = c1+c2  , @variable2 = c1-c2  from someView

it dosn't work in SQL Server

please help

Thanks...


Yes, SQL Server allows this

CREATE TABLE fish (c1 int, c2 int)
INSERT fish VALUES (1, 2)
GO
DECLARE @v1 int, @v2 int
SELECT
   @v1 = c1-c2, @v2 = c1+c2
FROM
  fish

SELECT @v1, @v2

So, you are not giving us full information:

  • query
  • data
  • error message
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜