<p><strong>Step 1</strong></p>
<p>Run FogBugz Setup. Choose SQL Server as the database option. 
When Setup has finished, it launches a web page and 
asks you to install licenses. Don't install the licenses yet - it's okay if you already did, but you just don't need to. Just minimize this browser, we'll come back to it later. </p>
<p>&nbsp;&nbsp;&nbsp;<img src="http://www.fogcreek.com/FogBugz/kb/dbsetup/images/1.gif" /></p>
<p><strong>Don't install licenses yet! (it's ok if you already did)</strong></p>
<p><strong>Step 2</strong></p>
<p>In another browser window, log into your hosted account as a Site Administrator.  Click Admin at the top right, then "Your On Demand Account", and click the download link for "SQL 
Server 2000". FogBugz will warn you that during the database copy, the site will be down. Make sure nobody needs to use FogBugz and then click "Begin Copy"</p>
<p>After the copy is complete, click the Download button that appears to download your MDF data file (it will be named something like fogbugz72040459_copy.MDF), and save it to the folder that MS SQL Server likes to keep data files, which is normally:
</p>
<p><pre>C:\Program Files\Microsoft SQL Server\MSSQL\Data</pre><p></p>
<p><em>Make sure this 
file is not read-only.</em></p>
<p>At this point, your FogBugz On Demand account is still locked for the download. On the page you downloaded from, either enter a URL for a new site to link to, or click the link next to "Go back" to reactivate the site if you need to keep using it.</p>
<p><strong>Step 3</strong></p>
<p>Run SQL Server Management Studio and connect to your database server. Drill down to the empty database named 
<strong>FogBugz</strong> that was created by Setup. Select it and 
press the <strong>Delete</strong> key to delete it.</p>
<p>&nbsp;&nbsp;&nbsp;<img src="http://our.fogbugz.com/default.asp?pg=pgDownload&pgType=pgWikiAttachment&ixAttachment=78717&sFileName=deletedb.png" alt="" /></p>
<p><strong>Step 4</strong></p>
<p>Right click the <strong>Databases</strong> item and choose 
<strong>Attach...</strong></p>
<p>&nbsp;&nbsp;&nbsp;<img src="http://our.fogbugz.com/default.asp?pg=pgDownload&pgType=pgWikiAttachment&ixAttachment=78718&sFileName=attach.png" alt="" /></p>
<p>
In the dialog which appears, click the 
<strong>"Add..."</strong> button and select the MDF file you just 
downloaded. The dialog will now look like this. Click the second entry in the bottom pane, which has File Type "Log" and click the Remove button:</p>
<p>&nbsp;&nbsp;&nbsp;<img src="http://our.fogbugz.com/default.asp?pg=pgDownload&pgType=pgWikiAttachment&ixAttachment=78720&sFileName=attach2.png" alt="" /></p>
<p>In the top pane, click on the Owner field, then click again to bring up the menu. Select the same user you told setup to run FogBugz as. If you told Setup to use Windows/Mixed Mode authentication to connect to the database, this user is the same one you see for Anonymous Authentication in the FogBugz virtual directory. If you told Setup to connect to the database using a SQL Server login (name and password), then specify that login here. Click <strong>OK</strong>. </p>
<p>&nbsp;&nbsp;&nbsp;<img src="http://our.fogbugz.com/default.asp?pg=pgDownload&pgType=pgWikiAttachment&ixAttachment=78719&sFileName=attach3.png" alt="" /></p>
<p><strong>Step 5</strong></p>
<p><em>Update on 9/12/05: </em>There is currently an issue with downloading SQL Server databases from On Demand where occasionally the database you download is missing default values which are needed. So take a moment to check your database: open SQL Server Management Studio, expand <strong>FogBugz -> Tables</strong> in the left pane, right-click on dbo.Bug and select "Design..." Find fForwarded and fReplied. Click on each and look at the value for "Default Value or Binding" in the pane below. It should be "(0)" as shown here:</p>
<p>&nbsp;&nbsp;&nbsp;<img src="http://our.fogbugz.com/default.asp?pg=pgDownload&pgType=pgWikiAttachment&ixAttachment=78723&sFileName=defaultvalue.png" alt="" /></p>
<p>If it does not, if the default is blank, you will simply need to download the database again and check the one you download in the same way. &nbsp;</p>
<p><strong>Step 6</strong></p>
<p>Bring up FogBugz in your web browser and refresh the page. If at this point you get 
an error message, please re-read the above steps and verify that 
you didn't do something ever so slightly differently. Install your licenses, set 
your options, and log on using a name and password from your hosted account. Presto magicko, you should see all the 
data you created on our server like so many eggs in a 
basket! </p>
<p>Your data is now all there. </p>
<p><strong>Step 7</strong></p>
<p>Re-install your plugins per <a href="http://fogbugz.stackexchange.com/questions/1121/my-plugins-are-broken-after-importing-my-on-demand-database-locally">this question</a>.</p>