<?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>MSSQL &#8211; Phocean.net</title>
	<atom:link href="/tag/mssql/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Computer Security Blog</description>
	<lastBuildDate>Fri, 24 Feb 2017 21:17:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.10</generator>
	<item>
		<title>Restoring a MSSQL 2000/2005 database while in production</title>
		<link>/2007/03/03/restoring-a-mssql-20002005-database-while-in-production.html</link>
		<pubDate>Sat, 03 Mar 2007 19:02:00 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://192.168.1.10/wordpress/?p=23</guid>
		<description><![CDATA[<p>At my work, I had to overwrite a MSSQL database while in production. The goal was to replace the existing database by one with a new structure.</p> <p>I tried first the easy way, right clicking on it and trying to take it off line using the menu of Microsoft. </p> Unfortunately, that didn't do anything, complaining that several users were accessing it. Of course, trying to restore it directly gave the same message. <br /><br />I couldn't find a way to successfully force it through the interface.<br />]]></description>
				<content:encoded><![CDATA[<p>At my work, I had to overwrite a MSSQL database while in production. The goal was to replace the existing database by one with a new structure.</p>
<p>I tried first the easy way, right clicking on it and trying to take it off line using the menu of Microsoft.</p>
<p>Unfortunately, that didn&#8217;t do anything, complaining that several users were accessing it. Of course, trying to restore it directly gave the same message.</p>
<p>I couldn&#8217;t find a way to successfully force it through the interface.<br />
<span id="more-23"></span></p>
<p>It was, of course, a multiuser database on which always an user was working on, making it impossible to overwrite it.</p>
<p>So, at this point, I had to consider using the SQL query tool, to enjoy the power of a command line interface (you see what I mean).</p>
<p>Below is the kind of request I submited :</p>
<pre>use master;
alter database $your_database set single_user with rollback immediate;
backup database $your_database to disk = 'C:\$your_database.bak' with init,Name = 'backup';
restore database $your_database from disk = 'C:\path\to\your\DB\$your_new_database.bak' with replace,file=1,recovery
alter database Datasharing_Translation set multi_user with rollback immediate;</pre>
<p>It switches the database to the single user mode, make a backup of it (for safety), make the restoring operation, and finally switches it back to the multi user mode.</p>
<p><img src="/wp-content/uploads/2007/05/public/mssql_query_tool.png" alt="" width="320" height="229" /><br />
Once again the day is saved by a command line tool !  ;)</p>
]]></content:encoded>
			</item>
	</channel>
</rss>
