<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tag 'SQL Server Agent'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SQL+Server+Agent&amp;orTags=0</link><description>Search results matching tag 'SQL Server Agent'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Express Edition revisited, focus on SSMS</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2013/01/30/express-edition-revisited-focus-on-ssms.aspx</link><pubDate>Wed, 30 Jan 2013 17:01:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47398</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;p&gt;&amp;nbsp;(Note: I have re-written parts of this post in the light of the comments that SP1 of 2012 include Complete tools.)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I have decided to revisit the topic of whats included in Express Edition, with focus on the tools. I have a couple of reasons for this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In my &lt;a href="http://sqlblog.com/blogs/tibor_karaszi/archive/2011/02/10/what-does-this-express-edition-look-like-anyhow.aspx"&gt;2011 post&lt;/a&gt;, I never tried to connect from Express SSMS to a non-Express database engine.&lt;/li&gt;

&lt;li&gt;I want to check if there are any significant differences in SQL Server 2012 Express Edition, compared to SQL Server 2008R2 Express Edition.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It isn't uncommon that people want to have SQL Server Management Studio (SSMS) on their machines; and instead of searching for the install files for the full product, they download the freely available Express Edition and install SSMS from there. This was the main reason for this update post, and the reason I focus on SSMS and the tools&amp;nbsp;in this post.&lt;/p&gt;

&lt;p&gt;It turns out that both 2008R2 and 2012 RTM Express editions of SSMS includes a lot, but not quite everyting that the full version of SSMS has. And they don't have Profiler or Database Engine Tuning Advisor. 2012 SP1 Express download does indeed have the Complete tool package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic and Complete&lt;/strong&gt;&lt;br&gt;The full SSMS (etc.) is referred to as "Management Tools - Complete". This is only available with the Product you pay for and with 2012 SP1 Express. The only one available with the various free Express downloads (prior to 2012 SP1), is called "Management Tools - Basic". You can explicitly request to install Basic from an install media that includes Complete, but you have to explicitly request that in the setup program. You don't want to do that. &lt;/p&gt;

&lt;p&gt;One difference between 2008R2 and 2012 is when you install from a pay-media and select that you want to install Express. For 2008R2, you then only have SSMS Basic available. For 2012, you have Complete. In other words, if you use a 2012 pay-media and select Express to install SSMS, you have the option to have the full-blown SSMS - Complete&amp;nbsp;(including other tools, like Profiler).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The downloads&lt;/strong&gt;&lt;br&gt;For SQL Server 2008R2, you have "Express Edition" and "Express Edition with Advanced Services". The former is basically only the database engine, where the later has some Tools (SSMS Basic, primarily). See my earlier blog post for more details about 2008R2. &lt;/p&gt;

&lt;p&gt;For 2012, there are bunch of downloads available. Note that if you want Complete tools, you need to download SP1&amp;nbsp;of the installers. You find SP1 &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=35579"&gt;here&lt;/a&gt; (and RTM, which you don't want to use,&amp;nbsp;&lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=29062"&gt;here&lt;/a&gt;). SP1 includes Complete tools, and you will see that those downloads are significantly larger compared to RTM. It isn't obvious what each exe files stand for, but scroll down and you will find pretty good explanations. I tried several of these (SSMS only, Express with Tools, Express with Advanced Services). They all have in common that for &lt;strong&gt;RTM&lt;/strong&gt; the tool included is &lt;strong&gt;Basic&lt;/strong&gt;, where for &lt;strong&gt;SP1&lt;/strong&gt; we have &lt;strong&gt;Complete&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So what is the difference between Basic and Complete?&lt;/p&gt;

&lt;p&gt;In the table below, my focus was on what&lt;strong&gt; isn't&lt;/strong&gt; in Basic. In general, I don't bother to list functionality which is available in both Basic and Complete. So, if the functionality isn't in the table below, it is likely available in Basic. I might have missed something, of course! And my main focus was on SSMS and the database engine.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;table id="Table1" cellspacing="1" cellpadding="1"&gt;
  
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Component/Functionality&lt;/b&gt;&lt;/td&gt;

&lt;td&gt;&lt;b&gt;2008R2&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;2012 RTM&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;b&gt;2012 SP1&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Functionality in SSMS&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Node for Agent&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Graphical Execution Plans&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Projects and Solutions&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Maint Plans, Wizard&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Maint Plans, New, designer&lt;/td&gt;
&lt;td&gt;N (1)&lt;/td&gt;
&lt;td&gt;N (2)&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Maint Plans, Modify&lt;/td&gt;
&lt;td&gt;N (1)&lt;/td&gt;
&lt;td&gt;N (2)&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Node for SSIS Catalog&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Tools menu, Profiler&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Tools menu, Tuning Advisor&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Connect Object Explorer to:&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
 
&lt;tr&gt;
&lt;td&gt;Analysis Services&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Reporting Services&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Integration Services&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Tools&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Profiler&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
  
&lt;tr&gt;
&lt;td&gt;Database Engine Tuning Advisor&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;(1): The selections are there, but they were dead - nothing happened when you select them.&lt;br&gt;(2): The selections are there, but I got an error message when selecting any of them.&lt;/p&gt;</description></item><item><title>Backup and the evil RETAINDAYS option</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2012/07/08/backup-and-the-evil-retaindays-option.aspx</link><pubDate>Sun, 08 Jul 2012 12:25:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44226</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;p&gt;"So what bad has this option done?", you probably as yourself. Well, not much, but I find it evil because it confuses people, especially those new to SQL Server. I have many times seen people specifying something like 3, and expect SQL Server to keep the three most recent backups in the backup file and overwrite everything which is older than that. Well, that is &lt;strong&gt;not&lt;/strong&gt; what the option does. &lt;/p&gt;
&lt;p&gt;But before we go into details, let's look at an example backup command which is using this option:&lt;/p&gt;&lt;p&gt;

&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;BACKUP DATABASE &lt;/span&gt;&lt;span style="color:black;"&gt;sqlmaint &lt;/span&gt;&lt;span style="color:blue;"&gt;TO DISK = &lt;/span&gt;&lt;span style="color:red;"&gt;'R:\sqlmaint.bak' &lt;/span&gt;&lt;span style="color:blue;"&gt;WITH &lt;/span&gt;&lt;span style="color:black;"&gt;RETAINDAYS &lt;/span&gt;&lt;span style="color:blue;"&gt;= &lt;/span&gt;&lt;span style="color:black;"&gt;3&lt;/span&gt;&lt;/code&gt;
&lt;/p&gt;&lt;p&gt;The RETAINDAYS is also exposed in the backup dialog in SSMS: "&lt;em&gt;Backup set will expire: After x days&lt;/em&gt;".&lt;/p&gt;&lt;p&gt;It is also exposed in Maintenance Plans, the backup task. The option is named "&lt;em&gt;Backup set will expire: After x days&lt;/em&gt;". It is only enabled if you select the "&lt;em&gt;Back up databases across one or more files&lt;/em&gt;" option, which is not the default option. This makes sense.&lt;br&gt;The default option is "&lt;em&gt;Create a backup files for every database&lt;/em&gt;", which means that every time a backup is performed, a new file is created consisting of&amp;nbsp;the database name, date and time. Since we will see that this option is only relevant when we do append, it makes sense in the RETAINDAYS not being enabled for this choice.&lt;/p&gt;&lt;p&gt;So what does this option do? All it does is make SQL Server&amp;nbsp;return an error message of you try to do a backup using the INIT option (which means overwrite) before the date and time has occurred. In other words, it tries to help you in not overwriting a backup file, using the INIT option, before it is time. You can still overwrite&amp;nbsp;earlier by either using the stronger FORMAT option instead of INIT; or by simply deleting the backup file. Btw, the RETAINDAYS parameter has a cousin named EXPIREDATE, which does the same thing but you specify a datetime value instead of number of days.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Backup generations&lt;br&gt;&lt;/strong&gt;So, we have seen that RETAINDAYS do not in any way provide any automatic backup generation handling. There is no such functionality built-in in the BACKUP command. This means that when you are looking for functionality such as "keep backup files three days, and remove older than that", you need to look outside the BACKUP command. I.e., some script or tool of some sort. &lt;/p&gt;&lt;p&gt;I have an example (without the "delete old files" part) &lt;a href="http://www.karaszi.com/SQLServer/util_backup_script_like_MP.asp"&gt;here&lt;/a&gt;, which I mostly created as a starting point for those who want to roll their own and want to have some example to start with. Many of you are probably using Maintenance plans (the "Create a backup files for every database" option in the backup task, along with Maintenance Cleanup task). Another popular script/tool for this is Ola Hallengren's Maintenance Solution, which you find at &lt;a href="http://ola.hallengren.com/"&gt;http://ola.hallengren.com/&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Analyzing the errorlog</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2012/07/05/analyzing-the-errorlog.aspx</link><pubDate>Thu, 05 Jul 2012 11:53:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44203</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;p&gt;How often do you do this? Look over each message (type) in the errorlog file and determine whether this is something you want to act on. Sure, some (but not all) of you have some monitoring solution in place, but are you 100% confident that it really will notify for all messages that you might find interesting? That there isn't even one little message hiding in there that you would find valuable knowing about? Or how about messages that you typically don't are about, but knowing that you have a high frequency can be valuable information?&lt;/p&gt;&lt;p&gt;So, this boils down to actually reading the errorlog file. Some of you probably already have scripts and tool that makes this easier than just reading every simple message from top to bottom. I wanted to share how I do it, and this is why I wrote my&amp;nbsp;&lt;a href="http://www.karaszi.com/SQLServer/util_analyze_sql_server_logs.asp"&gt;Analyze SQL Server&amp;nbsp;logs&lt;/a&gt; article.&amp;nbsp;Check it out. And, feedback is always welcome!&lt;/p&gt;</description></item><item><title>Two bugs you should be aware of</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2012/03/21/two-bugs-you-should-be-aware-of.aspx</link><pubDate>Wed, 21 Mar 2012 16:43:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:42431</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;In the past 24 hours I have come across two bugs that can be quite problematic in certain environments.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;font size="4"&gt;LPIM issue with SetFileIoOverlappedRange&lt;/font&gt;
&lt;/p&gt;

&lt;p&gt;Last night the CSS team &lt;a href="http://blogs.msdn.com/b/psssql/archive/2012/03/20/setfileiooverlappedrange-can-lead-to-unexpected-behavior-for-sql-server-2008-r2-or-sql-server-2012-denali.aspx" title="http://blogs.msdn.com/b/psssql/archive/2012/03/20/setfileiooverlappedrange-can-lead-to-unexpected-behavior-for-sql-server-2008-r2-or-sql-server-2012-denali.aspx" target="_blank"&gt;posted a blog entry&lt;/a&gt; detailing a potential issue with Lock Pages in Memory and Windows' SetFileIoOverlappedRange API. I tweeted about it at the time, but thought it could use a little more treatment. The potential symptoms can vary, but include the following (as quoted from the blog post):&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#ffffdd" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div style="padding:10px 20px;background:none repeat scroll 0% 0% transparent;font-size:13px;font-family:georgia,times new roman,times;-moz-background-inline-policy:continuous;"&gt;&lt;i&gt;Wide ranging in SQL from invalid write location, lost read or write, early access to a page that is not yet fully in memory, I/O list damage such as AVs, incorrect timing reports, and many others. You may not even see the situation until days later.&lt;/i&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;The fix for this will be issued through Windows Update and through SQL Server 2008 R2 Service Pack 2 (not yet released). In the meantime, which will hopefully be short, I recommend you disable Lock Pages in Memory to avoid these potential problems, if you are using SQL Server 2008 R2 or SQL Server 2012 *unless* you are already running on Windows 8.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;font size="4"&gt;SQL Server Agent Log bloat&lt;/font&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;In the SQL Server 2012 RTM release, there seems to have been some debug code left in that is filling the Agent log with useless status messages. In my case this is happening every 135 seconds or so, though the &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/729700/" title="http://connect.microsoft.com/SQLServer/feedback/details/729700/" target="_blank"&gt;Connect item&lt;/a&gt; indicates it is every 90 seconds:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;img src="http://bertrandaaron.files.wordpress.com/2012/03/agentlog.png" height="366" border="1" width="593"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, this isn't a bad thing per se, but it is unnecessarily filling the log with these useless messages, and this can cause performance issues when you are trying to read the log through various methods (e.g. &lt;a href="http://www.mssqltips.com/sqlservertip/1476/reading-the-sql-server-log-files-using-tsql/" title="http://www.mssqltips.com/sqlservertip/1476/reading-the-sql-server-log-files-using-tsql/" target="_blank"&gt;xp_readerrorlog&lt;/a&gt;). Note that while you can suppress "Information" messages from the SQL Server Agent Log (right-click SQL Server Agent &amp;gt; Error Logs, choose "Configure", and uncheck "Information"), you should find that this is already unchecked by default, and that this specific information message is ignored by this setting.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;If you're using &lt;a href="http://www.sqlsentry.net/event-manager/sql-server-enterprise.asp" title="http://www.sqlsentry.net/event-manager/sql-server-enterprise.asp" target="_blank"&gt;SQL Sentry Event Manager&lt;/a&gt;, you can automatically cycle the agent log when it hits 1 MB, by changing the SQL Server Connection setting "Auto-recycle large SQL Server Agent Logs" to true:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;img src="http://bertrandaaron.files.wordpress.com/2012/03/cyclelog.png" height="253" border="1" width="430"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However you will still see all of the events on your calendar, as we're currently not filtering these messages out. &lt;/p&gt;

&lt;p&gt;If you're not using Event Manager, you might want to consider scheduling a job nightly or weekly that cycles the error log for you, since it will otherwise grow uninhibited as it fills up with these status messages. You can do this by simply calling the following stored procedure (which is exactly what we do behind the scenes when the log file hits the threshold):&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;EXEC msdb.dbo.sp_cycle_agent_errorlog;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;This won't suppress the error messages from the log, but it will at least roll your log over so it doesn't grow unchecked. The workaround listed in the Connect item is to disable the Auto Registry Refresh feature. Using regedit.exe, go to the following key:&lt;br&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.INSTANCE_NAME\SQLServerAgent&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

And change the value for “AutoRegistryRefresh” from 1 to 0.&lt;br&gt;&lt;br&gt;Note the disclaimer though: If you change any SQL Server Agent settings, you may need to restart the Agent to see them.&lt;br&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Send email after Agent job execution</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2011/12/28/send-email-after-agent-job-execution.aspx</link><pubDate>Wed, 28 Dec 2011 11:15:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:40667</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;p&gt;After executing a job, I want to have an email with the following information:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Success or failure in the mail subject (not just in the body)&lt;/li&gt;&lt;li&gt;Success or failure and execution time for each job step in mail body&lt;/li&gt;&lt;li&gt;Have output file(s) for the job steps attached to email&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Agent has none of above built-in so I created my own procedure for this. This is meant to be added as a final job step for your jobs. You find all details and the procedure here: &lt;a href="http://www.karaszi.com/SQLServer/util_MailAfterJob.asp"&gt;http://www.karaszi.com/SQLServer/util_MailAfterJob.asp&lt;/a&gt;. Feedback is of course very welcome.&lt;/p&gt;</description></item><item><title>Who owns your jobs?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2011/10/06/who-owns-your-jobs.aspx</link><pubDate>Thu, 06 Oct 2011 16:13:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38900</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;p&gt;Yep, another Agent blog. The topic of job owner has been discussed here before, but this is a specific situation, which potentially is a ticking bomb. First a quick recap of how agent does things:&lt;/p&gt;&lt;p&gt;When a job is owned by somebody who is sysadmin, then no impersonation is performed. &lt;/p&gt;&lt;ul&gt;&lt;li&gt;T-SQL jobsteps will be executed as Agent's own Windows authenticated login.&lt;/li&gt;&lt;li&gt;Other jobsteps (which operates as the OS level) is done in Agent's service account's context.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Above is, assuming you didn't ask for impersonation for the jobstep (Run As). &lt;/p&gt;&lt;p&gt;Last week, at a SQL Server admin class, Andreas Jarbéus from Swedish Match asked about job owned by Windows account and what happens when that person leaves the company. I was about to say "no problem, if the job owner is sysadmin", but I felt there was a bit more to it. The scenario is:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The job owner is member of a Windows/AD group. Say you have a "SQL Server DBA" group in your AD.&lt;/li&gt;&lt;li&gt;This group is added as a login to your SQL Servers. The persons in that group do not have individual logins in SQL Server - only through this group. &lt;/li&gt;&lt;li&gt;This group is sysadmin. (I'm not saying that having jobs in general owned by sysadmins is a best practice. You can for instance have vendors installing some software and you &lt;strong&gt;don't&lt;/strong&gt; want to make them sysadmin. In such a case, clearly we don't want the job to keep running if that person would disappear. So, I'm targeting jobs owned by sysadmin here, and I would bet you have bunch of those.)&lt;/li&gt;&lt;li&gt;Somebody in this group creates an Agent job.&lt;/li&gt;&lt;li&gt;The person in the group leaves the company and is removed from this Windows/AD group.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Above is a pretty common scenario. The thing now is that &lt;strong&gt;the job no longer works&lt;/strong&gt;. And here's the reason:&lt;/p&gt;&lt;p&gt;If the owner was somebody in Windows/AD who's SID exists in SQL Server (the &lt;strong&gt;individual&lt;/strong&gt; was added as a login to SQL Server), then the job will still work. This also applies for SQL Logins which might be disabled (like "sa" for instance). The reason for this is that the SID for the job owner exists in sys.server_principals and SQL Server will know that this SID is sysadmin. Since Agent won't do impersonation for sysadmins, there's no need to "go out to Windows" and see if this SID exists in Windows/AD. Remove the login, and the job will stop working, though - but you have at least don't something explicitly inside your SQL Server to cause this (removed the login).&lt;/p&gt;&lt;p&gt;But when the owner's SID don't exist in sysadmin we have a problem. The problem is that the recorded owner of the job is the SID for the Windows user, even though that SID&amp;nbsp;doesn’t exist in sys.server_principals. As long as this still exists in Windows/AD, the job will work just fine. Agent will run this job owned by ?, ask Windows who this SID is and see that this SID is a member of a group which exists as a login in SQL Server and that is sysadmin. Now, imagine what happen if the SID doesn't exist in Windows anymore. The job is owned by ?, and that is all that SQL Server knows. The SID no longer exist in Windows/AD so you there's nobody to tell SQL Server "Yeah, this used to be a sysadmin in SQL Server - through a group membership in Windows/AD". &lt;/p&gt;&lt;p&gt;Even worse, the job seems to keep working until you re-start the SQL Server service, some caching going on. Makes it even more difficult to determine why the job suddenly stops working: "We deleted this Windows account 4.5 months ago." This is easy to repro, and you don't even need a domain (local Windows accounts and groups work just fine):&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Create a Windows group for this.&lt;/li&gt;&lt;li&gt;Create a Windows account for this.&lt;/li&gt;&lt;li&gt;Add the Windows account to above group.&lt;/li&gt;&lt;li&gt;Add above &lt;strong&gt;group&lt;/strong&gt; as a login to SQL Server.&lt;/li&gt;&lt;li&gt;Make this group sysadmin.&lt;/li&gt;&lt;li&gt;Create a job, with two jobsteps:&lt;/li&gt;&lt;li&gt;T-SQL which executes: PRINT ORIGINAL_LOGIN() + ' | ' + SUSER_SNAME() + ' | ' + USER_NAME()&lt;/li&gt;&lt;li&gt;CmdExec which executes: WHOAMI.EXE&lt;/li&gt;&lt;li&gt;(Above isn't really necessary, but useful for testing other impersonation aspects of Agent)&lt;/li&gt;&lt;li&gt;Specify the Windows account as owner of the job.&lt;/li&gt;&lt;li&gt;Run the job, make sure it works fine.&lt;/li&gt;&lt;li&gt;Remove the Windows account from the Windows group.&lt;/li&gt;&lt;li&gt;Run the job and see it fails.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I'm sure this has been blogged before, but I was a bit surprised by it. I have now added a check for this in my "Check best practices" stored procedure I run every day... On the flip side, this doesn't seem to happen for multi-server (MSX) jobs, the ownership seems to have special handling for these&amp;nbsp;- you will see if you check the owner_sid in sysjobs.&lt;/p&gt;</description></item><item><title>Agent Alerts Management Pack updated</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2011/09/15/agent-alerts-management-pack-updated.aspx</link><pubDate>Thu, 15 Sep 2011 19:13:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38484</guid><dc:creator>TiborKaraszi</dc:creator><description>I have updated the Agent Alerts Management Pack, cleaned up the T-SQL code which creates the alerts. You can now just copy, paste and execute that code. Earlier, for some of the some of the alert definitions it just generated the calls to the query result window, and you had to copy this to a query window and execute it. Now you just copy the code and execute it. You find it here:&amp;nbsp;&lt;a title="http://www.karaszi.com/SQLServer/util_agent_alerts.asp" href="http://www.karaszi.com/SQLServer/util_agent_alerts.asp"&gt;http://www.karaszi.com/SQLServer/util_agent_alerts.asp&lt;/a&gt;.</description></item><item><title>Ola Hallengren's maint procedures now supports logging to table</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2011/07/15/ola-hallengren-s-maint-procedures-now-supports-logging-to-table.aspx</link><pubDate>Sat, 16 Jul 2011 01:19:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36985</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;p&gt;This can for instance be very useful if you want to keep track how long time things take, over time.&lt;/p&gt;&lt;p&gt;Check them out &lt;a title="http://ola.hallengren.com/" href="http://ola.hallengren.com/"&gt;here&lt;/a&gt;.Version history &lt;a title="http://ola.hallengren.com/Versions.html" href="http://ola.hallengren.com/Versions.html"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Article released about moving databases</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2011/07/10/article-released-about-moving-databases.aspx</link><pubDate>Sun, 10 Jul 2011 13:26:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36757</guid><dc:creator>TiborKaraszi</dc:creator><description>Just a short notice that I've released an article about moving databases between SQL Server instances: You find it at &lt;a href="http://www.karaszi.com/SQLServer/info_moving_database.asp"&gt;http://www.karaszi.com/SQLServer/info_moving_database.asp&lt;/a&gt;&lt;a title="http://www.karaszi.com/SQLServer/info_moving_database.asp" href="http://www.karaszi.com/SQLServer/info_moving_database.asp"&gt;&lt;/a&gt;.</description></item><item><title>Connect Digest : 2011-03-26</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2011/03/26/connect-digest-2011-03-26.aspx</link><pubDate>Sat, 26 Mar 2011 12:50:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34344</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;This week I have collected five important bugs involving Management Studio, and I hope you'll visit them, provide input and vote on the ones you think are worthwhile.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/651176" title="http://connect.microsoft.com/SQLServer/feedback/details/651176" target="_blank"&gt;#651176 : SSMS tries to access disconnected network drives when in the Save File As wizard&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Paul Randal (&lt;a href="http://sqlskills.com/blogs/paul/" title="http://sqlskills.com/blog/paul/" target="_blank"&gt;blog&lt;/a&gt; | &lt;a href="http://twitter.com/PaulRandal" title="http://twitter.com/PaulRandal" target="_blank"&gt;twitter&lt;/a&gt;) filed this issue when he experienced significant delays trying to save files from SSMS. The issue: SSMS is spinning its wheels trying to access drives that are currently disconnected. I have seen this issue before, but did not put two and two together at the time. Surely it would be easy enough for Management Studio to poll the properties of all of the drives known to Windows, and only pay any attention to the drives that are online and accessible.&lt;br&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/557402%20" title="http://connect.microsoft.com/SQLServer/feedback/details/557402 " target="_blank"&gt;&lt;br&gt;#557402 : SSMS : Can no longer create or edit job steps&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This is one of mine that I filed last May - when editing a job step, you may find that the dialog raises a very non-user-friendly error about some IClassFactory, and the only workaround so far (other than modifying all of your jobs with T-SQL) is to close Management Studio and start over. Microsoft originally claimed this was fixed two cumulative updates ago, but many people have confirmed that even the most recent CU for SQL Server 2008 R2 does not resolve the issue. This time for sure?&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/349116" title="http://connect.microsoft.com/SQLServer/feedback/details/349116" target="_blank"&gt;&lt;br&gt;#349116 : keyboard shortcut Alt+F1 (sp_help) doesn't work for tables belonging to non-default schemas&lt;/a&gt;&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Michael Swart (&lt;a href="http://michaeljswart.com/" title="http://michaeljswart.com/" target="_blank"&gt;blog&lt;/a&gt; | &lt;a href="http://twitter.com/mjswart" title="http://twitter.com/mjswart" target="_blank"&gt;twitter&lt;/a&gt;) raised this issue in 2008, and it remains in limbo. Personally I think it stands to reason that, as the use of schemas becomes more commonplace, the tools should support them better. In this case, I am not sure that Alt+F1 should be connected directly to sp_help, since Microsoft has already committed to not extending the sp_ procedures for new functionality. But give us an easy way to map F1 or Alt+F1 to some kind of query that *will* give us information about the object in question.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/614130" title="http://connect.microsoft.com/SQLServer/feedback/details/614130" target="_blank"&gt;&lt;br&gt;#614130 : IntelliSense doesn't work with CAST&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Simon Sabin (&lt;a href="http://sqlblogcasts.com/blogs/simons/default.aspx" title="http://sqlblogcasts.com/blogs/simons/default.aspx" target="_blank"&gt;blog&lt;/a&gt; | &lt;a href="http://twitter.com/simon_sabin" title="http://twitter.com/simon_sabin" target="_blank"&gt;twitter&lt;/a&gt;) filed this complaint last year, and I wholeheartedly agree. IntelliSense is a mere annoyance in general, and I usually shut it off after any tangible amount of coding; but when it starts pulling this nonsense, I'm ready to throw it out the window entirely. Simon's complaint here is specifically with CAST - when you type "CAST(col AS " it auto-completes with the weirdest stuff you could imagine, and doesn't even offer you valid data types. Now, I'm not going to sugar-coat this: there are a LOT of things to fix with IntelliSense, but I can only pimp so many - and we can only expect so many to be fixed in any reasonable development cycle. Maybe I'll dedicate a future digest to IntelliSense? In the meantime, you may be better off with &lt;a href="http://www.red-gate.com/products/sql-development/sql-prompt/" title="http://www.red-gate.com/products/sql-development/sql-prompt/" target="_blank"&gt;RedGate's SQLPrompt&lt;/a&gt; or the free &lt;a href="http://www.devart.com/dbforge/sql/sqlcomplete/" title="http://www.devart.com/dbforge/sql/sqlcomplete/" target="_blank"&gt;dbForge SQL Complete Express&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/124842" title="http://connect.microsoft.com/SQLServer/feedback/details/124842" target="_blank"&gt;&lt;br&gt;#124842 : 'Remember Password' option is not remembered in Registered Server Properties&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;David Kean filed this back in 2005, and it's a bug I'm sure we've all experienced. Yes, you can overcome it temporarily with a workaround (delete the SqlStudio.bin file), but this is tedious and may affect other settings as well. Also, this workaround will no longer be valid in the Denali timeframe, since Management Studio is now actually just an extension of the official Visual Studio shell. I filed a related bug, &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/339592/" title="http://connect.microsoft.com/SQLServer/feedback/details/339592/" target="_blank"&gt;#339592&lt;/a&gt;, and Joseph Leathlean filed one about duplicate entries in the connection dialog, &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/339592/" title="http://connect.microsoft.com/SQLServer/feedback/details/339592/" target="_blank"&gt;#373794&lt;/a&gt;. Both are still active; the latter is still very much an issue in Denali:&lt;/p&gt;&lt;p&gt;&lt;img src="http://sqlblog.com/files/folders/34424/download.aspx" border="0" height="596" width="544"&gt;&lt;br&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;br&gt;&lt;/p&gt;</description></item></channel></rss>