I would like to know how I can use local variables in CASE statements in SQL?
This script gives me an error:
DECLARE @Test int;
DECLARE @Result char(10);
SET @Test = 10;
CASE @Test
WHEN @Test = 10
THEN SET @Result='OK test'
END
Print @Result;
I use MS SQL 2008.
Two ways to use CASE in this scenario with MSSQL