<?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>nPath Ltd. &#187; SQL server</title>
	<atom:link href="http://www.npathweb.com/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.npathweb.com</link>
	<description>Web Development Blog</description>
	<lastBuildDate>Mon, 22 Feb 2010 15:16:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Search your entire server for a string across all databases! MSSql 2000</title>
		<link>http://www.npathweb.com/2009/10/09/search-your-entire-server-for-a-string-across-all-databases-mssql-2000/</link>
		<comments>http://www.npathweb.com/2009/10/09/search-your-entire-server-for-a-string-across-all-databases-mssql-2000/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 21:39:42 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/?p=94</guid>
		<description><![CDATA[You can use this query to search your entire server for a string. It will search views, stored procs, triggers, everything.
All the sql text in your database is stored in system tables under each database. There are a few hardships to overcome in order to search.
1.) Text is split into 4000 character chunks. So every [...]]]></description>
			<content:encoded><![CDATA[<p>You can use this query to search your entire server for a string. It will search views, stored procs, triggers, everything.</p>
<p>All the sql text in your database is stored in system tables under each database. There are a few hardships to overcome in order to search.</p>
<p>1.) Text is split into 4000 character chunks. So every 4k chunk has a colID to note its position in the stack of rows .  The names are stored in sysobjects and the text is stored in syscomments. The issue is when your search hits in the second chunk. You need to pull in all chunks when any one finds a hit.</p>
<p>2.) Each database has it&#8217;s own system tables. For one search to check every database&#8217;s syscomments you need to loop. My example solution didn&#8217;t use a cursor.</p>
<p>I pulled a list of database names out of master.dbo.sysdatabases and put it in a temp table. That is what I used for my loop. I  just jet the top row, work it, delete it, and get the next one from the top.</p>
<p>In the loop I execute sql constructed dynamically based on the database name of in the current loop iteration. It searches for all object Ids that have text matching the search term. Then gets all chucks for that object.  To help me narrow down the search I also search on object type. V for view, p for proc  etc&#8230;Leave type &#8221; to get all types.</p>
<p>If you paste this in your query window and set the search strings you should get results.  I clipped the text to 3990 because I kept getting errors that the row was too large. I should probably look into it but this will do for now.</p>
<p>I&#8217;m dealing with MSSql Server 2000 here and this works.  I plan to make this a stored proc and call it from asp but right now it&#8217;s 5:00pm on Friday and this can wait &#8217;till Monday.</p>
<p><!--</p>
<p>p.MsoNormal<br />
{margin-top:0in;<br />
margin-right:0in;<br />
margin-bottom:10.0pt;<br />
margin-left:0in;<br />
line-height:115%;<br />
font-size:11.0pt;<br />
font-family:"Calibri","sans-serif";<br />
}<br />
--></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">Create</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> <span style="color:blue">Table</span> #dblist<span style="color:blue"> </span><span style="color:gray">(</span>NAME <span style="color:blue">VARCHAR</span><span style="color:gray">(</span>80<span style="color:gray">))</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">create</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="color:blue">table</span> #results<span style="color:blue"> </span><span style="color:gray">(</span>name <span style="color:blue">nvarchar</span><span style="color:gray">(</span>80<span style="color:gray">),</span><span style="color:blue">text</span> <span style="color:blue">varchar</span><span style="color:gray">(</span>4000<span style="color:gray">))</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:gray;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">insert</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> <span style="color:blue">into</span> #dblist</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">exec</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:gray;mso-no-proof:yes">(</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:red;mso-no-proof:yes">&#8217;select         name from master..sysdatabases order by name&#8217;</span><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:gray;mso-no-proof:yes">)</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:gray;mso-no-proof:yes"><br />
</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">declare</span><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes"> @ObjectType <span style="color:blue">as</span> <span style="color:blue">nvarchar</span><span style="color:gray">(</span>80<span style="color:gray">)<br />
</span>declare</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> @search <span style="color:blue">as</span> <span style="color:blue">nvarchar</span><span style="color:gray">(</span>80<span style="color:gray">)</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:gray;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">set</span><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes"> @search <span style="color:gray">=</span> <span style="color:red">&#8216;update&#8217; &#8211;change this</span><br />
set</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> @ObjectType<span style="color:gray">=</span><span style="color:red">&#8216;p&#8217;  &#8211;searches only procedures</span><br />
<span style="color:green">&#8211;set to &#8221; for all types</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">declare</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> @dbname <span style="color:blue">as</span> <span style="color:blue">nvarchar</span><span style="color:gray">(</span>80<span style="color:gray">)</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">set</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> @dbname<span style="color:gray">=</span><span style="color:blue"> </span><span style="color:gray">(</span><span style="color:blue">select</span> <span style="color:blue">top</span> 1 name <span style="color:blue">from</span> #dblist<span style="color:gray">)</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">while</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> @dbname<span style="color:gray">&lt;&gt;</span><span style="color:red">&#8221;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-tab-count: 1"> </span><span style="color:blue">begin</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="color:blue">insert</span> <span style="color:blue">into</span> #results<span style="mso-tab-count: 3"><br />
</span><span style="color:blue">exec</span><span style="mso-tab-count: 4">(<br />
</span><span style="color:red">&#8217;select id &#8216;</span> <span style="color:gray">+</span><span style="color:red"><br />
&#8216;into #found &#8216;</span> <span style="mso-tab-count: 4">+<br />
</span><span style="color:red">&#8216;from ['</span><span style="color:gray">+</span>@dbname<span style="color:gray">+</span><span style="color:red">']..syscomments &#8216;</span><span style="mso-tab-count: 4">+<br />
</span><span style="color:red">&#8216;where [text] like &#8221;%&#8217;</span><span style="color:gray">+</span> @search <span style="color:gray">+</span><span style="color:red">&#8216;%&#8221; &#8216;</span> <span style="color:gray">+</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-tab-count: 4"> </span><span style="color:red">&#8217;select &#8221;&#8217;</span><span style="color:gray">+</span> @dbname<span style="color:gray">+</span><span style="color:red">&#8216;:&#8221; + so.name         as name, left(sc.text, 3990) &#8216; +<br />
&#8216;from ['</span> <span style="color:gray">+</span></span><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> @dbname <span style="color:gray">+</span><span style="color:red"> ']..syscomments sc &#8216;</span> <span style="color:gray">+</span><span style="mso-tab-count: 4"><br />
</span><span style="color:red">&#8216;inner join ['</span> <span style="color:gray">+</span> @dbname <span style="color:gray">+</span> <span style="color:red">']..sysobjects         so on sc.id= so.id &#8216;</span> <span style="color:gray">+</span><span style="mso-tab-count: 4"><br />
</span><span style="color:red">&#8216;where sc.id in (select id from #found) &#8216;</span><span style="mso-tab-count: 4">+</span><span style="color:red"><br />
&#8216;and<span style="mso-spacerun:yes"> </span> xtype like &#8221;%&#8217;</span> <span style="color:gray">+</span> @ObjectType<span style="color:gray">+</span> <span style="color:red">&#8216;%&#8221; &#8216;</span><span style="color:gray">+</span><span style="color:red"><br />
&#8216;order by name, colid &#8216;</span><span style="mso-tab-count: 4">+<br />
</span><span style="color:red">&#8216;drop table #found&#8217;</span><br />
</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="color:gray">)</span></span></p>
<p><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="color:blue">delete</span><span style="mso-spacerun:yes"> </span><span style="color:blue">from</span> #dblist <span style="color:blue"> where</span> name<span style="color:gray">=</span> @dbname</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-tab-count: 2"></span><span style="color:blue">set</span> @dbname<span style="color:gray">=</span><span style="color:blue"> </span><span style="color:gray">(</span><span style="color:blue">select</span> <span style="color:blue">top</span> 1 name <span style="color:blue">from</span> #dblist<span style="color:gray">)</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-tab-count: 1"> </span><span style="color:blue">end</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">select</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> <span style="color:gray">*</span> <span style="color:blue">from</span> #results</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">drop </span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="color:blue">table</span> #dblist</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;color:blue;mso-no-proof:yes">drop</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> <span style="color:blue">table</span> #results</span></p>
<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/10/09/search-your-entire-server-for-a-string-across-all-databases-mssql-2000/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Store an IP Address in a human-readable Int64 (bigint)</title>
		<link>http://www.npathweb.com/2009/09/29/83/</link>
		<comments>http://www.npathweb.com/2009/09/29/83/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 13:34:07 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[SQL server]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/?p=83</guid>
		<description><![CDATA[Lets say you have an  ip address in a string such as  &#8221;127.1.2.3&#8243;
This code will store the information in an int64 (C#) or bigint (SQL) in with three places per octet.
127001002003
The highest this number could go is 255,255,255,255.00 which is too large for a 32 bit integer. Hence the Int64. In SQL an 64 bit [...]]]></description>
			<content:encoded><![CDATA[<p>Lets say you have an  ip address in a string such as  &#8221;127.1.2.3&#8243;</p>
<p>This code will store the information in an int64 (C#) or bigint (SQL) in with three places per octet.</p>
<p>127001002003</p>
<p>The highest this number could go is 255,255,255,255.00 which is too large for a 32 bit integer. Hence the Int64. In SQL an 64 bit Integer is big int so that is what you&#8217;ll need to store in an MS-SQL Database.</p>
<p>I worked this up as a work-around on a project and present it here for your enjoyment.</p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-family: 'Courier New', 'Times New Roman', 'Bitstream Charter', Times, serif;"><span style="color: #0000ff;">using System.Text.RegularExpressions;<br />
</span></span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> <span style="mso-spacerun:yes"> </span><span style="color:blue">public</span> <span style="color:blue">static</span><span style="color:#2B91AF"> Int64</span> convertIP(<span style="color:blue">string</span> sAddress) {<br />
<span style="color:#2B91AF"> </span><br />
<span style="color:#2B91AF"> Match</span> ipaddress =<span style="color:#2B91AF"> Regex</span>.Match(sAddress,<span style="color:#A31515">&#8220;^([\\d]*).([\\d]*).([\\d]*).([\\d]*)&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="color:#2B91AF"> <span style="color: #2b91af;">Int64</span> iAddress = 0;</span></span></p>
<p>Int64 ip1 =<span style="color:#2B91AF">Convert</span>.ToInt64(ipaddress.Groups[1].ToString())<span style="mso-spacerun:yes"> </span>* 1000000000;<br />
<span style="color:#2B91AF"> Int64</span> ip2 =<span style="color:#2B91AF">Convert</span>.ToInt64(ipaddress.Groups[2].ToString()) * 1000000;<br />
<span style="color:#2B91AF"> Int64</span> ip3 =<span style="color:#2B91AF">Convert</span>.ToInt64(ipaddress.Groups[3].ToString()) * 1000;<br />
<span style="color:#2B91AF"> Int64</span> ip4 =<span style="color:#2B91AF">Convert</span>.ToInt64(ipaddress.Groups[4].ToString());</p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-family: 'Courier New', 'Times New Roman', 'Bitstream Charter', Times, serif; "> iAddress = ip1 + ip2 + ip3 + ip4;</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-spacerun:yes"><br />
</span><span style="color:blue">return</span> iAddress;</span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"> </span></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-size: 10.0pt;font-family:&quot;Courier New&quot;;mso-no-proof:yes"><br />
<span style="mso-spacerun:yes"> </span><br />
}</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;line-height:115%;font-family: &quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-spacerun:yes">Extra credit: This number is now 127,001,002,003. You can use string formating to display it as 127.001.002.003 by using the format string N0 (Number, zero decimal places) and changing the number group separator from the default comma to a period. All with the raw int64, no function required.</span></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;line-height:115%;font-family: &quot;Courier New&quot;;mso-no-proof:yes"><span style="mso-spacerun:yes"> </span></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;color:#2B91AF; mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA; mso-no-proof:yes">Int64</span><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language: EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA;mso-no-proof:yes"> iAddress = convertIP(Request.UserHostAddress);</span></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">Response.Write(util.convertIP(Request.UserHostAddress).ToString(&#8220;N0&#8243;, new NumberFormatInfo { NumberGroupSeparator = &#8220;.&#8221; }));</div>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height: normal;mso-layout-grid-align:none;text-autospace:none"><span style="font-family: 'Courier New', 'Times New Roman', 'Bitstream Charter', Times, serif;">Response.Write(iAddress).ToString(<span style="color:#A31515">&#8220;N0&#8243;</span>, <span style="color:blue">new </span><span style="color:#2B91AF">NumberFormatInfo</span> { NumberGroupSeparator =<span style="color:#A31515">&#8220;.&#8221;</span> }));</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/09/29/83/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Restore failed for Server ./SQLEXPRESS</title>
		<link>http://www.npathweb.com/2009/02/12/restore-failed-for-server-sqlexpress/</link>
		<comments>http://www.npathweb.com/2009/02/12/restore-failed-for-server-sqlexpress/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 16:49:02 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[SQL server]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Management Studio Express]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/?p=61</guid>
		<description><![CDATA[A wise man once told me: &#8220;The quatilty of your life is directly proportional to the quality of your backups&#8221;. I have come to respect this advice greatly. A few weeks ago my dedicated server went down. The incompitent tech support at AIT was unable to get it working again. It took them 16 days [...]]]></description>
			<content:encoded><![CDATA[<p>A wise man once told me: <em>&#8220;The quatilty of your life is directly proportional to the quality of your backups&#8221;</em>. I have come to respect this advice greatly. A few weeks ago my dedicated server went down. The incompitent tech support at AIT was unable to get it working again. It took them 16 days to decide the drive was toast. All data was lost.  Luckily I was somewhat prepared and had been genrating .bak files on a different server daily. But if a backup that can&#8217;t be restored it&#8217;s useless.  The wise man always followed his advice with <em>&#8220;always do a test restore&#8221;</em>.</p>
<p>This is where the error of today&#8217;s post comes into play.  I was restoring from a .bak file on my local machine to sql express when the following error appeared:</p>
<p><img class="alignnone size-full wp-image-64" title="restoreerror12" src="http://www.npathweb.com/wp-content/upLoads/2009/02/restoreerror12.jpg" alt="restoreerror12" width="621" height="173" /></p>
<h6>For the Search engines:<br />
Restore failed for Server &#8216;.\SQLEXPRESS&#8217;<br />
The backup set holds a backup of a database other than the existing &#8216;clientDB&#8217; database.</h6>
<p>Was my quality of life not what I once thought it was?  Hold on a minute&#8230;</p>
<p>I decided to check the options on the restore. Low and behold there were a few settings that made the restore work like a charm.<br />
First I check replace database then I made sure the filenames were in the right spot. All was right with the world. Inner peace restored.</p>
<p><img class="alignnone size-full wp-image-65" title="restoreoptions" src="http://www.npathweb.com/wp-content/upLoads/2009/02/restoreoptions.jpg" alt="restoreoptions" width="704" height="632" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/02/12/restore-failed-for-server-sqlexpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
