Can we assign more than one variable in on SELECT Statement in SQL Server? [closed]
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
精彩评论