mardi 14 novembre 2017

SQL Server: CASE WHEN with temp tables syntax errroring out

The logic I'm trying to implement is as follows: Replace certain strings with other strings for a specific column.

Leave string values that do not need to be replaced as their original values.

   SELECT * INTO #df_ERA4_a_temp 
            CASE WHEN [REQMNT] = 'A CHEC' THEN 'A CHECK'   
                 WHEN [REQMNT] = 'A-12' THEN 'A12'
                 WHEN [REQMNT] = 'A-9' THEN 'A9'
                 WHEN [REQMNT] = 'ADS-B' THEN 'ADSB' 
                 WHEN [REQMNT] = 'ADWK' THEN 'ADWORK'
                 WHEN [REQMNT] = 'ALI-W' THEN 'ALI-WRK'
                 ELSE [REQMNT]
            END  
    FROM #df_ERA4_a

Error: Msg 156, Level 15, State 1, Line 129 Incorrect syntax near the keyword 'CASE'.

Aucun commentaire:

Enregistrer un commentaire