<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dushyanth Jyothi &#187; MS SQL Server 2008</title>
	<atom:link href="http://dushi.co.uk/tag/ms-sql-server-2008/feed/" rel="self" type="application/rss+xml" />
	<link>http://dushi.co.uk</link>
	<description>Me, My Life and the Binary</description>
	<lastBuildDate>Sun, 18 Dec 2011 00:54:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>SQL server backup Error 3154</title>
		<link>http://dushi.co.uk/22/07/2009/sql-server-backup-error-3154/</link>
		<comments>http://dushi.co.uk/22/07/2009/sql-server-backup-error-3154/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 19:52:03 +0000</pubDate>
		<dc:creator>Dushyanth Jyothi</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[MS SQL Server 2008]]></category>
		<category><![CDATA[Stored Procedure]]></category>

		<guid isPermaLink="false">http://dushi.co.uk/?p=86</guid>
		<description><![CDATA[SQL Sever Error 3154: The backup set holds a backup of a database other than the existing database. Tested only on MS SERVER 2008 USE master GO &#160; -- Database to restore : DJ_ADMIN -- Resore With: DJ_ADMIN_Latest.bak -- Backup existing database's to : DJ_ADMIN_Old.bak;DJ_ADMIN_Old_Log.bak -- Database to restore : DJ_ADMIN &#160; ALTER DATABASE DJ_ADMIN [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Sever Error 3154: The backup set holds a backup of a database other than the existing database.</p>
<p><strong>Tested only on MS SERVER 2008</strong></p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">USE</span> master
GO
&nbsp;
<span style="color: #008080;">-- Database to restore : DJ_ADMIN</span>
<span style="color: #008080;">-- Resore With: DJ_ADMIN_Latest.bak</span>
<span style="color: #008080;">-- Backup existing database's to : DJ_ADMIN_Old.bak;DJ_ADMIN_Old_Log.bak</span>
<span style="color: #008080;">-- Database to restore : DJ_ADMIN</span>
&nbsp;
<span style="color: #0000FF;">ALTER</span> <span style="color: #0000FF;">DATABASE</span> DJ_ADM<span style="color: #808080;">IN</span>
<span style="color: #0000FF;">SET</span> S<span style="color: #808080;">IN</span>GLE_USER <span style="color: #0000FF;">WITH</span>
<span style="color: #0000FF;">ROLLBACK</span> <span style="color: #0000FF;">IMMEDIATE</span>
<span style="color: #0000FF;">RESTORE</span> <span style="color: #0000FF;">DATABASE</span> DJ_ADM<span style="color: #808080;">IN</span>
<span style="color: #0000FF;">FROM</span> <span style="color: #0000FF;">DISK</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">'C:\Backups\DJ_ADMIN_Latest.bak'</span>
<span style="color: #0000FF;">WITH</span> MOVE <span style="color: #FF0000;">'DJ_ADMIN'</span> <span style="color: #0000FF;">TO</span> <span style="color: #FF0000;">'C:\Backups\DJ_ADMIN_Old.mdf'</span>,
MOVE <span style="color: #FF0000;">'DJ_ADMIN_Log'</span> <span style="color: #0000FF;">TO</span> <span style="color: #FF0000;">'C:\Backups\DJ_ADMIN_Old_Log.ldf'</span>,
<span style="color: #FF00FF;">REPLACE</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dushi.co.uk/22/07/2009/sql-server-backup-error-3154/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Information Schema Database Metadata</title>
		<link>http://dushi.co.uk/15/07/2009/information-schema-database-metadata/</link>
		<comments>http://dushi.co.uk/15/07/2009/information-schema-database-metadata/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 09:46:49 +0000</pubDate>
		<dc:creator>Dushyanth Jyothi</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Information schema]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[MS SQL Server 2008]]></category>

		<guid isPermaLink="false">http://dushi.co.uk/?p=71</guid>
		<description><![CDATA[Information schema is part of the SQL-92 standard, holds the structure if your database. Applies to MS SQL SERVER 2008 T-SQL CODE to see the metada: SELECT * FROM INFORMATION_SCHEMA.TABLES SELECT TABLE_CATALOG,/*'TABLE_CATALOG' IS SQL-92 STANDARD NAME FOR 'DATABASE'*/ TABLE_SCHEMA,/*'TABLE_SCHEMA' IS SQL-92 STANDARD NAME FOR 'OWNER'*/ TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES Further Reading/Details: http://msdn.microsoft.com/en-us/library/ms186778.aspx]]></description>
			<content:encoded><![CDATA[<p>Information schema is part of the SQL-92 standard, holds the structure if your database.</p>
<p><strong>Applies to MS SQL SERVER 2008</strong></p>
<p>T-SQL CODE to see the metada:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">FROM</span> <span style="color: #808080;">IN</span>F<span style="color: #808080;">OR</span>MATION_SCHEMA.<span style="color: #202020;">TABLES</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> 
TABLE_CATALOG,<span style="color: #008080;">/*'TABLE_CATALOG' IS SQL-92 STANDARD NAME FOR 'DATABASE'*/</span>
TABLE_SCHEMA,<span style="color: #008080;">/*'TABLE_SCHEMA' IS SQL-92 STANDARD NAME FOR 'OWNER'*/</span>
TABLE_NAME,
TABLE_TYPE
<span style="color: #0000FF;">FROM</span> <span style="color: #808080;">IN</span>F<span style="color: #808080;">OR</span>MATION_SCHEMA.<span style="color: #202020;">TABLES</span></pre></div></div>

<p><strong>Further Reading/Details:</strong><br />
<a href="http://msdn.microsoft.com/en-us/library/ms186778.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms186778.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dushi.co.uk/15/07/2009/information-schema-database-metadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An error occurred when attaching the database</title>
		<link>http://dushi.co.uk/14/07/2009/an-error-occurred-when-attaching-the-database/</link>
		<comments>http://dushi.co.uk/14/07/2009/an-error-occurred-when-attaching-the-database/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 21:56:01 +0000</pubDate>
		<dc:creator>Dushyanth Jyothi</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[AdvenureWorks]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[MS SQL Server 2008]]></category>

		<guid isPermaLink="false">http://dushi.co.uk/?p=66</guid>
		<description><![CDATA[An error occurred when attaching the database &#8211; AdvenureWorks database The below steps applies to MS SQL Server 2008 A. Make sure you enabled database instance to use FILESTREAM as instructed here: http://msdn.microsoft.com/en-us/library/cc645923.aspx B. If you downloaded Adventureworks from codeplex, make sure you have set the right user permissions to these files C. Copy AdventureWorks2008_Data.mdf [...]]]></description>
			<content:encoded><![CDATA[<p><strong>An error occurred when attaching the database &#8211; AdvenureWorks database</strong></p>
<p>The below steps applies to MS SQL Server 2008</p>
<p>A. Make sure you enabled database instance to use <strong>FILESTREAM </strong>as instructed here:<br />
<a href="http://msdn.microsoft.com/en-us/library/cc645923.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/cc645923.aspx</a></p>
<p>B. If you downloaded Adventureworks from codeplex, make sure you have set the right <strong>user permissions</strong> to these files</p>
<p>C. <strong>Copy </strong>AdventureWorks2008_Data.mdf and AdventureWorks2008_Log.ldf to<br />
&#8216;C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\&#8217;<br />
If you see a folder called &#8216;Documents&#8217; in the downloaded files set, then copy this folder also to &#8216;C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\&#8217;</p>
<p>D. In the managment studio, open new query window and <strong>execute the below code</strong>: [Change the files path accordingly]</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">USE</span> <span style="color: #808080;">&#91;</span>master<span style="color: #808080;">&#93;</span>
GO
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">DATABASE</span> <span style="color: #808080;">&#91;</span>Adventureworks<span style="color: #808080;">&#93;</span> <span style="color: #0000FF;">ON</span>
<span style="color: #808080;">&#40;</span> FILENAME <span style="color: #808080;">=</span> N<span style="color: #FF0000;">'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008_Data.mdf'</span> <span style="color: #808080;">&#41;</span>,
<span style="color: #808080;">&#40;</span> FILENAME <span style="color: #808080;">=</span> N<span style="color: #FF0000;">'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008_Log.ldf'</span> <span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">FOR</span> ATTACH
GO
<span style="color: #0000FF;">if</span> not exists <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">select</span> name <span style="color: #0000FF;">from</span> master.<span style="color: #202020;">sys</span>.<span style="color: #202020;">databases</span> sd <span style="color: #0000FF;">where</span> name <span style="color: #808080;">=</span> N<span style="color: #FF0000;">'Adventureworks'</span> and <span style="color: #FF00FF;">SUSER_SNAME</span><span style="color: #808080;">&#40;</span>sd.<span style="color: #202020;">owner_sid</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF00FF;">SUSER_SNAME</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">EXEC</span> <span style="color: #808080;">&#91;</span>Adventureworks<span style="color: #808080;">&#93;</span>.<span style="color: #202020;">dbo</span>.<span style="color: #AF0000;">sp_changedbowner</span> @loginame<span style="color: #808080;">=</span>N<span style="color: #FF0000;">'sa'</span>, @<span style="color: #0000FF;">map</span><span style="color: #808080;">=</span><span style="color: #0000FF;">false</span>
GO</pre></div></div>

<p><strong>OR  you can attach a databse either using MS:</strong><br />
1. In SQL Server Management Studio Object Explorer, connect to an instance of the Microsoft SQL Server Database Engine, and then expand that instance.<br />
2. Right click Databases, then Tasks, and then click Attach.<br />
3. In the Attach Databases dialog box, to specify the database to be attached, click Add; and in the Locate Database Files dialog box, select the disk drive where the database resides and expand the directory tree to find and select the .mdf file of the database; for example: C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008_Data.mdf</p>
<p>Optionall : Specify a different name, Change the ownership<br />
4. When you are ready to attach the database, click OK.</p>
]]></content:encoded>
			<wfw:commentRss>http://dushi.co.uk/14/07/2009/an-error-occurred-when-attaching-the-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

