<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>&lt;CF-A-LOT /&gt; - SQL Server</title>
			<link>http://www.danlance.co.uk/index.cfm</link>
			<description>Dan Lancelot&apos;s CF-Blog</description>
			<language>en-gb</language>
			<pubDate>Tue, 07 Sep 2010 01:40:34 --0100</pubDate>
			<lastBuildDate>Wed, 30 Dec 2009 23:53:31 --0100</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>danlance@gmail.com</managingEditor>
			<webMaster>danlance@gmail.com</webMaster>
			
			
			
			
			
			<item>
				<title>SQL Server 2005 Maintenance Plans not sending email alerts?</title>
				<link>http://www.danlance.co.uk/index.cfm/2009/12/30/SQL-Server-2005-Maintenance-Plans-not-sending-email-alerts</link>
				<description>
				
				&lt;p&gt;SQL Server 2005 does make it much easier to set up email alerts than it&apos;s predecessors, however its still very easy to set it up in such a way that emails generated by SQL Agent are not sent, despite test emails being sent without any difficulty.&lt;/p&gt; &lt;p&gt;If your SQL Agent jobs are not sending out emails, and you have set up mail accounts and profiles, together with specifying at least one operator with an email address, and you are getting the following errors in your error logs:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;[260] Unable to start mail session (reason: No mail profile defined)&lt;/p&gt; &lt;p&gt;[264] An attempt was made to send an email when no email session has been established&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;You need to do the following:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Right click on SQL Server Agent within Management Studio  &lt;li&gt;Select &lt;strong&gt;Properties&lt;/strong&gt;  &lt;li&gt;Select &lt;strong&gt;Alert System&lt;/strong&gt;  &lt;li&gt;Tick the &lt;strong&gt;Enable mail profile&lt;/strong&gt; checkbox  &lt;li&gt;Select &lt;strong&gt;Database Mail&lt;/strong&gt; from the &lt;strong&gt;Mail System:&lt;/strong&gt; select box  &lt;li&gt;Select the Mail Profile you wish to use for SQL Agent emails&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I believe you then need to restart SQL Server Agent - and providing your profile is set up correctly (and firewall rules permitting) SQL Agent jobs should now send out emails correctly :)&lt;/p&gt; &lt;p&gt;After doing this, it&apos;s probably worth checking that emails are working correctly - to do this I set up a simple SQL Agent job containing a single step with a simple select statement, and configured the job to send me an email on completion.&amp;nbsp; I then ran the task manually, and checked to see the email was received successfully.&lt;/p&gt;
				
				</description>
						
				
				<category>SQL Server</category>				
				
				<pubDate>Wed, 30 Dec 2009 23:53:31 --0100</pubDate>
				<guid>http://www.danlance.co.uk/index.cfm/2009/12/30/SQL-Server-2005-Maintenance-Plans-not-sending-email-alerts</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>SQL Server Maintenance Plan &amp;ndash; Rebuild Index Task Gotcha on SQL Server 2005 Standard</title>
				<link>http://www.danlance.co.uk/index.cfm/2009/12/30/SQL-Server-Maintenance-Plan-ndash-Rebuild-Index-Task-Gotcha-on-SQL-Server-2005-Standard</link>
				<description>
				
				&lt;p&gt;Here&apos;s one to watch out for if you are setting up a SQL Server 2005 Maintenance Plan on SQL Server 2005 Standard edition&lt;/p&gt; &lt;p&gt;SQL Server 2005 supports online rebuilding of indexes on &lt;strong&gt;Enterprise Edition Only&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The Task wizard for setting up the &lt;em&gt;Rebuild Index Task&lt;/em&gt; has an option &lt;em&gt;Keep index online while reindexing &lt;/em&gt;&lt;strong&gt;even when connected to Standard Edition.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;No warnings are given when setting up a task with this option enabled, but when the maintenance plan executes, the error &lt;strong&gt;Online index operations can only be performed in Enterprise edition of SQL Server&lt;/strong&gt; will be generated for each index - and indexes will &lt;strong&gt;not&lt;/strong&gt; be recreated.&lt;/p&gt; &lt;p&gt;As a side note, make sure you do have the &lt;strong&gt;Generate a text file report&lt;/strong&gt; option ticked within &lt;strong&gt;Reporting and Logging&lt;/strong&gt;&amp;nbsp; settings for the job, as the information given within the SQL job History Log is limited to &lt;strong&gt;The job failed&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;As a side side note, its definitely worth checking that your SQL Agent email alerts are functioning correctly if you have them set to notify on failure, as otherwise an issue like this can go completely un-noticed (apart from performance issues), as the rest of the tasks within the plan will probably succeed (like backups being generated) - which is certainly the main thing I have always checked after setting up a maintenance plan...&lt;/p&gt;
				
				</description>
						
				
				<category>SQL Server</category>				
				
				<pubDate>Wed, 30 Dec 2009 23:31:00 --0100</pubDate>
				<guid>http://www.danlance.co.uk/index.cfm/2009/12/30/SQL-Server-Maintenance-Plan-ndash-Rebuild-Index-Task-Gotcha-on-SQL-Server-2005-Standard</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>I Love (SQL) views</title>
				<link>http://www.danlance.co.uk/index.cfm/2007/11/22/I-Love-SQL-views</link>
				<description>
				
				I&apos;ve always been a fan of Views within SQL Server - I&apos;ve found them especially useful when creating applications which need to be able to access data from external sources, without necessarily being aware of where that data came from - or even of its precise format.

One feature which I have found especially useful, is the ability to select and join to data from within a different database, from within a view.

This can be done as follows:
				 [More]
				</description>
						
				
				<category>SQL Server</category>				
				
				<category>Database</category>				
				
				<pubDate>Thu, 22 Nov 2007 22:57:00 --0100</pubDate>
				<guid>http://www.danlance.co.uk/index.cfm/2007/11/22/I-Love-SQL-views</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Love the View!</title>
				<link>http://www.danlance.co.uk/index.cfm/2007/3/22/Love-the-view</link>
				<description>
				
				I&apos;ve always been a fan of Views within SQL Server - I&apos;ve found them especially useful when creating applications which need to be able to access data from external sources, without necessarily being aware of where that data came from - or even of its precise format.

 
One feature which I have found especially useful, is the ability to select and join to data from within a different database, from within a view.
 

This can be done as follows:
 
&lt;code&gt;
Create View MyView1
AS
Select L.ID as Local_ID, L.Name as Local_Name, L.Related_ID as Remote_ID,
R.Name as Remote_Name, R.Description as Remote_Description
From dbo.tbl_local L
Inner Join  RemoteDB.dbo.tbl_remote R on L.Related_ID = R.ID
&lt;/code&gt;
&lt;i&gt;Please note: table / field names are for illustration only - and not indicative of Best Practice or requirement&lt;/i&gt;

 
So specifying an explicit database name in front of the schema name causes the data to be retrieved from the named DB, on the same server, rather than from the db in which the view is placed.  I believe it is also possible to specify a database which is on a different server, using Linked Servers - but I&apos;ve never had a requirement to check this out so far.
 

What&apos;s great about this, is that if I reference this view rather than the tables directly within my application / stored procedures, I can change where the data is coming from without impact on the application.  This has been particularly useful in the past when a system is reliant upon external data, but needs to be developed in isolation.  I can create a table in my local DB which mirrors the structure of the remote data source, and point my view at that - and then when the application is ready for integration, I can update the view to point to the remote DB.
				 [More]
				</description>
						
				
				<category>SQL Server</category>				
				
				<category>Database</category>				
				
				<pubDate>Thu, 22 Mar 2007 00:38:00 --0100</pubDate>
				<guid>http://www.danlance.co.uk/index.cfm/2007/3/22/Love-the-view</guid>
				
			</item>
			
		 	
			</channel></rss>