<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SQL Server</title>
        <link>http://blog.colinmackay.net/category/14.aspx</link>
        <description>SQL Server</description>
        <language>en-GB</language>
        <copyright>Colin Angus Mackay</copyright>
        <managingEditor>colin.mackay@gmail.com</managingEditor>
        <generator>Subtext Version 1.9.0.27</generator>
        <item>
            <title>SQL Injection Attack Talk in Nuneaton</title>
            <link>http://blog.colinmackay.net/archive/2009/12/02/SQL-Injection-Attack-Talk-in-Nuneaton.aspx</link>
            <description>&lt;p&gt;I’ll be speaking to VBUG in Nuneaton on the 12th January 2010 on the subject of SQL Injection Attacks and Tips on How to Prevent Them.&lt;/p&gt;  &lt;p&gt;&lt;a title="SQL Injection Attacks and Tips on How To Prevent Them" href="http://www.vbug.co.uk/Events/January-2010/SQL-injection-attacks-and-tips-on-how-to-prevent-them--with-Colin-Mackay.aspx"&gt;More details on this event&lt;/a&gt; can be found on the &lt;a href="http://www.vbug.co.uk"&gt;VBUG website&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/10136.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/12/02/SQL-Injection-Attack-Talk-in-Nuneaton.aspx</guid>
            <pubDate>Wed, 02 Dec 2009 10:18:47 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/10136.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/12/02/SQL-Injection-Attack-Talk-in-Nuneaton.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/10136.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Visual Studio / SQL Server install order on Windows 7</title>
            <link>http://blog.colinmackay.net/archive/2009/10/11/Visual-Studio--SQL-Server-install-order-on-Windows-7.aspx</link>
            <description>&lt;p&gt;Quite a while ago I blogged about the &lt;a href="http://blog.colinmackay.net/archive/2008/08/03/3206.aspx"&gt;Visual Studio / SQL Server install order on Windows Vista&lt;/a&gt;. I’m about to go through a similar exercise on Windows 7 and given the issues I had then I thought that it would be only right to document the procedure in case any problems arose.&lt;/p&gt;  &lt;p&gt;Last time, it would seem, the best solution was to install things in the order in which Microsoft released them with the notable exception of the operating system. So this time, that is the strategy that I’m going to take. Windows 7 is already installed on my laptop. Then I’m going to install Visual Studio 2008, then SQL Server 2008, then any patches for either and we’ll see how we get on. &lt;/p&gt;  &lt;p&gt;I’m also going to ensure that I do NOT install SQL Server Express Edition on Visual Studio 2008 as I’ve had problems with that before. Essentially, the problem last time was that the SQL Server installer mistook Visual Studio’s SQL Server Express installation has having installed certain things. The SQL Server installation therefore didn’t want to repeat what it didn’t need to so it refused to install the client tools.&lt;/p&gt;  &lt;h2&gt;Install Order&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;Visual Studio 2008, excluding SQL Server 2005 Express Edition &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a title="vs2008-installer-no-sql-express by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3998065131/"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" border="0" alt="vs2008-installer-no-sql-express" src="http://farm3.static.flickr.com/2562/3998065131_db70ee5207_o.png" width="766" height="587" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;MSDN Library (This is optional – I installed it because I’m occasionally developing on the road with no or limited connectivity) &lt;/li&gt;    &lt;li&gt;Visual Studio 2008 Service Pack 1 (this is required in order to install SQL Server 2008 – the installation will fail otherwise) &lt;/li&gt;    &lt;li&gt;SQL Server 2008 Developer Edition &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt; &lt;a title="sql-server-2008-compatibility-issues by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3999036490/"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" border="0" alt="sql-server-2008-compatibility-issues" src="http://farm4.static.flickr.com/3496/3999036490_171190fea1_o.png" width="602" height="298" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Install SQL Server 2008 SP1&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;That’s it – Job done. And it only took me two attempts to get it right this time. My stumbling block here was the order in which I applied the service packs.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e433c6e1-2626-40ef-82da-07c2b90bb701" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/sql+server" rel="tag"&gt;sql server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql+server+2008" rel="tag"&gt;sql server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/visual+studio" rel="tag"&gt;visual studio&lt;/a&gt;,&lt;a href="http://technorati.com/tags/visual+studio+2008" rel="tag"&gt;visual studio 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/installation" rel="tag"&gt;installation&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/9407.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/10/11/Visual-Studio--SQL-Server-install-order-on-Windows-7.aspx</guid>
            <pubDate>Sun, 11 Oct 2009 10:50:22 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/9407.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/10/11/Visual-Studio--SQL-Server-install-order-on-Windows-7.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/9407.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQL Injection Attacks and Tips on How to Prevent Them</title>
            <link>http://blog.colinmackay.net/archive/2009/09/24/SQL-Injection-Attacks-and-Tips-on-How-to-Prevent-Them.aspx</link>
            <description>&lt;p&gt;I’m giving a talk in Dundee on the topic of SQL Injection Attacks. If you are interested in the subject then the registration link is at the bottom of the page.&lt;/p&gt;  &lt;p align="center"&gt;&lt;strong&gt;Wednesday, 28th October 2009 at 19:00 – 21:00      &lt;br /&gt;Queen Margaret Building, Dundee University&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Talk&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In light of some recent events, such as the man who was convicted of &lt;a href="http://news.bbc.co.uk/1/hi/world/americas/8206305.stm"&gt;stealing 130 million credit card details through a SQL Injection attack&lt;/a&gt;, it is imperative that developers understand what a SQL Injection Attack is, how they are carried out, and most importantly, how to defend your code against attack.&lt;/p&gt;  &lt;p&gt;In this talk I’ll demonstrate a SQL Injection Attack on an application in a controlled environment*. I’ll show you where the vulnerable code lies and what you can do to harden it.&lt;/p&gt;  &lt;p&gt;Although this talk uses C# as the application language and Microsoft SQL Server 2008 as the database engine many of the concepts and prevention mechanisms will apply to any application that accesses a database through SQL.&lt;/p&gt;  &lt;p&gt;* Demonstrating an attack on a real system without the owner’s consent is a breach of the 1990 Misuse of Computers Act, hence the controlled environment.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Venue&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;We are meeting in the Queen Mother Building at Dundee University. After the meeting we normally retire to the the bar at Laing's&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Agenda&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;18:45 Doors Open    &lt;br /&gt;19:00 Welcome     &lt;br /&gt;19:10 The Talk (Part 1)     &lt;br /&gt;19:55 Break     &lt;br /&gt;20:05 The Talk (Part 2)     &lt;br /&gt;20:45 Feedback &amp;amp; Prizes     &lt;br /&gt;21:00 Repair to the Pub&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Registration&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Space is limited, we would therefore ask that you &lt;a title="SQL Injection Attacks and Tips on How To Prevent Them" href="http://www.eventbrite.com/event/443957890/colmac"&gt;sign up&lt;/a&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1042c58b-5acf-45b9-9e40-ab1d6d46edfe" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/sql" rel="tag"&gt;sql&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql+injection+attack" rel="tag"&gt;sql injection attack&lt;/a&gt;,&lt;a href="http://technorati.com/tags/security" rel="tag"&gt;security&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/9103.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/09/24/SQL-Injection-Attacks-and-Tips-on-How-to-Prevent-Them.aspx</guid>
            <pubDate>Thu, 24 Sep 2009 03:29:25 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/9103.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/09/24/SQL-Injection-Attacks-and-Tips-on-How-to-Prevent-Them.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/9103.aspx</wfw:commentRss>
        </item>
        <item>
            <title>If you really must do dynamic SQL&amp;hellip;</title>
            <link>http://blog.colinmackay.net/archive/2009/09/21/If-you-really-must-do-dynamic-SQLhellip.aspx</link>
            <description>&lt;p&gt;I may have mentioned in previous posts and articles about SQL Injection Attacks that dynamic SQL (building SQL commands by concatenating strings together) is a source of failure in the security of a data driven application. It becomes easy to inject malicious text in there to cause the system to return incorrect responses. Generally the solution is to use parameterised queries&lt;/p&gt;  &lt;p&gt;However, there are times where you may have no choice. For example, if you want to dynamically reference tables or columns. You can’t do that as the table name or column name cannot be replaced with a parameter. You then have to use dynamic SQL and inject these into a SQL command.&lt;/p&gt;  &lt;h2&gt;The problem&lt;/h2&gt;  &lt;p&gt;It is possible for SQL Server to do that concatenation for you. For example:&lt;/p&gt;  &lt;pre&gt;CREATE PROCEDURE GetData 
	@Id INT,
	@TableName sysname,
	@ColumnName sysname
AS
BEGIN
	SET NOCOUNT ON;
	
	DECLARE @sql nvarchar(max) = 
		'SELECT ' + @ColumnName + 
		' FROM ' + @TableName + 
		' WHERE Id = '+cast(@Id as nvarchar(20));	
	EXEC(@sql)
END
GO&lt;/pre&gt;

&lt;p&gt;This is a simple stored procedure that gets some data dynamically. However, even although everything is neatly parameterised it is no protection. All that has happened is that the location for vulnerability (i.e. the location of the construction of the SQL) has moved from the application into the database. The application is now parameterising everything, which is good. But there is more to consider than just that.&lt;/p&gt;

&lt;h2&gt;Validating the input&lt;/h2&gt;

&lt;p&gt;The next line of defence should be verifying that the table and column names passed are actually valid. In SQL Server you can query the &lt;strong&gt;INFORMATION_SCHEMA&lt;/strong&gt; views to determine whether the column and tables exist.&lt;/p&gt;

&lt;p&gt;If, for example, there is a table called &lt;strong&gt;MainTable&lt;/strong&gt; in the database you can check it with a query like this:&lt;/p&gt;

&lt;pre&gt;SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'MainTable'&lt;/pre&gt;

&lt;p&gt;And it will return:&lt;/p&gt;

&lt;p&gt;&lt;a title="INFORMATION_SCHEMA.TABLES by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3940740909/"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="INFORMATION_SCHEMA.TABLES" src="http://farm4.static.flickr.com/3510/3940740909_32d8c15927_o.png" width="417" height="64" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is a similar view for checking columns. For example:&lt;/p&gt;

&lt;p&gt;&lt;a title="INFORMATION_SCHEMA.COLUMNS by Colin  Angus Mackay, on Flickr" href="http://www.flickr.com/photos/colinangusmackay/3940756637/"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="INFORMATION_SCHEMA.COLUMNS" src="http://farm4.static.flickr.com/3504/3940756637_c35304d4f9_o.png" width="510" height="70" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the &lt;strong&gt;INFORMATION_SCHEMA.COLUMNS&lt;/strong&gt; view also contains sufficient detail on the table so that when we implement it we only have to make one check:&lt;/p&gt;

&lt;pre&gt;ALTER PROCEDURE GetData 
	@Id INT,
	@TableName sysname,
	@ColumnName sysname
AS
BEGIN
    SET NOCOUNT ON;
	
    IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
               WHERE TABLE_NAME = @TableName AND COLUMN_NAME = @ColumnName)
    BEGIN
        DECLARE @sql nvarchar(max) = 
            'SELECT ' + @ColumnName + 
            ' FROM ' + @TableName + 
            ' WHERE Id = '+cast(@Id as nvarchar(20));	
        EXEC(@sql)
    END
END
GO&lt;/pre&gt;

&lt;h2&gt;Formatting the input&lt;/h2&gt;

&lt;p&gt;The above is only part of the solution, it is perfectly possible for a table name to contain characters that mean it needs to be escaped. (e.g. a space character or the table may share a name with a SQL keyword). To escape a table or column name it is enclosed in square brackets, so a table name of &lt;strong&gt;My Table&lt;/strong&gt; becomes &lt;strong&gt;[My Table]&lt;/strong&gt; or a table called &lt;strong&gt;select&lt;/strong&gt; becomes &lt;strong&gt;[select]&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can escape table and column names that wouldn’t ordinarily require escaping also. It makes no difference to them.&lt;/p&gt;

&lt;p&gt;The code now becomes:&lt;/p&gt;

&lt;pre&gt;ALTER PROCEDURE GetData 
	@Id INT,
	@TableName sysname,
	@ColumnName sysname
AS
BEGIN
    SET NOCOUNT ON;
	
    IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
               WHERE TABLE_NAME = @TableName AND COLUMN_NAME = @ColumnName)
    BEGIN
        DECLARE @sql nvarchar(max) = 
            'SELECT [' + @ColumnName + '] ' + 
            'FROM [' + @TableName + '] ' +
            'WHERE Id = '+cast(@Id as nvarchar(20));	
        EXEC(@sql)
    END
END
GO&lt;/pre&gt;

&lt;p&gt;But that's not quite the full story.&lt;/p&gt;

&lt;h2&gt;Really formatting the input&lt;/h2&gt;

&lt;p&gt;What if you have a table called &lt;strong&gt;Cra]zee Table&lt;/strong&gt;? Okay - Why on earth would you have a table with such a stupid name? It happens, and it is a perfectly legitimate table name in SQL Server. People do weird stuff and you have to deal with it.&lt;/p&gt;

&lt;p&gt;At the moment the current stored procedure will simply fall apart when presented with such input. The call to the stored procedure would look like this: &lt;/p&gt;

&lt;pre&gt;EXEC GetData 1, 'Cra]zee Table', 'MadStuff'&lt;/pre&gt;

&lt;p&gt;And it gets past the validation stage because it is a table in the system. The result is a message: &lt;/p&gt;

&lt;pre&gt;Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'Table'.&lt;/pre&gt;
The SQL produced looks like this: 

&lt;pre&gt;SELECT [MadStuff] FROM [Cra]zee Table] WHERE Id = 1&lt;/pre&gt;

&lt;p&gt;By this point is should be obvious why it failed. The SQL Parser interpreted the first closing square bracket as the terminator for the escaped section.&lt;/p&gt;

&lt;p&gt;There are other special characters in SQL that require special consideration and you could write code to process them before adding it to the SQL string. In fact, I’ve seen many people do that. And more often than not they get it wrong.&lt;/p&gt;

&lt;p&gt;The better way to deal with that sort of thing is to use a built in function in SQL Server called &lt;strong&gt;&lt;a title="QUOTENAME function (SQL Server Books On-Line)" href="http://msdn.microsoft.com/en-us/library/ms176114.aspx"&gt;QUOTENAME&lt;/a&gt;&lt;/strong&gt;. This will ensure the column or table name is properly escaped. The stored procedure we are now building now looks like this:&lt;/p&gt;

&lt;pre&gt;ALTER PROCEDURE GetData 
	@Id INT,
	@TableName sysname,
	@ColumnName sysname
AS
BEGIN
    SET NOCOUNT ON;
	
    IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
               WHERE TABLE_NAME = @TableName AND COLUMN_NAME = @ColumnName)
    BEGIN
        DECLARE @sql nvarchar(max) = 
            'SELECT ' + QUOTENAME(@ColumnName) +
            ' FROM ' + QUOTENAME(@TableName) + 
            ' WHERE Id = '+cast(@Id as nvarchar(20));	
        EXEC(@sql)
    END
END
GO&lt;/pre&gt;

&lt;h2&gt;Things that can be parameterised&lt;/h2&gt;

&lt;p&gt;There is still something that can be done to this. The Id value is being injected in to the SQL string, yet it is something that can quite easily be parameterised.&lt;/p&gt;

&lt;p&gt;The issue at the moment is that the SQL String is being executed by using the &lt;a title="EXECUTE (T-SQL) (SQL Server Books On-Line)" href="http://msdn.microsoft.com/en-us/library/ms188332.aspx"&gt;&lt;strong&gt;EXECUTE&lt;/strong&gt;&lt;/a&gt; command. However, you cannot pass parameters into this sort of executed SQL. You need to use a stored procedure called &lt;strong&gt;&lt;a title="sp_executesql (Stored Procedure, Transact SQL) (SQL Server Books On-Line)" href="http://msdn.microsoft.com/en-us/library/ms188001.aspx"&gt;sp_executesql&lt;/a&gt;&lt;/strong&gt;. This allows parameters to be defined and passed into the dynamically created SQL.&lt;/p&gt;

&lt;p&gt;The stored procedure now looks like this:&lt;/p&gt;

&lt;pre&gt;ALTER PROCEDURE GetData 
	@Id INT,
	@TableName sysname,
	@ColumnName sysname
AS
BEGIN
    SET NOCOUNT ON;
	
    IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS 
               WHERE TABLE_NAME = @TableName AND COLUMN_NAME = @ColumnName)
    BEGIN
        DECLARE @sql nvarchar(max) = 
            'SELECT ' + QUOTENAME(@ColumnName) +
            ' FROM ' + QUOTENAME(@TableName) + 
            ' WHERE Id = @Identifier';	
        EXEC sp_executesql @sql, N'@Identifier int',
                           @Identifier = @Id
    END
END
GO&lt;/pre&gt;

&lt;p&gt;This is not quite the end of the story. There are performance improvements that can be made when using sp_executesql. You can find out about these in the SQL Server books-online.&lt;/p&gt;

&lt;h2&gt;And finally...&lt;/h2&gt;

&lt;p&gt;If you must use dynamic SQL in stored procedures do take care to ensure that all the data is validated and cannot harm your database. This is an area in which I tread very carefully if I have no other choice. &lt;/p&gt;

&lt;p&gt;Try and consider every conceivable input, especially inputs outside of the bounds of your application. Remember also, that defending your database is a multi-layered strategy. Even if you have the best firewalls and security procedures elsewhere in your system a determined hacker may find a way though your other defences and be communicating with the database in a way in which you didn’t anticipate. Assume that an attacker has got through your other defences, how do you provide the data services to your application(s) yet protect the database?&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:80b80b8f-e1ea-40c0-bbd9-6e4760f85a79" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/sql" rel="tag"&gt;sql&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql+server" rel="tag"&gt;sql server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sql+injection+attack" rel="tag"&gt;sql injection attack&lt;/a&gt;,&lt;a href="http://technorati.com/tags/dynamic+sql" rel="tag"&gt;dynamic sql&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/9076.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/09/21/If-you-really-must-do-dynamic-SQLhellip.aspx</guid>
            <pubDate>Mon, 21 Sep 2009 18:15:01 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/9076.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/09/21/If-you-really-must-do-dynamic-SQLhellip.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/9076.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQL Injection Attack Prevention talk</title>
            <link>http://blog.colinmackay.net/archive/2009/08/23/SQL-Injection-Attack-Prevention-talk.aspx</link>
            <description>&lt;p&gt;In light of some recent events, such as the man who was convicted of &lt;a href="http://blog.colinmackay.net/archive/2009/08/18/BBC-repeating-mindless-nonsense.aspx"&gt;stealing 130 million credit card details through a SQL Injection attack&lt;/a&gt; and &lt;a href="http://blog.colinmackay.net/archive/2009/08/22/Follow-up-on-what-not-to-develop.aspx"&gt;hotel websites that vomit up SQL&lt;/a&gt;, I’ve decided to revive my &lt;em&gt;SQL Injection Attacks (and how to prevent them)&lt;/em&gt; talk.&lt;/p&gt;  &lt;p&gt;I’ve already &lt;a href="http://www.sqlbits.com/Agenda/event5/SQL_Injection_Attacks__and_how_to_prevent_them_/default.aspx"&gt;submitted it for consideration for SQL Bits V&lt;/a&gt;. But I’m also happy to come along to user groups that want to hear it.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/8782.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2009/08/23/SQL-Injection-Attack-Prevention-talk.aspx</guid>
            <pubDate>Sun, 23 Aug 2009 12:41:58 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/8782.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2009/08/23/SQL-Injection-Attack-Prevention-talk.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/8782.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQL Server Spatial Queries talk</title>
            <link>http://blog.colinmackay.net/archive/2008/11/13/4679.aspx</link>
            <description>&lt;p&gt;Well, I was battling a huge cold that day but &lt;a href="http://www.sqlbits.com/" target="_blank"&gt;SQL Bits&lt;/a&gt; have still put up &lt;a href="http://www.sqlbits.com/Agenda/event3/Where_s_my_data__An_introduction_to_Spatial_Queries_in_SQL_Server_2008/default.aspx#Video" target="_blank"&gt;the talk I did on SQL Server 2008 Spatial Queries&lt;/a&gt;. They've edited it to take out the point I coughed so loudly I almost blew out the speakers which is good.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/4679.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/11/13/4679.aspx</guid>
            <pubDate>Thu, 13 Nov 2008 00:14:52 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/4679.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/11/13/4679.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/4679.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Developing with SQL Server 2008, deploying on SQL Server 2005</title>
            <link>http://blog.colinmackay.net/archive/2008/08/31/3738.aspx</link>
            <description>&lt;p&gt;I received the following by email today:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Hi Colin! I found your blog after googling for a bit about SQL Server. I had a question for you... As someone fairly new to .NET development, would it be easier to stick with SQL Server 2005 for now, or just install SQL Server 2008 express? I ask because I don't yet know enough about the differences between the two to know if there will be any issues when developing small web applications with 2008, but then deploying them to a hosting provider with 2005. Hope that makes sense. :) &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Cheers,        &lt;br /&gt;Sean&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I don't recommend moving to SQL Server 2008 if you will ultimately be deploying on SQL Server 2005. &lt;/p&gt;  &lt;p&gt;If you don't know the difference between SQL Server 2005 and 2008, yet your hosting provider only supports 2005 then you would be better off sticking to working with SQL Server 2005 on your system. The reason for this is that you don't want to accidentally stumble into features of 2008 that are not supported on 2005.&lt;/p&gt;  &lt;p&gt;Also, even if you were intimately aware of the differences between the two versions it is still a good rule of thumb to develop on a system that is as close to the eventual live system as you can. That way you won't get any unexpected nasty surprises when you do deploy the application and suddenly realise that things are not quite as expected.&lt;/p&gt;  &lt;p&gt;If you have already developed the applications then you can set the compatibility level of the database to mimic SQL Server 2005:&lt;/p&gt;  &lt;pre&gt;ALTER DATABASE [MyDatabaseName] SET COMPATIBILITY_LEVEL = 90&lt;/pre&gt;

&lt;p&gt;That way you should have a similar (although not necessarily quite the same) experience as if you were developing on a real SQL Server 2005 system. There will still be things that you cannot do. I don't think backing up your 2008 database and restoring it on a 2005 system will work. &lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3738.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/31/3738.aspx</guid>
            <pubDate>Sun, 31 Aug 2008 23:18:04 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3738.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/31/3738.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3738.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Advert for SQL Bits III</title>
            <link>http://blog.colinmackay.net/archive/2008/08/09/3275.aspx</link>
            <description>&lt;p&gt;&lt;embed src="http://www.grapheine.com/bombaytv/bt.swf?code=1c836bb7463852b5dc292a017374a7df" width="400" height="370" type="application/x-shockwave-flash" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sqlbits.com/" target="_blank"&gt;SQL Bits III&lt;/a&gt; will be held on 13th September 2008.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c5cffb8f-ffa0-4899-8a15-554d22d43ee4" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Bits" rel="tag"&gt;SQL Bits&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Bits%20III" rel="tag"&gt;SQL Bits III&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3275.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/09/3275.aspx</guid>
            <pubDate>Sat, 09 Aug 2008 11:24:50 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3275.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/09/3275.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3275.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQL Server 2008 RTM</title>
            <link>http://blog.colinmackay.net/archive/2008/08/07/3249.aspx</link>
            <description>&lt;p&gt;It would appear that &lt;a href="http://www.microsoft.com/sqlserver/2008/en/us/default.aspx" target="_blank"&gt;SQL Server 2008&lt;/a&gt; has finally RTM'ed. &lt;a href="http://msdn.microsoft.com/en-gb/default.aspx" target="_blank"&gt;MSDN&lt;/a&gt; and &lt;a href="http://technet.microsoft.com/en-gb/default.aspx" target="_blank"&gt;TechNet&lt;/a&gt; subscribers can now download it from their respective websites.&lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3249.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/07/3249.aspx</guid>
            <pubDate>Thu, 07 Aug 2008 00:24:59 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3249.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/07/3249.aspx#feedback</comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3249.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQL Server / Visual Studio Install Order</title>
            <link>http://blog.colinmackay.net/archive/2008/08/03/3206.aspx</link>
            <description>&lt;p&gt;Yesterday I paved my laptop in order to upgrade to Windows Vista. I've now started to reinstall everything from scratch again. However, one thing that didn't work out was the installation of SQL Server 2005. No matter what I tried I could not seem to get it to install the SQL Server Management Studio - somehow it was convinced that it already existed. I eventually figured out why.&lt;/p&gt;
&lt;p&gt;I'd installed Visual Studio 2008 first, and as part of that installation it installed SQL Server 2005 Express edition. The express edition does not come with SQL Server Management Studio. When I went to install SQL Server 2005 it refused to install the management studio saying that more up-to-date versions of the tools were already available on the machine. (Well, I suppose some of them were, at least the ones installed by Visual Studio 2008's installer). Running the Service Pack 2 upgrade did not help either. It concluded that the client tools were not valid as part of the upgrade and refused to install them.&lt;/p&gt;
&lt;p&gt;Eventually I came to the conclusion that it would be quicker, given my recent wiping of my laptop to just start afresh again and install things in the correct order. I suppose I was lucky to have that option. I am also lucky that I don't activate Windows until I'm sure everything is installed correctly - after all I do have 30 days to activate Windows. I'd hate to have lost an activation of Windows because of a dodgy install.&lt;/p&gt;
&lt;p&gt;So what is the installation order I've now used that works:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Windows Vista SP1 &lt;/li&gt;
    &lt;li&gt;Windows Update (my install required 33 updates) &lt;/li&gt;
    &lt;li&gt;SQL Server 2005 &lt;/li&gt;
    &lt;li&gt;SQL Server 2005 SP2 &lt;/li&gt;
    &lt;li&gt;Visual Studio 2008 &lt;/li&gt;
&lt;/ul&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dc7edcfe-2f0c-4c53-a48d-9c49002cd50a" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/sql%20server"&gt;sql server&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/sql%20server%202005"&gt;sql server 2005&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/visual%20studio"&gt;visual studio&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/visual%20studio%202008"&gt;visual studio 2008&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/windows"&gt;windows&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/vista"&gt;vista&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/windows%20vista"&gt;windows vista&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/sql%20server%202005%20express"&gt;sql server 2005 express&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/sql%20server%20express"&gt;sql server express&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/installation"&gt;installation&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/install"&gt;install&lt;/a&gt;&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;PLEASE NOTE: The above is what worked for me. I've also heard that it has worked for others too. It comes with no warranties of any kind. &lt;/p&gt;
&lt;p&gt;If you are having difficulty installing your SQL Server you may like to ask a question on one of the many fine forums that are available for asking questions of that nature. I tend to hang out on &lt;a href="http://www.codeproject.com"&gt;Code Project&lt;/a&gt; and may be able to help there. If I'm not around then one of the many other great members can possibly help you on their &lt;a href="http://www.codeproject.com/script/Forums/View.aspx?fid=1725&amp;amp;msg=1278600"&gt;database forum&lt;/a&gt;. &lt;/p&gt;&lt;img src="http://blog.colinmackay.net/aggbug/3206.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Colin Angus Mackay</dc:creator>
            <guid>http://blog.colinmackay.net/archive/2008/08/03/3206.aspx</guid>
            <pubDate>Sun, 03 Aug 2008 14:02:10 GMT</pubDate>
            <wfw:comment>http://blog.colinmackay.net/comments/3206.aspx</wfw:comment>
            <comments>http://blog.colinmackay.net/archive/2008/08/03/3206.aspx#feedback</comments>
            <slash:comments>9</slash:comments>
            <wfw:commentRss>http://blog.colinmackay.net/comments/commentRss/3206.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>