Modify two variables within a THEN

0

Good afternoon: What I need is the following: Within a CASE , you can manipulate two different variables in the THEN (ex: @var1=a and @var2=1 ) in case the WHEN is fulfilled.

I have not been able to do it. I tried all the possible syntax but I always get an error. It only allows me to manipulate a single variable in THEN since putting and or , to manipulate another variable gives me the error, as I try to represent in bold in the following example.

WHEN @dia = 'Friday' THE GETDATE () + 3) AND @ var = 4

PS: it is not a duplicate question. Greetings. Juan

    
asked by lanshare 02.08.2017 в 22:11
source

1 answer

2

Instead of the case use a if , this way it will allow you to perform several actions after the begin .

Declare
@dia varchar(255),
@fecha datetime,
@var int
Set @dia='viernes'

print @dia

IF @dia = 'Viernes'
BEGIN
    Set @fecha=GETDATE()
    Set @var=4      
END

print @fecha
print @var

Result

  

Friday

     

Aug 3 2017 3:05 PM

     

4

    
answered by 03.08.2017 / 15:06
source