case statement issue

  • SELECT CASE

    WHEN EXISTS ( SELECT name,enabled FROM msdb.dbo.sysjobs

    WHERE name = 'Myjob' )

    THEN 'Exists'

    ELSE 'Does not exist'

    END as 'SQL Job'

    How do I add the enabled column to the output here?

    If job exists then print 'Exists' and its status as enabled or disabled as in the sysjobs table

    if job does not exist then print 'Does not exist' and under the status column as 'No job no status'

  • When exists(

    Select case when [enabled]=1 then [name] + ' Enabled' else [name] + ' Not Enabled' End

    )

  • CASE is  an expression, not a statement. Basics, please.

    Please post DDL and follow ANSI/ISO standards when asking for help. 

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply