﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Hardik Doshi  / Create Database / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Mon, 20 May 2013 16:01:02 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>nice question.... new thing is added in my knowledgemanik*******</description><pubDate>Tue, 29 Jan 2013 08:12:14 GMT</pubDate><dc:creator>manik123</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>+1 :-)</description><pubDate>Sat, 06 Oct 2012 07:29:50 GMT</pubDate><dc:creator>kapil_kk</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Got it right.</description><pubDate>Wed, 08 Aug 2012 12:19:21 GMT</pubDate><dc:creator>Neha05</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Why don't you remove a question or clarify it when it is clearly wrong and both answers are working.I have tested it on my SQL Server and the "wrong" option works fine.Soren</description><pubDate>Tue, 31 Jul 2012 22:34:56 GMT</pubDate><dc:creator>nerosdk71</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Like those who commented earlier, I think both options work (provided there was a clean shutdown).  I picked the second because although I knew the first optioopn would also work I guessed that the question's author didn't.</description><pubDate>Wed, 18 Jul 2012 11:24:53 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Thanks for the question.I agree that both options may be correct, depending if the database was shut down cleanly AND only one log file existed for the database file. BOL specifies:- "If multiple log files exist, they must all be available." and- "If a read/write database has a single log file that is currently unavailable, and if the database was shut down with no users or open transactions before the attach operation, FOR ATTACH automatically rebuilds the log file and updates the primary file."in the FOR_ATTACH option."El" Jerry.</description><pubDate>Fri, 22 Jun 2012 08:50:33 GMT</pubDate><dc:creator>EL Jerry</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>A simple one for me thank you very much.</description><pubDate>Fri, 22 Jun 2012 01:46:33 GMT</pubDate><dc:creator>kapfundestanley</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Pretty easy if you had to attach the AdventureWorks MDF files multiple times :-D</description><pubDate>Thu, 21 Jun 2012 14:20:28 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>BOL citation:FOR ATTACH [ WITH &amp;lt; attach_database_option &amp;gt; ]    Specifies that the database is created by attaching an existing set of operating system files. There must be a &amp;lt;filespec&amp;gt; entry that specifies the primary file. The only other &amp;lt;filespec&amp;gt; entries required are those for any files that have a different path from when the database was first created or last attached. A &amp;lt;filespec&amp;gt; entry must be specified for these files.    FOR ATTACH requires the following:        All data files (MDF and NDF) must be available.        If multiple log files exist, they must all be available.   [highlight=#ffff11] If a read/write database has a single log file that is currently unavailable, and if the database was shut down with no users or open transactions before the attach operation, FOR ATTACH automatically rebuilds the log file and updates the primary file. [/highlight]In contrast, for a read-only database, the log cannot be rebuilt because the primary file cannot be updated. Therefore, when you attach a read-only database with a log that is unavailable, you must provide the log files, or the files in the FOR ATTACH clause.</description><pubDate>Thu, 21 Jun 2012 14:11:18 GMT</pubDate><dc:creator>gchornenkyy</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Worth noting that the attach will only succeed if the database was cleanly shut down before the log was deleted. Otherwise the  attach (even with Attach_rebuild_log) will fail.</description><pubDate>Thu, 21 Jun 2012 11:14:22 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>[quote][b]SQLRNNR (6/21/2012)[/b][hr][quote][b]Thomas Abraham (6/21/2012)[/b][hr][quote][b]tommyh (6/21/2012)[/b]Works just fine to attach a database with just "for attach" with only one log file. /T[/quote]I figured it would. But it's nice to have it confirmed. (Yes, I don't always trust BOL.) Thanks for the effort![/quote]I have used the For Attach method several times as well.[/quote]I've done this as well without the log file for various reasons.</description><pubDate>Thu, 21 Jun 2012 09:38:23 GMT</pubDate><dc:creator>sestell1</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Answered off the cuff believing that FOR ATTACH rebuilds the log.  Thanks tommyh for confirming...  Missed the earlier postCheers</description><pubDate>Thu, 21 Jun 2012 08:29:29 GMT</pubDate><dc:creator>OzYbOi d(-_-)b</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>[quote][b]Thomas Abraham (6/21/2012)[/b][hr][quote][b]tommyh (6/21/2012)[/b]Works just fine to attach a database with just "for attach" with only one log file. /T[/quote]I figured it would. But it's nice to have it confirmed. (Yes, I don't always trust BOL.) Thanks for the effort![/quote]I have used the For Attach method several times as well.</description><pubDate>Thu, 21 Jun 2012 07:51:46 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>[quote][b]tommyh (6/21/2012)[/b]Works just fine to attach a database with just "for attach" with only one log file. /T[/quote]I figured it would. But it's nice to have it confirmed. (Yes, I don't always trust BOL.) Thanks for the effort!</description><pubDate>Thu, 21 Jun 2012 07:25:47 GMT</pubDate><dc:creator>Thomas Abraham</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>[quote][b]Thomas Abraham (6/21/2012)[/b][hr][quote][b]David P Fisher (6/21/2012)[/b][hr][quote][b]ipounder (6/21/2012)[/b][hr]Seems to me that both answers can be correct.Ian[/quote]I agree :-)[/quote]Anybody care to test it? :-)Thanks for the question.BTW, love the cat with the mice crawling over it.[/quote]Works just fine to attach a database with just "for attach" with only one log file. /T</description><pubDate>Thu, 21 Jun 2012 07:03:09 GMT</pubDate><dc:creator>tommyh</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>[quote][b]David P Fisher (6/21/2012)[/b][hr][quote][b]ipounder (6/21/2012)[/b][hr]Seems to me that both answers can be correct.Ian[/quote]I agree :-)[/quote]Anybody care to test it? :-)Thanks for the question.BTW, love the cat with the mice crawling over it.</description><pubDate>Thu, 21 Jun 2012 06:23:11 GMT</pubDate><dc:creator>Thomas Abraham</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>[quote][b]ipounder (6/21/2012)[/b][hr]Seems to me that both answers can be correct.Ian[/quote]I agree :-)</description><pubDate>Thu, 21 Jun 2012 03:27:19 GMT</pubDate><dc:creator>David P Fisher</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Ok, I got it wrong after reading the books online specifically on that subject. I agree, with single log file, both answers are correct.</description><pubDate>Thu, 21 Jun 2012 03:15:14 GMT</pubDate><dc:creator>Jakub.Janda</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>I did divine the correct answer, however I would agree with 'Just a number' that both options would work.</description><pubDate>Thu, 21 Jun 2012 03:03:24 GMT</pubDate><dc:creator>call.copse</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Got it right, seemed an easy guess :-)But when I then did a bit of research, it appears that FOR ATTACH will also work if the database had a single log file.</description><pubDate>Thu, 21 Jun 2012 03:02:20 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Seems to me that both answers can be correct.Ian</description><pubDate>Thu, 21 Jun 2012 03:01:30 GMT</pubDate><dc:creator>ipounder</dc:creator></item><item><title>RE: Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Am I reading this right?FOR ATTACH[quote]FOR ATTACH [ WITH &amp;lt; attach_database_option &amp;gt; ] Specifies that the database is created by attaching an existing set of operating system files. There must be a &amp;lt;filespec&amp;gt; entry that specifies the primary file. The only other &amp;lt;filespec&amp;gt; entries required are those for any files that have a different path from when the database was first created or last attached. A &amp;lt;filespec&amp;gt; entry must be specified for these files. FOR ATTACH requires the following: All data files (MDF and NDF) must be available.If multiple log files exist, they must all be available.If a read/write database has a single log file that is currently unavailable, and if the database was shut down with no users or open transactions before the attach operation, FOR ATTACH automatically rebuilds the log file and updates the primary file. In contrast, for a read-only database, the log cannot be rebuilt because the primary file cannot be updated. Therefore, when you attach a read-only database with a log that is unavailable, you must provide the log files, or the files in the FOR ATTACH clause. [/quote]Given the assumtions in the question, I think both answers are correct.</description><pubDate>Thu, 21 Jun 2012 01:00:16 GMT</pubDate><dc:creator>440692 I am just a number</dc:creator></item><item><title>Create Database</title><link>http://www.sqlservercentral.com/Forums/Topic1319073-2833-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/create+database/91009/"&gt;Create Database&lt;/A&gt;[/B]</description><pubDate>Wed, 20 Jun 2012 22:30:01 GMT</pubDate><dc:creator>Hardy21</dc:creator></item></channel></rss>