<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2005 &#8211; T-SQL Script to Attach and Detach Database</title>
	<atom:link href="http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:22:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: gowtham</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-249057</link>
		<dc:creator><![CDATA[gowtham]]></dc:creator>
		<pubDate>Mon, 06 Feb 2012 17:40:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-249057</guid>
		<description><![CDATA[I TRIED TO NEW DATA BASE BUT I GET THE FOLLWING ERROR PLEASE HELP ME TO CORRECT




TITLE: Microsoft SQL Server Management Studio Express
------------------------------

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

------------------------------

The server principal &quot;dell-PC\dell&quot; is not able to access the database &quot;model&quot; under the current security context. (Microsoft SQL Server, Error: 916)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;ProdVer=09.00.1399&amp;EvtSrc=MSSQLServer&amp;EvtID=916&amp;LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------]]></description>
		<content:encoded><![CDATA[<p>I TRIED TO NEW DATA BASE BUT I GET THE FOLLWING ERROR PLEASE HELP ME TO CORRECT</p>
<p>TITLE: Microsoft SQL Server Management Studio Express<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)</p>
<p>For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;LinkId=20476</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ADDITIONAL INFORMATION:</p>
<p>An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>The server principal &#8220;dell-PC\dell&#8221; is not able to access the database &#8220;model&#8221; under the current security context. (Microsoft SQL Server, Error: 916)</p>
<p>For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;ProdVer=09.00.1399&#038;EvtSrc=MSSQLServer&#038;EvtID=916&#038;LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;ProdVer=09.00.1399&#038;EvtSrc=MSSQLServer&#038;EvtID=916&#038;LinkId=20476</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
BUTTONS:</p>
<p>OK<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL_Help</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-235311</link>
		<dc:creator><![CDATA[SQL_Help]]></dc:creator>
		<pubDate>Wed, 11 Jan 2012 14:16:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-235311</guid>
		<description><![CDATA[/*
Rewritten, takes several files now 
*/

DECLARE @database_name varchar(128);
DECLARE @file_id varchar(3);
DECLARE @old_file_id varchar(3);
DECLARE @file_name varchar(128);
DECLARE @M_DB varchar(128);

DECLARE databases CURSOR FOR 
select fileid,db_name(dbid) as databas, filename from sysaltfiles where dbid &gt; &#039;4&#039; and dbid &lt; &#039;32767&#039;
OPEN databases;

FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name

Print &#039;&#039;
print &#039;************** Statement for Detach ***************&#039;
print &#039;&#039;
WHILE @@FETCH_STATUS = 0
   		Begin
		declare @cmd nvarchar(512)
		if @file_id = &#039;1&#039;
			begin
			select @cmd = &#039;USE [MASTER] &#039; + 
					  &#039;ALTER DATABASE [&#039; + @database_name + &#039;] SET SINGLE_USER WITH ROLLBACK IMMEDIATE &#039; +
					  &#039;EXEC dbo.sp_detach_db N&#039; + CHAR(39) + @database_name + CHAR(39) +
					  &#039;, @keepfulltextindexfile = N&#039; + CHAR(39) + &#039;true&#039; +CHAR(39)
			print(@cmd)
			end  
		FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name
		end
CLOSE databases;
OPEN databases;

FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name

Print &#039;&#039;
print &#039;************** Statement for Attach ***************&#039;
Print &#039;&#039;
WHILE @@FETCH_STATUS = 0  
		
   		Begin  
   		declare @cmd2 nvarchar(2048)
		select @cmd2 = &#039;CREATE DATABASE &#039; + @database_name + &#039; ON&#039;   
		if @file_id = &#039;1&#039; 
				begin
				select @cmd2 = @cmd2 + &#039;(FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;)&#039;
				FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name
				set @old_file_id = &#039;1&#039;
		Loop_label:
				if @file_id = &#039;1&#039; or @file_id = @old_file_id GOTO Done_Label
				select @cmd2 = @cmd2 + &#039;,(FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;)&#039;
				set @old_file_id = @file_id
				FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name
		goto Loop_label
				Done_Label:
						end
					select @cmd2 = @cmd2 + &#039; FOR ATTACH&#039;
					print(@cmd2)
						
		end 
CLOSE databases;
DEALLOCATE databases]]></description>
		<content:encoded><![CDATA[<p>/*<br />
Rewritten, takes several files now<br />
*/</p>
<p>DECLARE @database_name varchar(128);<br />
DECLARE @file_id varchar(3);<br />
DECLARE @old_file_id varchar(3);<br />
DECLARE @file_name varchar(128);<br />
DECLARE @M_DB varchar(128);</p>
<p>DECLARE databases CURSOR FOR<br />
select fileid,db_name(dbid) as databas, filename from sysaltfiles where dbid &gt; &#8217;4&#8242; and dbid &lt; &#039;32767&#039;<br />
OPEN databases;</p>
<p>FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name</p>
<p>Print &#039;&#039;<br />
print &#039;************** Statement for Detach ***************&#039;<br />
print &#039;&#039;<br />
WHILE @@FETCH_STATUS = 0<br />
   		Begin<br />
		declare @cmd nvarchar(512)<br />
		if @file_id = &#039;1&#039;<br />
			begin<br />
			select @cmd = &#039;USE [MASTER] &#039; +<br />
					  &#039;ALTER DATABASE [&#039; + @database_name + &#039;] SET SINGLE_USER WITH ROLLBACK IMMEDIATE &#039; +<br />
					  &#039;EXEC dbo.sp_detach_db N&#039; + CHAR(39) + @database_name + CHAR(39) +<br />
					  &#039;, @keepfulltextindexfile = N&#039; + CHAR(39) + &#039;true&#039; +CHAR(39)<br />
			print(@cmd)<br />
			end<br />
		FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name<br />
		end<br />
CLOSE databases;<br />
OPEN databases;</p>
<p>FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name</p>
<p>Print &#039;&#039;<br />
print &#039;************** Statement for Attach ***************&#039;<br />
Print &#039;&#039;<br />
WHILE @@FETCH_STATUS = 0  </p>
<p>   		Begin<br />
   		declare @cmd2 nvarchar(2048)<br />
		select @cmd2 = &#039;CREATE DATABASE &#039; + @database_name + &#039; ON&#039;<br />
		if @file_id = &#039;1&#039;<br />
				begin<br />
				select @cmd2 = @cmd2 + &#039;(FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;)&#039;<br />
				FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name<br />
				set @old_file_id = &#039;1&#039;<br />
		Loop_label:<br />
				if @file_id = &#039;1&#039; or @file_id = @old_file_id GOTO Done_Label<br />
				select @cmd2 = @cmd2 + &#039;,(FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;)&#039;<br />
				set @old_file_id = @file_id<br />
				FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name<br />
		goto Loop_label<br />
				Done_Label:<br />
						end<br />
					select @cmd2 = @cmd2 + &#039; FOR ATTACH&#039;<br />
					print(@cmd2)</p>
<p>		end<br />
CLOSE databases;<br />
DEALLOCATE databases</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL_Help</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-235187</link>
		<dc:creator><![CDATA[SQL_Help]]></dc:creator>
		<pubDate>Wed, 11 Jan 2012 09:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-235187</guid>
		<description><![CDATA[Made a small script for automatically create the Detach as well as the Attach, useful for server with many Db´s installed
just now it is separeted in detach and attach sections.
Needs to be run before detach shall be made, 
makes a Print result but it is easy to change for a execution like this EXEC sp_EXECutesql @cmd.


DECLARE @database_name varchar(128);
DECLARE @file_id varchar(1);
DECLARE @file_name varchar(128);
DECLARE @M_DB varchar(128);

DECLARE databases CURSOR FOR 
select fileid,db_name(dbid),filename from sysaltfiles where dbid &gt; &#039;4&#039; and dbid &lt; &#039;32767&#039;
OPEN databases;

FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name

Print &#039;&#039;
print &#039;************** Statement for Detach ***************&#039;
print &#039;&#039;
WHILE @@FETCH_STATUS = 0
   		Begin
		declare @cmd nvarchar(512)
		if @file_id = &#039;1&#039;
			begin
			select @cmd = &#039;USE [MASTER] &#039; + 
					  &#039;ALTER DATABASE [&#039; + @database_name + &#039;] SET SINGLE_USER WITH ROLLBACK IMMEDIATE &#039; +
					  &#039;EXEC dbo.sp_detach_db N&#039; + CHAR(39) + @database_name + CHAR(39)
			print(@cmd)
			end  
		FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name
		end
CLOSE databases;
OPEN databases;

FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name

Print &#039;&#039;
print &#039;************** Statement for Attach ***************&#039;
Print &#039;&#039;
WHILE @@FETCH_STATUS = 0  
   		Begin  
		declare @cmd2 nvarchar(512)
		select @cmd2 = &#039;CREATE DATABASE &#039; + @database_name + &#039; ON&#039;   
		if @file_id = &#039;1&#039; 
				begin
				select @cmd2 = @cmd2 + &#039;( FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;),&#039;
				FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name
				end
				select @cmd2 = @cmd2 + &#039;( FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;) FOR ATTACH&#039;
				print(@cmd2)
		FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name
		end 
CLOSE databases;
DEALLOCATE databases]]></description>
		<content:encoded><![CDATA[<p>Made a small script for automatically create the Detach as well as the Attach, useful for server with many Db´s installed<br />
just now it is separeted in detach and attach sections.<br />
Needs to be run before detach shall be made,<br />
makes a Print result but it is easy to change for a execution like this EXEC sp_EXECutesql @cmd.</p>
<p>DECLARE @database_name varchar(128);<br />
DECLARE @file_id varchar(1);<br />
DECLARE @file_name varchar(128);<br />
DECLARE @M_DB varchar(128);</p>
<p>DECLARE databases CURSOR FOR<br />
select fileid,db_name(dbid),filename from sysaltfiles where dbid &gt; &#8217;4&#8242; and dbid &lt; &#039;32767&#039;<br />
OPEN databases;</p>
<p>FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name</p>
<p>Print &#039;&#039;<br />
print &#039;************** Statement for Detach ***************&#039;<br />
print &#039;&#039;<br />
WHILE @@FETCH_STATUS = 0<br />
   		Begin<br />
		declare @cmd nvarchar(512)<br />
		if @file_id = &#039;1&#039;<br />
			begin<br />
			select @cmd = &#039;USE [MASTER] &#039; +<br />
					  &#039;ALTER DATABASE [&#039; + @database_name + &#039;] SET SINGLE_USER WITH ROLLBACK IMMEDIATE &#039; +<br />
					  &#039;EXEC dbo.sp_detach_db N&#039; + CHAR(39) + @database_name + CHAR(39)<br />
			print(@cmd)<br />
			end<br />
		FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name<br />
		end<br />
CLOSE databases;<br />
OPEN databases;</p>
<p>FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name</p>
<p>Print &#039;&#039;<br />
print &#039;************** Statement for Attach ***************&#039;<br />
Print &#039;&#039;<br />
WHILE @@FETCH_STATUS = 0<br />
   		Begin<br />
		declare @cmd2 nvarchar(512)<br />
		select @cmd2 = &#039;CREATE DATABASE &#039; + @database_name + &#039; ON&#039;<br />
		if @file_id = &#039;1&#039;<br />
				begin<br />
				select @cmd2 = @cmd2 + &#039;( FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;),&#039;<br />
				FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name<br />
				end<br />
				select @cmd2 = @cmd2 + &#039;( FILENAME = N&#039; + CHAR(39) + @file_name + CHAR(39) + &#039;) FOR ATTACH&#039;<br />
				print(@cmd2)<br />
		FETCH NEXT FROM databases INTO @file_id,@database_name,@file_name<br />
		end<br />
CLOSE databases;<br />
DEALLOCATE databases</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: virendra</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-198552</link>
		<dc:creator><![CDATA[virendra]]></dc:creator>
		<pubDate>Fri, 18 Nov 2011 13:01:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-198552</guid>
		<description><![CDATA[Hi Pinal ,

 How can lock my database if any user stole my mdf and ldf file,User not able to attach the file.

Thanks
Mayank................]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal ,</p>
<p> How can lock my database if any user stole my mdf and ldf file,User not able to attach the file.</p>
<p>Thanks<br />
Mayank&#8230;&#8230;&#8230;&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yogesh singhal</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-131026</link>
		<dc:creator><![CDATA[Yogesh singhal]]></dc:creator>
		<pubDate>Mon, 25 Apr 2011 10:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-131026</guid>
		<description><![CDATA[Hello ALL.

I am new to SQL.

I got a Database copied from my SQL 2005 data folder and tried to attach it in 2008 R2..but it is showing errior 
&quot;the DB you r trying to attach is not a Primary database File&quot;

While this Database gets easily attached in another SQL servr 2005 edition..]]></description>
		<content:encoded><![CDATA[<p>Hello ALL.</p>
<p>I am new to SQL.</p>
<p>I got a Database copied from my SQL 2005 data folder and tried to attach it in 2008 R2..but it is showing errior<br />
&#8220;the DB you r trying to attach is not a Primary database File&#8221;</p>
<p>While this Database gets easily attached in another SQL servr 2005 edition..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ana</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-102024</link>
		<dc:creator><![CDATA[ana]]></dc:creator>
		<pubDate>Thu, 25 Nov 2010 12:26:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-102024</guid>
		<description><![CDATA[Hi...
I detached my database and then it does not exist on my computer.Is it deleted on detach? How can I access to my detached file?
Thanks]]></description>
		<content:encoded><![CDATA[<p>Hi&#8230;<br />
I detached my database and then it does not exist on my computer.Is it deleted on detach? How can I access to my detached file?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ssysadmin</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-83650</link>
		<dc:creator><![CDATA[ssysadmin]]></dc:creator>
		<pubDate>Tue, 10 Aug 2010 22:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-83650</guid>
		<description><![CDATA[Can you help me to attach databases in bulk, i.e. if there are 100 databases and I’m needed to migrate in bulk to other server through script?
Currently I hosted databases on SQL Server 2005 SP2 x64 bit. I&#039;m planning to upgrade my database server to SQL Server 2008 R2 x64, and it&#039;s not supported to upgrade SQL Server 2008 R2 X64 from SQL Server 2005 x64 SP2 (according to http://msdn.microsoft.com/en-us/library/ms143393.aspx).

what is your suggestion?
I am planning to install new version of SQL Server 2008 Rs x64 and migrate all databases to new instance, that is why I am looking for script for attaching SQL Server in bulk.

Thank you.]]></description>
		<content:encoded><![CDATA[<p>Can you help me to attach databases in bulk, i.e. if there are 100 databases and I’m needed to migrate in bulk to other server through script?<br />
Currently I hosted databases on SQL Server 2005 SP2 x64 bit. I&#8217;m planning to upgrade my database server to SQL Server 2008 R2 x64, and it&#8217;s not supported to upgrade SQL Server 2008 R2 X64 from SQL Server 2005 x64 SP2 (according to <a href="http://msdn.microsoft.com/en-us/library/ms143393.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms143393.aspx</a>).</p>
<p>what is your suggestion?<br />
I am planning to install new version of SQL Server 2008 Rs x64 and migrate all databases to new instance, that is why I am looking for script for attaching SQL Server in bulk.</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ssysadmin</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-83648</link>
		<dc:creator><![CDATA[ssysadmin]]></dc:creator>
		<pubDate>Tue, 10 Aug 2010 22:19:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-83648</guid>
		<description><![CDATA[Can you help me to attach databases in bulk, i.e. if there are 100 databases and I&#039;m needed to migrate in bulk to other server through script?
Thank you]]></description>
		<content:encoded><![CDATA[<p>Can you help me to attach databases in bulk, i.e. if there are 100 databases and I&#8217;m needed to migrate in bulk to other server through script?<br />
Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhishek</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-73227</link>
		<dc:creator><![CDATA[Abhishek]]></dc:creator>
		<pubDate>Wed, 26 May 2010 16:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-73227</guid>
		<description><![CDATA[I ran into similar problem when I was working with ASP.NET Dynamic Data Website. When I tried to attach database into App_Data folder in Visual Studio, I used to get an error &quot;The file cannot be opened as it is used by another program.Please close all applications that might access this file and try again.&quot; 

After lot of research I realized that my database file was attached to SQL Server and in order to add it to Visual studio, I had to detach the database file from SQL Server.

I ran the script to detach the database file as described in this article :

USE [master]
GO
EXEC master.dbo.sp_detach_db @dbname = &#039;&#039; @keepfulltextindexfile = &#039;true&#039;
GO

And Whoaaaa ... I was able to add database file to App_Data folder in Visual Studio!!!

Thank you.]]></description>
		<content:encoded><![CDATA[<p>I ran into similar problem when I was working with ASP.NET Dynamic Data Website. When I tried to attach database into App_Data folder in Visual Studio, I used to get an error &#8220;The file cannot be opened as it is used by another program.Please close all applications that might access this file and try again.&#8221; </p>
<p>After lot of research I realized that my database file was attached to SQL Server and in order to add it to Visual studio, I had to detach the database file from SQL Server.</p>
<p>I ran the script to detach the database file as described in this article :</p>
<p>USE [master]<br />
GO<br />
EXEC master.dbo.sp_detach_db @dbname = &#8221; @keepfulltextindexfile = &#8216;true&#8217;<br />
GO</p>
<p>And Whoaaaa &#8230; I was able to add database file to App_Data folder in Visual Studio!!!</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DeVBand</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-65137</link>
		<dc:creator><![CDATA[DeVBand]]></dc:creator>
		<pubDate>Tue, 13 Apr 2010 21:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-65137</guid>
		<description><![CDATA[Nice code very helpful !!

thanks !]]></description>
		<content:encoded><![CDATA[<p>Nice code very helpful !!</p>
<p>thanks !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sandrar</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-55772</link>
		<dc:creator><![CDATA[sandrar]]></dc:creator>
		<pubDate>Thu, 10 Sep 2009 13:11:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-55772</guid>
		<description><![CDATA[Hi! I was surfing and found your blog post... nice! I love your blog.  :) Cheers! Sandra. R.]]></description>
		<content:encoded><![CDATA[<p>Hi! I was surfing and found your blog post&#8230; nice! I love your blog.  :) Cheers! Sandra. R.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: VS</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52913</link>
		<dc:creator><![CDATA[VS]]></dc:creator>
		<pubDate>Wed, 10 Jun 2009 17:41:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52913</guid>
		<description><![CDATA[I can find no information on @keepfulltextindexfile parameter for dbcc detachdb. I want to see what happens when this is set to false.  I want to be sure that all ft indexing is removed so there will be no confusion with the newly attached db when I rebuild the ft catalog.

Any info you can provide will be immensely helpful. 

vs]]></description>
		<content:encoded><![CDATA[<p>I can find no information on @keepfulltextindexfile parameter for dbcc detachdb. I want to see what happens when this is set to false.  I want to be sure that all ft indexing is removed so there will be no confusion with the newly attached db when I rebuild the ft catalog.</p>
<p>Any info you can provide will be immensely helpful. </p>
<p>vs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52282</link>
		<dc:creator><![CDATA[Imran Mohammed]]></dc:creator>
		<pubDate>Sat, 23 May 2009 22:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52282</guid>
		<description><![CDATA[@Biyani, 

Please post your question once. 

Reponse to your question :

Are you trying to attach  SQL Server 2005 database files on SQL Server 2000 ? If that is the case then you cannot attach those files. 

Please provide, version details you are trying to restore On.

~IM.]]></description>
		<content:encoded><![CDATA[<p>@Biyani, </p>
<p>Please post your question once. </p>
<p>Reponse to your question :</p>
<p>Are you trying to attach  SQL Server 2005 database files on SQL Server 2000 ? If that is the case then you cannot attach those files. </p>
<p>Please provide, version details you are trying to restore On.</p>
<p>~IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kshitij Biyani</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52268</link>
		<dc:creator><![CDATA[Kshitij Biyani]]></dc:creator>
		<pubDate>Sat, 23 May 2009 16:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52268</guid>
		<description><![CDATA[Kindly Help me to sort this error which is comming while attaching my database

TITLE: Microsoft SQL Server Management Studio Express
------------------------------

Attach database failed for Server &#039;KPS-980B2490DB6&#039;.  (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;ProdVer=9.00.2047.00&amp;EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&amp;EvtID=Attach+database+Server&amp;LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

------------------------------

Could not find row in sysindexes for database ID 14, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database &#039;db_Swapan&#039;. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;EvtSrc=MSSQLServer&amp;EvtID=602&amp;LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------]]></description>
		<content:encoded><![CDATA[<p>Kindly Help me to sort this error which is comming while attaching my database</p>
<p>TITLE: Microsoft SQL Server Management Studio Express<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Attach database failed for Server &#8216;KPS-980B2490DB6&#8242;.  (Microsoft.SqlServer.Express.Smo)</p>
<p>For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;ProdVer=9.00.2047.00&#038;EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&#038;EvtID=Attach+database+Server&#038;LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;ProdVer=9.00.2047.00&#038;EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&#038;EvtID=Attach+database+Server&#038;LinkId=20476</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ADDITIONAL INFORMATION:</p>
<p>An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Could not find row in sysindexes for database ID 14, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.<br />
Could not open new database &#8216;db_Swapan&#8217;. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)</p>
<p>For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;EvtSrc=MSSQLServer&#038;EvtID=602&#038;LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;EvtSrc=MSSQLServer&#038;EvtID=602&#038;LinkId=20476</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
BUTTONS:</p>
<p>OK<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kshitij Biyani</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52267</link>
		<dc:creator><![CDATA[Kshitij Biyani]]></dc:creator>
		<pubDate>Sat, 23 May 2009 16:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-52267</guid>
		<description><![CDATA[Hi
I am trying to attach my database to my pc which I made in my trainning but an error is comming Kindly Help :-
TITLE: Microsoft SQL Server Management Studio Express
------------------------------

Attach database failed for Server &#039;KPS-980B2490DB6&#039;.  (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;ProdVer=9.00.2047.00&amp;EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&amp;EvtID=Attach+database+Server&amp;LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

------------------------------

Could not find row in sysindexes for database ID 14, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database &#039;db_Swapan&#039;. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;EvtSrc=MSSQLServer&amp;EvtID=602&amp;LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------]]></description>
		<content:encoded><![CDATA[<p>Hi<br />
I am trying to attach my database to my pc which I made in my trainning but an error is comming Kindly Help :-<br />
TITLE: Microsoft SQL Server Management Studio Express<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Attach database failed for Server &#8216;KPS-980B2490DB6&#8242;.  (Microsoft.SqlServer.Express.Smo)</p>
<p>For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;ProdVer=9.00.2047.00&#038;EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&#038;EvtID=Attach+database+Server&#038;LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;ProdVer=9.00.2047.00&#038;EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&#038;EvtID=Attach+database+Server&#038;LinkId=20476</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
ADDITIONAL INFORMATION:</p>
<p>An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Could not find row in sysindexes for database ID 14, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.<br />
Could not open new database &#8216;db_Swapan&#8217;. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)</p>
<p>For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;EvtSrc=MSSQLServer&#038;EvtID=602&#038;LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&#038;EvtSrc=MSSQLServer&#038;EvtID=602&#038;LinkId=20476</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
BUTTONS:</p>
<p>OK<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-51219</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Wed, 22 Apr 2009 19:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-51219</guid>
		<description><![CDATA[Pinal - this is *exactly* what I needed and was looking for - always find great SQL tips and code on your site, thanks for all you do.]]></description>
		<content:encoded><![CDATA[<p>Pinal &#8211; this is *exactly* what I needed and was looking for &#8211; always find great SQL tips and code on your site, thanks for all you do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-47242</link>
		<dc:creator><![CDATA[SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:10:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-47242</guid>
		<description><![CDATA[[...] SQL SERVER - 2005 - T-SQL Script to Attach and Detach Database [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; 2005 &#8211; T-SQL Script to Attach and Detach Database [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nag</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-45069</link>
		<dc:creator><![CDATA[Nag]]></dc:creator>
		<pubDate>Wed, 24 Dec 2008 23:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-45069</guid>
		<description><![CDATA[Helped me immensely for coming over issues with login after detaching a default DB of windows user. Alter login didn&#039;t worked that time.]]></description>
		<content:encoded><![CDATA[<p>Helped me immensely for coming over issues with login after detaching a default DB of windows user. Alter login didn&#8217;t worked that time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Katie</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-43224</link>
		<dc:creator><![CDATA[Katie]]></dc:creator>
		<pubDate>Wed, 24 Sep 2008 20:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-43224</guid>
		<description><![CDATA[I used sp_attach like this and get the Msg 1813:

USE [master]
GO
sp_attach_db @dbname = N&#039;TestDB&#039;,
 @FILENAME1 = N&#039;C:\Data\TestDB.mdf&#039; ,
 @FILENAME2 = N&#039;C:\Data\TestDB_1.ldf&#039; 

What did I miss?]]></description>
		<content:encoded><![CDATA[<p>I used sp_attach like this and get the Msg 1813:</p>
<p>USE [master]<br />
GO<br />
sp_attach_db @dbname = N&#8217;TestDB&#8217;,<br />
 @FILENAME1 = N&#8217;C:\Data\TestDB.mdf&#8217; ,<br />
 @FILENAME2 = N&#8217;C:\Data\TestDB_1.ldf&#8217; </p>
<p>What did I miss?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-41970</link>
		<dc:creator><![CDATA[Imran Mohammed]]></dc:creator>
		<pubDate>Sun, 24 Aug 2008 05:49:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-41970</guid>
		<description><![CDATA[@Larry, 

Chill Man !!!

I guess, this is what you did ?

1. You executed detached database statement ( sp_detach_db) on server1 and then 
2. You logged in to Server2 ( different machine) and 
3. There you are trying to attach the database by executing this statement ( sp_attach_db).

But my dear, you have also have to manually move those .mdf and .ldf files from old server to new server. 

And while using sp_attach_db stored procedures, give the new location of these files ( where ever you moved it to, ex: D:\program files\ microsoft sql server\.........)

Once you move ( copy those .mdf and .ldf files)to new server then use sp_attach_db with the new location ( on new server).

You should be able to attach it.

If you cannot do it through sql commands, let me know I will try to post screen shots for the same using interfaces.

Hope this helps,
Imran.]]></description>
		<content:encoded><![CDATA[<p>@Larry, </p>
<p>Chill Man !!!</p>
<p>I guess, this is what you did ?</p>
<p>1. You executed detached database statement ( sp_detach_db) on server1 and then<br />
2. You logged in to Server2 ( different machine) and<br />
3. There you are trying to attach the database by executing this statement ( sp_attach_db).</p>
<p>But my dear, you have also have to manually move those .mdf and .ldf files from old server to new server. </p>
<p>And while using sp_attach_db stored procedures, give the new location of these files ( where ever you moved it to, ex: D:\program files\ microsoft sql server\&#8230;&#8230;&#8230;)</p>
<p>Once you move ( copy those .mdf and .ldf files)to new server then use sp_attach_db with the new location ( on new server).</p>
<p>You should be able to attach it.</p>
<p>If you cannot do it through sql commands, let me know I will try to post screen shots for the same using interfaces.</p>
<p>Hope this helps,<br />
Imran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Larry</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-41964</link>
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Sun, 24 Aug 2008 01:30:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-41964</guid>
		<description><![CDATA[Apparently no one in this uinverse knows how to do this. On the same server, yes it work, but move to other server and you get: Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘AdventureWorks’. CREATE DATABASE is aborted.
Msg 602, Level 21, State 50, Line 1
Could not find row in sysindexes for database ID 19, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.]]></description>
		<content:encoded><![CDATA[<p>Apparently no one in this uinverse knows how to do this. On the same server, yes it work, but move to other server and you get: Msg 1813, Level 16, State 2, Line 1<br />
Could not open new database ‘AdventureWorks’. CREATE DATABASE is aborted.<br />
Msg 602, Level 21, State 50, Line 1<br />
Could not find row in sysindexes for database ID 19, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danny</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-41404</link>
		<dc:creator><![CDATA[Danny]]></dc:creator>
		<pubDate>Wed, 06 Aug 2008 20:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-41404</guid>
		<description><![CDATA[Worked flawlessly, thanks for the script!]]></description>
		<content:encoded><![CDATA[<p>Worked flawlessly, thanks for the script!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali.Net</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-38802</link>
		<dc:creator><![CDATA[Ali.Net]]></dc:creator>
		<pubDate>Mon, 26 May 2008 16:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-38802</guid>
		<description><![CDATA[Hi,
This topic is very useful
Thank&#039;s]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
This topic is very useful<br />
Thank&#8217;s</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shamshad</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-37112</link>
		<dc:creator><![CDATA[Shamshad]]></dc:creator>
		<pubDate>Tue, 06 May 2008 19:07:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-37112</guid>
		<description><![CDATA[Attach db query not working at all !!!
Do i have to create a new db and then run this attach query?


Msg 1813, Level 16, State 2, Line 1
Could not open new database &#039;AdventureWorks&#039;. CREATE DATABASE is aborted.
Msg 602, Level 21, State 50, Line 1
Could not find row in sysindexes for database ID 19, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.]]></description>
		<content:encoded><![CDATA[<p>Attach db query not working at all !!!<br />
Do i have to create a new db and then run this attach query?</p>
<p>Msg 1813, Level 16, State 2, Line 1<br />
Could not open new database &#8216;AdventureWorks&#8217;. CREATE DATABASE is aborted.<br />
Msg 602, Level 21, State 50, Line 1<br />
Could not find row in sysindexes for database ID 19, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lyn</title>
		<link>http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-34946</link>
		<dc:creator><![CDATA[Lyn]]></dc:creator>
		<pubDate>Wed, 09 Apr 2008 14:58:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/08/24/sql-server-2005-t-sql-script-to-attach-and-detach-database/#comment-34946</guid>
		<description><![CDATA[Hi Pinal,

I noticed that when a database is re-attached, it&#039;s creation_date is updated to the date of attachment. Is there any way to change this?

Thanks
Lyn]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I noticed that when a database is re-attached, it&#8217;s creation_date is updated to the date of attachment. Is there any way to change this?</p>
<p>Thanks<br />
Lyn</p>
]]></content:encoded>
	</item>
</channel>
</rss>

