0

I am working in SQL Parallel Data Warehouse / APS. I am trying to set the values of multiple variables in a single SELECT statement. My code is:

DECLARE
    @var1 int
    ,@var2 int
;
SELECT
    @var1 = col1
    ,@var2 = col2
FROM
    A
;

PDW is throwing the following error:

Parse error ... Incorrect syntax near '='

Is this not valid syntax on PDW? If not, how do I resolve?

skyline01
  • 1,919
  • 8
  • 34
  • 55

1 Answers1

1

Yes there is a restriction on how you assign variable values. Try this instead:

DECLARE
    @var1 int
    ,@var2 int
;
SET @var1 = (SELECT col1 FROM A);
SET @var2 = (SELECT col2 FROM A);
GregGalloway
  • 11,355
  • 3
  • 16
  • 47