January 5, 2012 at 7:32 am
I wrote this query for finding a list of SQL Server disable Agent jobs in SQL 2008
select j.Name , (case when k.Job_ID ISnull then 'Temporary' else 'Permanent' end )as 'Job_Status' from
( select * from msdb.dbo.sysjobs where enabled = 0 ) as j left outer join SQLAdmins.dbo.DisabledServerAgentJobs as k
on j.job_id = k.Job_ID
I got following errors:
Msg 4145, Level 15, State 1, Line 1
An expression of non-boolean type specified in a context where a condition is expected, near 'ISnull'.
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'as'
Please help me to slove this error. I am new in sql development.:crying:
Thanks in Advance..
January 5, 2012 at 7:36 am
your first line:
select j.Name , (case when k.Job_ID ISnull then 'Temporary' else 'Permanent' end )as 'Job_Status' from
should have a space between is and null:
case when k.job_ID IS NULL then...
January 5, 2012 at 7:47 am
And there is no need for a subquery as your main table. You are pulling back a lot of information you don't need. You used select * when you only need a single column.
select j.Name , case when k.Job_ID IS null then 'Temporary' else 'Permanent' end as Job_Status
from msdb.dbo.sysjobs j
left outer join SQLAdmins.dbo.DisabledServerAgentJobs as k on j.job_id = k.Job_ID
where j.enabled = 0
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 5, 2012 at 9:14 am
Hye It's working...
Thank you so much...:-)
January 5, 2012 at 9:19 am
You're welcome. thanks for letting us know that worked for you.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply