SQL CASE and local variables

后端 未结 5 1246
忘了有多久
忘了有多久 2021-02-07 23:47

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;
    DE         


        
5条回答
  •  后悔当初
    2021-02-08 00:25

    DECLARE @Test int;
    SET @Test = 10;
    
    SELECT 
    CASE @Test
    WHEN 10
    THEN 'OK test'
    END
    

    For SQL server 2005

提交回复
热议问题