<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blog.cpugeni.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>Tom Hall's Blog : SQL Server</title><link>http://blog.cpugeni.com/archive/tags/SQL+Server/default.aspx</link><description>Tags: SQL Server</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Debug Build: 40407.4157)</generator><item><title>Connect to SQL Azure using SQL Server Management Studio 2008</title><link>http://blog.cpugeni.com/archive/2009/10/26/connect-to-sql-azure-using-sql-server-management-studio-2008.aspx</link><pubDate>Mon, 26 Oct 2009 00:04:11 GMT</pubDate><guid isPermaLink="false">639facdc-ae2a-47ea-a5af-a73104758a1a:4080</guid><dc:creator>Tom Hall</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://blogs.technet.com/blogfiles/patricg/WindowsLiveWriter/SQLServicesdevientMicrosoftSQLAzure_A566/Clipboard01_thumb.jpg"&gt;&lt;img style="border-right-width:0px;margin:0px 0px 10px 10px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="SQL Azure Logo" border="0" alt="SQL Azure Logo" align="right" src="http://blogs.technet.com/blogfiles/patricg/WindowsLiveWriter/SQLServicesdevientMicrosoftSQLAzure_A566/Clipboard01_thumb.jpg" width="240" height="76" /&gt;&lt;/a&gt; SQL Azure is now in CTP and for those who have received an invitation to test it out, you might be wondering how you can manage your databases via SQL Server Management Studio…. Here’s a few steps to do it:&lt;/p&gt; &lt;div id="extendedEntryBreak"&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Set up your SQL Azure server and Administrator Username via &lt;a href="https://sql.azure.com/"&gt;https://sql.azure.com/&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;On the SQL Azure website under Firewall Settings ensure you check “Allow Microsoft Services access to this server” and add your IP address to the IP Address Range &lt;/li&gt;    &lt;li&gt;Open SQL Server Management Studio &lt;/li&gt;    &lt;li&gt;Close the “Connect to Server” dialogue and click “New Query” &lt;/li&gt;    &lt;li&gt;In the “Connect to Server” dialogue box type the server name provided via the SQL Azure website, e.g: &lt;em&gt;&lt;font color="#0000a0" face="Courier New"&gt;&amp;lt;servername&amp;gt;.database.windows.net &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;Select Authentication to SQL Server Authentication &lt;/li&gt;    &lt;li&gt;Your username is the Administrator Username you set up in this format: &lt;font color="#0000a0" face="Courier New"&gt;&amp;lt;username&amp;gt;@&amp;lt;servername&amp;gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;Password is obvious? &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;From here you can run as much T-SQL as you like :) &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blog.cpugeni.com/aggbug.aspx?PostID=4080" width="1" height="1"&gt;</description><category domain="http://blog.cpugeni.com/archive/tags/Beta/default.aspx">Beta</category><category domain="http://blog.cpugeni.com/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blog.cpugeni.com/archive/tags/Development/default.aspx">Development</category><category domain="http://blog.cpugeni.com/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blog.cpugeni.com/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blog.cpugeni.com/archive/tags/Azure/default.aspx">Azure</category></item><item><title>Exporting your SQL Server Schema and Data to a Single Script File</title><link>http://blog.cpugeni.com/archive/2008/12/09/exporting-your-sql-server-schema-and-data-to-a-single-script-file.aspx</link><pubDate>Tue, 09 Dec 2008 21:54:20 GMT</pubDate><guid isPermaLink="false">639facdc-ae2a-47ea-a5af-a73104758a1a:30</guid><dc:creator>Tom Hall</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;margin:0px 0px 5px 5px;display:inline;border-top:0px;border-right:0px;" title="Microsoft SQL Server 2008 Logo" border="0" alt="Microsoft SQL Server 2008 Logo" align="right" src="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_thumb.png" width="240" height="50" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;I &lt;a target="_blank" href="http://www.eukhost.co.uk"&gt;host&lt;/a&gt; my &lt;a target="_blank" href="http://www.cpugeni.com"&gt;website&lt;/a&gt;, and manage several other websites using shared hosting, these hosting packages all contain some sort of SQL Server database allowance. Using shared hosting, problems can and do arise when you’re ready to deploy from development/test into the live/production environment, e.g. you have your database fully constructed and in working order on your development/test environment with all your static tables populated, with a bit of sample data thrown in on other tables.&lt;/p&gt;  &lt;p&gt;SQL Server has a few built-in tools to enable you to copy data to and from servers and databases, “&lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms188664.aspx"&gt;Copy Database…&lt;/a&gt;”, “&lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms141209.aspx"&gt;Export/Import Data…&lt;/a&gt;” and of course you can always perform a “&lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms190436.aspx"&gt;Backup and Restore&lt;/a&gt;” of the database and copy the backup file to another server. These all work great on your local network (most of the time!) where you hold a lot of security rights compared to when you are using a shared hosting environment where you hold a lot less security rights, therefore you cannot perform these built-in tasks (well not always). Problem!&lt;/p&gt;  &lt;p&gt;Well, actually, not so much of a problem anymore since there is a tool, &lt;a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&amp;amp;displaylang=en"&gt;Microsoft SQL Server Database Publishing Wizard&lt;/a&gt;, which will enable you to script the entire database schema AND data to a single script (.sql) file. If you want, you can script individual parts of the database, and you can also set a target SQL Server, so if you are developing using &lt;a target="_blank" href="http://www.microsoft.com/express/sql/default.aspx"&gt;SQL Server 2008 Express Edition&lt;/a&gt; but your host is SQL Server 2000 or 2005 you need not worry about compatibility. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_3.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;margin:0px 5px 5px 0px;display:inline;border-top:0px;border-right:0px;" title="Visual Studio 2008 Server Explorer" border="0" alt="Visual Studio 2008 Server Explorer" align="left" src="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_thumb_3.png" width="236" height="244" /&gt;&lt;/a&gt;SQL Database Publishing Wizard is built-in to Visual Studio 2008 and can be accessed under the “Server Explorer” window as seen to the left. &lt;/p&gt;  &lt;p&gt;Otherwise, if you don’t have Visual Studio 2008, you can download and install the &lt;a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&amp;amp;displaylang=en"&gt;SQL Server Database Publishing Wizard 1.1&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;When you’re ready, either going through Visual Studio or sqlpubwiz.exe, first things first, you’ll have to set up your connection string and if you are connecting to a remote server then you may come into difficulties if the database is large and your connection is slow, so bare that in mind and perhaps tweak your connection string, “Connect Timeout”, “Packet Size” and “Max Pool Size”. &lt;/p&gt;  &lt;p&gt;I really don’t need to explain anything else since these screenshots speak for themselves:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_4.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;margin-left:0px;border-top:0px;margin-right:0px;border-right:0px;" title="Database Publishing Wizard - Welcome" border="0" alt="Database Publishing Wizard - Welcome" src="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_thumb_4.png" width="244" height="220" /&gt;&lt;/a&gt;&amp;#160;&lt;a href="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_5.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Database Publishing Wizard - Select Database" border="0" alt="Database Publishing Wizard - Select Database" src="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_thumb_5.png" width="244" height="220" /&gt;&lt;/a&gt;&amp;#160;&lt;a href="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_6.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Database Publishing Wizard - Select an Output Location" border="0" alt="Database Publishing Wizard - Select an Output Location" src="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_thumb_6.png" width="244" height="220" /&gt;&lt;/a&gt;&amp;#160;&lt;a href="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_7.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Database Publishing Wizard - Select Publishing Options" border="0" alt="Database Publishing Wizard - Select Publishing Options" src="http://blog.cpugeni.com/filestorage/CommunityServer.Blogs.Components.WeblogFiles/tomhall/ExportingyourSQLServerSchemaandDatatoaSi_133F2/image_thumb_7.png" width="244" height="220" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It really is as simple as that… Once you click finish, the wizard will whiz away generating the T-SQL you need to deploy your database schema and data to any SQL Server, providing you set “Script for target database” appropriately. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Some notes:&lt;/strong&gt; When executing scripts onto the remote shared host SQL Server, this can take a long time, depending on the size of the database script, and while the script is executing your database will be unavailable.&lt;/p&gt;  &lt;p&gt;Also, you can use sqlpubwiz.exe via the command line (CMD), so obviously with that in mind, you could run batch files to generate a script backup.&lt;/p&gt;  &lt;p&gt;Hope that helps, it’s certainly made my life a lot easier!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blog.cpugeni.com/aggbug.aspx?PostID=30" width="1" height="1"&gt;</description><category domain="http://blog.cpugeni.com/archive/tags/Databases/default.aspx">Databases</category><category domain="http://blog.cpugeni.com/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Microsoft SQL Server Management Studio 2008: Error 916</title><link>http://blog.cpugeni.com/archive/2008/09/22/microsoft-sql-server-management-studio-2008-error-916.aspx</link><pubDate>Mon, 22 Sep 2008 22:38:00 GMT</pubDate><guid isPermaLink="false">639facdc-ae2a-47ea-a5af-a73104758a1a:5</guid><dc:creator>Tom Hall</dc:creator><slash:comments>83</slash:comments><description>&lt;p&gt;I came across a problem when using Microsoft SQL Server Management Studio 2008 to connect and manage a database which is housed on my shared host&amp;rsquo;s SQL Server 2005, the problem was that I couldn&amp;rsquo;t actually access my database, as I clicked the &amp;ldquo;Database&amp;rdquo; node within &amp;ldquo;Object Explorer&amp;rdquo; I received the message:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p align="left"&gt;&lt;i&gt;The server principal &amp;ldquo;username&amp;rdquo; is not able to access the database &amp;ldquo;databasename&amp;rdquo; under the current security context. (Microsoft SQL Server, Error: 916)&lt;/i&gt;&lt;/p&gt;
&lt;p align="left"&gt;&lt;a href="http://blog.cpugeni.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/tomhall/image_5F00_64310A65.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" alt="image" src="http://blog.cpugeni.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/tomhall/image_5F00_thumb_5F00_03CFBE61.png" border="0" width="244" height="84" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p align="left"&gt;Anyway, after an hour, I decided that I would try and access my database within Microsoft Visual Studio 2008, using the &amp;ldquo;Server Explorer&amp;rdquo;. I set myself up with a connection to the database server, and hooray, I could connect and access everything. That left me wondering why it wasn&amp;rsquo;t working in the Management Studio, so I spent some more time trawling the net for an answer (since I&amp;rsquo;m hardly a SQL Server guru!). I eventually found something to help me out&amp;hellip;&lt;/p&gt;
&lt;p align="left"&gt;When I clicked on the &amp;ldquo;Databases&amp;rdquo; node within SQL Server Management Studio, the software would (in the background) execute an T-SQL query to retrieve a list of databases along with additional information about those databases, one of those pieces of information is &lt;b&gt;collation&lt;/b&gt;, which I didn&amp;rsquo;t have permission to do for every database, only my own.&lt;/p&gt;
&lt;p align="left"&gt;&lt;b&gt;Fix:&lt;/b&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div align="left"&gt;In Object Explorer, click Databases&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="left"&gt;Display &amp;ldquo;Object Explorer Details&amp;rdquo; (F7) or &amp;ldquo;View &amp;ndash;&amp;gt; Object Explorer Details&amp;rdquo;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="left"&gt;Right click the column headers and deselect &amp;ldquo;collation&amp;rdquo;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="left"&gt;Refresh Databases, and hopefully bingo! &lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p align="left"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="left"&gt;Hopefully that helps anyone who finds themselves in the same situation! :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blog.cpugeni.com/aggbug.aspx?PostID=5" width="1" height="1"&gt;</description><category domain="http://blog.cpugeni.com/archive/tags/Databases/default.aspx">Databases</category><category domain="http://blog.cpugeni.com/archive/tags/SQL+Server/default.aspx">SQL Server</category></item></channel></rss>