<?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>The Proficiency Blog</title>
	<atom:link href="http://www.proficientit.com.au/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.proficientit.com.au/blog</link>
	<description>Helpful tips by Proficient IT</description>
	<lastBuildDate>Fri, 11 Nov 2011 22:54:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>MSSQL &#8211; Simple Fuzzy String Match.</title>
		<link>http://www.proficientit.com.au/blog/?p=203</link>
		<comments>http://www.proficientit.com.au/blog/?p=203#comments</comments>
		<pubDate>Thu, 27 Oct 2011 11:18:31 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=203</guid>
		<description><![CDATA[&#160; Sometimes we need to get a little creative with our querying. Having some nice, helpful functions on hand can be a great help and a fabulous time saver. &#160;Here is one from our collection that has been useful on &#8230; <a href="http://www.proficientit.com.au/blog/?p=203">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Sometimes we need to get a little creative with our querying. Having some nice, helpful functions on hand can be a great help and a fabulous time saver. &nbsp;Here is one from our collection that has been useful on a surprising number of occasions.</p>
<p>So what does it do?</p>
<p>Basically it returns true if a certain amount of consecutive string characters contained in any part of @Str1 matches any part of @Str2. The length of the match is controlled be the&nbsp;@Precision parameter.</p>
<p>It is useful where your want to find strings that are similar but not exactly the same.</p>
<p>With a little extra code using the inbuilt TSQL function &quot;SoundEx&quot; this could easily become an extremely powerful word analyser.</p>
<p>In it&#39;s current form it could even be used to search for documents with similar phrasing.</p>
<p>Anyway, we hope you find it a useful function to add to your ever expanding TSQL tool belt.</p>
<p>Enjoy.</p>
<p>&nbsp;</p>
<p><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; "><span style="font-family: 'Courier New'; color: blue; ">SET</span><span style="font-family: 'Courier New'; ">&nbsp;<span style="color: blue; ">ANSI_NULLS</span>&nbsp;<span style="color: blue; ">ON</span></span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">GO</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">SET</span><span style="font-family: 'Courier New'; ">&nbsp;<span style="color: blue; ">QUOTED_IDENTIFIER</span>&nbsp;<span style="color: blue; ">ON</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">GO</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: green; ">&#8211; ==============================<wbr>===============</wbr></span></span></p>
<p><wbr></p>
<p><wbr></wbr></p>
<p><wbr></p>
<p><wbr><wbr> </wbr></wbr></p>
<p><wbr><wbr><wbr><wbr></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: green; ">&#8211; Author:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Proficient IT (http://www.proficientit.com.au</span></span>)</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; "><span style="font-family: 'Courier New'; color: green; ">&#8211; Create date: 04/01/2011</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: green; ">&#8211; Description: Match two strings if any part of the string of length set by presistion matches the next.</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: green; ">&#8211; ==============================<wbr>===============</wbr></span></span></p>
<p><wbr><wbr><wbr><wbr></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">CREATE</span><span style="font-family: 'Courier New'; ">&nbsp;<span style="color: blue; ">FUNCTION</span>&nbsp;fn_FuzzyStringMatch</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: gray; ">(</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp; @Str1&nbsp;<span style="color: blue; ">Nvarchar</span><span style="color: gray; ">(</span>4000<span style="color: gray; ">)</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: gray; ">,</span>&nbsp;@Str2&nbsp;<span style="color: blue; ">Nvarchar</span><span style="color: gray; ">(</span>4000<span style="color: gray; ">)</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: gray; ">,</span>&nbsp;@Precision&nbsp;<span style="color: blue; ">int</span>&nbsp;<span style="color: gray; ">=</span>&nbsp;4</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: gray; ">)</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">RETURNS</span><span style="font-family: 'Courier New'; ">&nbsp;<span style="color: blue; ">bit</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">AS</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">BEGIN</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">&nbsp;</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">DECLARE</span>&nbsp;@Str1Len&nbsp;<span style="color: blue; ">int</span>&nbsp;<span style="color: blue; ">SET</span>&nbsp;@Str1Len&nbsp;<span style="color: gray; ">=</span>&nbsp;<span style="color: fuchsia; ">LEN</span><span style="color: gray; ">(</span>@Str1<span style="color: gray; ">)</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">DECLARE</span>&nbsp;@MaxPosition&nbsp;<span style="color: blue; ">int</span>&nbsp;<span style="color: blue; ">SET</span>&nbsp;@MaxPosition&nbsp;<span style="color: gray; ">=</span>&nbsp;@Str1Len&nbsp;<span style="color: gray; ">-</span>&nbsp;@Precision</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">DECLARE</span>&nbsp;@Str1Extract&nbsp;<span style="color: blue; ">Nvarchar</span><span style="color: gray; ">(</span>4000<span style="color: gray; ">)</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: gray; ">&nbsp;</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">DECLARE</span>&nbsp;@i&nbsp;<span style="color: blue; ">int</span>&nbsp;<span style="color: gray; ">=</span>&nbsp;1</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">WHILE</span>&nbsp;@i&nbsp;<span style="color: gray; ">&lt;=</span>&nbsp;@MaxPosition&nbsp;<span style="color: blue; ">BEGIN</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">SET</span>&nbsp;@Str1Extract&nbsp;<span style="color: gray; ">=</span>&nbsp;<span style="color: fuchsia; ">SUBSTRING</span><span style="color: gray; ">(</span>@Str1<span style="color: gray; ">,</span>&nbsp;@i<span style="color: gray; ">,</span>&nbsp;@Precision<span style="color: gray; ">)</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: gray; ">&nbsp;</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">IF</span>&nbsp;@Str2&nbsp;<span style="color: gray; ">LIKE</span>&nbsp;<span style="color: red; ">&#39;%&#39;</span>&nbsp;<span style="color: gray; ">+</span>&nbsp;@Str1Extract&nbsp;<span style="color: gray; ">+</span>&nbsp;<span style="color: red; ">&#39;%&#39;</span>&nbsp;<span style="color: blue; ">BEGIN</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">RETURN</span>&nbsp;1</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">END</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">&nbsp;</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">SET</span>&nbsp;@i&nbsp;<span style="color: gray; ">=</span>&nbsp;@i&nbsp;<span style="color: gray; ">+</span>&nbsp;1</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">END</span></span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">&nbsp;</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">RETURN</span>&nbsp;0</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; ">&nbsp;</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">END</span></span></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><span style="font-family: 'Courier New'; color: blue; ">GO</span></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></p>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=203</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL – Simple Live backup</title>
		<link>http://www.proficientit.com.au/blog/?p=188</link>
		<comments>http://www.proficientit.com.au/blog/?p=188#comments</comments>
		<pubDate>Sun, 19 Jun 2011 12:22:27 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=188</guid>
		<description><![CDATA[&#160; This is not a Live backup in the sense of transaction level replication but simply a snapshot in time of a database already mounted and ready to be queried. A very simple way to have a live backup is &#8230; <a href="http://www.proficientit.com.au/blog/?p=188">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<p><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse;border:none;">
<tbody>
<tr style="<br />
  height:13.25pt">
<td style="width:461.55pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:13.25pt" valign="top" width="615">
<div style="margin-bottom:0cm;margin-bottom:.0001pt">&nbsp;</div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="color:red">This is not a Live backup in the sense of transaction level replication but simply a snapshot in time of a database already mounted and ready to be queried.</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
</td>
</tr>
</tbody>
</table>
<div><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">A very simple way to have a live backup is to use a script to backup an existing live database and automatically restore the backup as a new or existing database.</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">If this is done as a SQL Server Agent job then it can be executed as often as needed giving you a live snapshot of a database which can be queried as if it were the real thing.</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">I generally do not use this method as a true backup and would not recommend doing so. Although, I have found it very useful in keeping development and debugging databases as up to date as possible.&nbsp;This means that developers do not need to worry that they are working on an old version of the database just because no one bothered to update it.</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">In the sense of an update it can often be helpful to have a live version of the current production data from 30 minutes or so ago. Trust me, as a database admin you soon realize how easy it is to make a typo or somebody comes along and bothers you and you forget a WHERE clause on your UPDATE statement. While, for me anyway, this a rarity the live backup can help you quickly get the database back up and running.</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Anyway here is the script I have been using to do the task;</span></div>
<div>&nbsp;</div>
<div>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; ">
<tbody>
<tr style="height: 13.25pt; ">
<td style="width: 461.55pt; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; height: 13.25pt; " valign="top" width="615">
<div style="margin-bottom: 0.0001pt; ">&nbsp;</div>
<div style="margin-bottom: 0.0001pt; "><font class="Apple-style-span" color="#ff0000"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Warning: When you edit this script to work for your database make sure you get the database names the correct way round. Otherwise this could wipe your original database. Do not attempt this unless you know what you are doing.</span></font></div>
<div style="margin-bottom: 0.0001pt; "><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br />
</span></div>
</td>
</tr>
</tbody>
</table>
</div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">USE</span><span style="font-size:10.0pt;Courier New&quot;;"> master</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:green;">&#8211;create myDatabase back file</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">BACKUP</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:blue">DATABASE</span> [myDatabase]<span style="color:blue">TO</span>&nbsp;<span style="color:blue">DISK</span> <span style="color:gray">=</span> <span style="color:red">N&#39;C:\temp\myDatabase.sql.bak&#39;</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">WITH</span><span style="font-size:10.0pt;Courier New&quot;;"> RETAINDAYS <span style="color:<br />
gray">=</span> 7<span style="color:gray">,</span> FORMAT<span style="color:<br />
gray">,</span> INIT<span style="color:gray">,</span> NAME <span style="color:gray">=</span> <span style="color:red">N&#39;myDatabase Full Database Backup&#39;</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> SKIP</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> NOREWIND</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> NOUNLOAD</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> STATS <span style="color:gray">=</span> 10GO</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">IF</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:fuchsia">DB_ID</span><span style="color:gray">(</span><span style="color:red">&#39;myDatabase_live_backup&#39;</span><span style="color:gray">)</span> <span style="color:gray">IS</span> <span style="color:gray">NOT</span> <span style="color:gray">NULL</span> <span style="color:blue">BEGIN</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">DECLARE</span> @spid <span style="color:blue">INT</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">DECLARE</span> @sql <span style="color:blue">NVARCHAR</span><span style="color:gray">(</span>100<span style="color:gray">)</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">DECLARE</span> csurProcess <span style="color:blue">CURSOR</span> <span style="color:blue">FOR</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">SELECT</span> SPID</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">FROM</span> master<span style="color:gray">..</span><span style="color:green">sysprocesses</span> pr </span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:gray">INNER</span> <span style="color:gray">JOIN</span> sys<span style="color:gray">.</span>databases da <span style="color:blue">ON</span> pr<span style="color:gray">.</span>dbid <span style="color:gray">=</span> da<span style="color:gray">.</span>database_id</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">WHERE</span> da<span style="color:gray">.</span>name <span style="color:gray">=</span> <span style="color:red">&#39;myDatabase_live_backup&#39;</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">OPEN</span> csurProcess</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">FETCH</span> NEXT <span style="color:blue">FROM</span> csurProcess <span style="color:blue">INTO</span> @spid <span style="color:blue">WHILE</span> <span style="color:fuchsia">@@FETCH_STATUS</span> <span style="color:gray">=</span> 0 <span style="color:blue">BEGIN</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">PRINT</span> <span style="color:red">&#39;Killing process &#39;</span> <span style="color:gray">+</span> <span style="color:blue">CONVERT</span><span style="color:gray">(</span><span style="color:blue">NVARCHAR</span><span style="color:gray">,</span> @spid<span style="color:gray">)</span> <span style="color:gray">+</span> <span style="color:red">&#39;.&#39;</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">SET</span> @sql <span style="color:gray">=</span> <span style="color:red">&#39;KILL &#39;</span> <span style="color:gray">+</span> <span style="color:blue">CONVERT</span><span style="color:gray">(</span><span style="color:blue">NVARCHAR</span><span style="color:gray">,</span> @spid<span style="color:gray">)</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">EXEC</span><span style="color:gray">(</span>@sql<span style="color:gray">)</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">FETCH</span> NEXT <span style="color:blue">FROM</span> csurProcess <span style="color:blue">INTO</span> @spid</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">END</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">CLOSE</span> csurProcess</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">DEALLOCATE</span> csurProcess</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">END</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:blue">ELSE</span> <span style="color:blue">BEGIN</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue">CREATE</span> <span style="color:blue">DATABASE</span> myDatabase_live_backup</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">END</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">GO</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">ALTER</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:blue">DATABASE</span> [myDatabase_live_backup]</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">SET</span><span style="font-size:10.0pt;Courier New&quot;;"> SINGLE_USER <span style="color:blue">WITH</span> <span style="color:blue">ROLLBACK</span> IMMEDIATE</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:green;">&#8211;Retore myDatabase backup to myDatabase_live_backup</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">RESTORE</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:blue">DATABASE</span> [myDatabase_live_backup] <span style="color:blue">FROM</span>&nbsp;<span style="color:blue">DISK</span> <span style="color:gray">=</span> <span style="color:red">N&#39;C:\Temp\myDatabase.sql.bak&#39;</span><span style="color:blue">WITH</span>&nbsp;<span style="color:blue">FILE</span> <span style="color:gray">=</span> 1<span style="color:gray">,</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;">MOVE <span style="color:red">N&#39;myDatabase&#39;</span> <span style="color:blue">TO</span> <span style="color:red">N&#39;C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\myDatabase_live_backup.mdf&#39;</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> MOVE <span style="color:red">N&#39;myDatabase_log&#39;</span> <span style="color:blue">TO</span> <span style="color:red">N&#39;C:\Program Files\Microsoft SQL</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:red;">Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\myDatabase_live_backup.ldf&#39;</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> NOUNLOAD</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:fuchsia">REPLACE</span></span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:gray;">,</span><span style="font-size:10.0pt;Courier New&quot;;"> STATS <span style="color:gray">=</span> 10GO</span></span></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;text-autospace:none"><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br />
</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><span style="font-size:10.0pt;Courier New&quot;;<br />
color:blue;">ALTER</span><span style="font-size:10.0pt;Courier New&quot;;"> <span style="color:blue">DATABASE</span> [myDatabase_live_backup]<span style="color:blue">SET</span> MULTI_USER <span style="color:blue">WITH</span> <span style="color:blue">ROLLBACK</span> IMMEDIATE<span style="color:gray">;</span></span></span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=188</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ASP.NET – Disable saving of password / user name.</title>
		<link>http://www.proficientit.com.au/blog/?p=184</link>
		<comments>http://www.proficientit.com.au/blog/?p=184#comments</comments>
		<pubDate>Sun, 19 Jun 2011 11:30:33 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=184</guid>
		<description><![CDATA[  Trying to stop people saving their login details on public computers? Often it is done inadvertently by people forgetting to un-tick a &#8220;Remember me&#8221; or &#8220;Keep me logged in&#8221;. Although this is only available on sites that give the &#8230; <a href="http://www.proficientit.com.au/blog/?p=184">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
 </p>
<p>Trying to stop people saving their login details on public computers? Often it is done inadvertently by people forgetting to un-tick a &#8220;Remember me&#8221; or &#8220;Keep me logged in&#8221;. Although this is only available on sites that give the option. Even if a site doesn&#8217;t offer this function, almost all modern browsers will offer to save the password anyway.
</p>
<p>To stop this you can simply add the following line to you page load event;
</p>
<p><strong>form1.Attributes.Add(&#8220;autocomplete&#8221;, &#8220;off&#8221;);<br />
</strong></p>
<p>If you are using a master page you can add this to the master page code behind. Remember though if you do it this way then it will stop any text on all your pages to not remember anything when the user come back to the page. This can actually become annoying so only use it when necessary.
</p>
<p style="text-align: justify">Another method is to change the property of the textbox, of the username and password controls, &#8220;<strong>AutoCompleteType</strong>&#8221; to &#8220;<strong>Disable</strong>&#8220;.
</p>
<p style="text-align: justify">You may need to change both the password textbox and the username textbox properties to &#8220;Disabled&#8221; in order for this to work as most browsers use the selection of a past username as the trigger point to save/retrieve the password.
</p>
<p style="text-align: justify">The benefit of the second method is that it only affects the targeted fields.
</p>
<p style="text-align: justify">I have not tested this on all browsers. It has worked on IE7, IE8, Safari, Firefox and Chrome.
</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=184</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kill processes in SQL server from TSQL.</title>
		<link>http://www.proficientit.com.au/blog/?p=180</link>
		<comments>http://www.proficientit.com.au/blog/?p=180#comments</comments>
		<pubDate>Thu, 24 Mar 2011 09:44:09 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=180</guid>
		<description><![CDATA[&#160; Sometimes you need to kill processes in SQL. I find that when I need to restore a database in I get that annoying &#8220;Cannot get exclusive access&#8221; error. One way to do it would be to run the command; &#8230; <a href="http://www.proficientit.com.au/blog/?p=180">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">Sometimes you need to kill processes in SQL. I find that when I need to restore a database in I get that annoying &ldquo;Cannot get exclusive access&rdquo; error. One way to do it would be to run the command;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">ALTER&nbsp;DATABASE&nbsp;</span><span style="color: black; ">[TestDB]&nbsp;</span><span style="color: blue; ">SET&nbsp;</span><span style="color: black; ">SINGLE_USER&nbsp;</span><span style="color: blue; ">WITH&nbsp;ROLLBACK&nbsp;</span><span style="color: black; ">IMMEDIATE</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">I find this a little harsh as I can do some real damage in a hurry if I muck it up. Not only the database I am dealing with but the whole server.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">I prefer just killing or the processes relating to the database and then working on it immediately afterward.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">Killing the processes in the GUI can become a little tedious though so I wrote a quick script (below) to do the leg work for me.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">Now if a want to kill all processes relating to a database I simply pass the database name into my script (without passing a user name) and bang, they are all dead.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">I ended up adding the login parameter because although I have not yet used it I can think of reasons in the future where it may come in handy. Say for instance, a rogue user is hogging all the server resources I can knock them out in a single punch. Obviously I am an admin though.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">To see which login is using the most resources directly from TSQL use this query (SQL 2005,2008+);</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">SELECT</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">loginame</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: gray; ">,</span>&nbsp;<span style="color: fuchsia; ">COUNT</span><span style="color: gray; ">(*)</span><span style="color: black; ">&nbsp;Processes</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: gray; ">,</span>&nbsp;<span style="color: fuchsia; ">SUM</span><span style="color: gray; ">(</span><span style="color: black; ">pr</span><span style="color: gray; ">.</span><span style="color: black; ">cpu</span><span style="color: gray; ">)</span><span style="color: black; ">&nbsp;cpu</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: gray; ">,</span>&nbsp;<span style="color: fuchsia; ">SUM</span><span style="color: gray; ">(</span><span style="color: black; ">pr</span><span style="color: gray; ">.</span><span style="color: black; ">physical_io</span><span style="color: gray; ">)</span><span style="color: black; ">&nbsp;physical_io</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: gray; ">,</span>&nbsp;<span style="color: fuchsia; ">SUM</span><span style="color: gray; ">(</span><span style="color: black; ">pr</span><span style="color: gray; ">.</span><span style="color: black; ">memusage</span><span style="color: gray; ">)</span><span style="color: black; ">&nbsp;memusage</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">FROM</span>&nbsp;<span style="color: blue; ">master</span><span style="color: gray; ">..</span><span style="color: green; ">sysprocesses</span><span style="color: black; ">&nbsp;pr</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">GROUP</span>&nbsp;<span style="color: blue; ">BY</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">loginame</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">ORDER</span>&nbsp;<span style="color: blue; ">BY</span>&nbsp;<span style="color: fuchsia; ">SUM</span><span style="color: gray; ">(</span><span style="color: black; ">pr</span><span style="color: gray; ">.</span><span style="color: black; ">cpu</span><span style="color: gray; ">)</span>&nbsp;<span style="color: blue; ">DESC</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">loginame</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 10pt; margin-left: 0cm; line-height: 17px; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">The script (SQL 2005,2008+);</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: green; ">&#8211;KILL SQL PROCESSES</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: green; ">&#8211;proficientit.com.au</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: green; ">&#8211;Note passing nothing kills all processes except the current one.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: green; ">&#8211;Passing only @dbName name will kill all processes for that database.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: green; ">&#8211;Passing only @loginName name will kill all processes for that login.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">DECLARE</span><span style="color: black; ">&nbsp;@dbName&nbsp;</span><span style="color: blue; ">As</span>&nbsp;<span style="color: blue; ">Nvarchar</span><span style="color: gray; ">(</span><span style="color: black; ">50</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">=</span>&nbsp;<span style="color: red; ">&#39;DB_NAME&#39;</span>&nbsp;<span style="color: green; ">&#8211;Database name</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">DECLARE</span><span style="color: black; ">&nbsp;@loginName&nbsp;</span><span style="color: blue; ">AS</span>&nbsp;<span style="color: blue; ">Nvarchar</span><span style="color: gray; ">(</span><span style="color: black; ">50</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">=</span>&nbsp;<span style="color: red; ">&#39;MY_DOMAIN\MY_USER&#39;</span><span style="color: green; ">&nbsp;&#8211;&#39;MY_DOMAIN\MY_USER&#39; or &#39;SQL_USER&#39;, basically how it appears in Security/Logins</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">USE</span>&nbsp;<span style="color: blue; ">master</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">IF</span><span style="color: black; ">&nbsp;@dbName&nbsp;</span><span style="color: gray; ">IN(</span><span style="color: red; ">&#39;master&#39;</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;model&#39;</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;msdb&#39;</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;tempdb&#39;</span><span style="color: gray; ">)</span>&nbsp;<span style="color: blue; ">BEGIN</span>&nbsp;<span style="color: blue; ">RAISERROR</span><span style="color: gray; ">(</span><span style="color: red; ">&#39;This script can only kill user processes.&#39;</span><span style="color: gray; ">,</span><span style="color: black; ">16</span><span style="color: gray; ">,</span><span style="color: black; ">1</span><span style="color: gray; ">)</span>&nbsp;<span style="color: blue; ">RETURN</span>&nbsp;<span style="color: blue; ">END</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">IF</span>&nbsp;<span style="color: fuchsia; ">ISNULL</span><span style="color: gray; ">(</span><span style="color: black; ">@dbName</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;&#39;</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">&lt;&gt;</span>&nbsp;<span style="color: red; ">&#39;&#39;</span>&nbsp;<span style="color: gray; ">AND</span>&nbsp;<span style="color: fuchsia; ">DB_ID</span><span style="color: gray; ">(</span><span style="color: black; ">@dbName</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">IS</span>&nbsp;<span style="color: gray; ">NULL</span>&nbsp;<span style="color: blue; ">BEGIN</span>&nbsp;<span style="color: blue; ">RAISERROR</span><span style="color: gray; ">(</span><span style="color: red; ">&#39;Database does not exist or you don&#39;&#39;t have permission to see it.&#39;</span><span style="color: gray; ">,</span><span style="color: black; ">16</span><span style="color: gray; ">,</span><span style="color: black; ">1</span><span style="color: gray; ">)</span>&nbsp;<span style="color: blue; ">RETURN</span>&nbsp;<span style="color: blue; ">END</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">IF</span>&nbsp;<span style="color: fuchsia; ">ISNULL</span><span style="color: gray; ">(</span><span style="color: black; ">@loginName</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;&#39;</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">&lt;&gt;</span>&nbsp;<span style="color: red; ">&#39;&#39;</span>&nbsp;<span style="color: gray; ">AND</span>&nbsp;<span style="color: gray; ">NOT</span>&nbsp;<span style="color: gray; ">EXISTS(</span><span style="color: blue; ">SELECT</span><span style="color: black; ">&nbsp;name&nbsp;</span><span style="color: blue; ">FROM</span>&nbsp;<span style="color: blue; ">master</span><span style="color: gray; ">.</span><span style="color: black; ">dbo</span><span style="color: gray; ">.</span><span style="color: green; ">syslogins</span>&nbsp;<span style="color: blue; ">WHERE</span><span style="color: black; ">name&nbsp;</span><span style="color: gray; ">=</span><span style="color: black; ">&nbsp;@loginName</span><span style="color: gray; ">)</span>&nbsp;<span style="color: blue; ">BEGIN</span>&nbsp;<span style="color: blue; ">RAISERROR</span><span style="color: gray; ">(</span><span style="color: red; ">&#39;Login doesn&#39;&#39;t exist on this server or you don&#39;&#39;t have permission to see it.&#39;</span><span style="color: gray; ">,</span><span style="color: black; ">16</span><span style="color: gray; ">,</span><span style="color: black; ">1</span><span style="color: gray; ">)</span>&nbsp;<span style="color: blue; ">RETURN</span>&nbsp;<span style="color: blue; ">END</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">DECLARE</span><span style="color: black; ">&nbsp;@spid&nbsp;</span><span style="color: blue; ">INT</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">DECLARE</span><span style="color: black; ">&nbsp;@sql&nbsp;</span><span style="color: blue; ">Nvarchar</span><span style="color: gray; ">(</span><span style="color: black; ">100</span><span style="color: gray; ">)</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">DECLARE</span><span style="color: black; ">&nbsp;csurProcess&nbsp;</span><span style="color: blue; ">CURSOR</span>&nbsp;<span style="color: blue; ">FOR</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">SELECT</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">SPID</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">FROM</span>&nbsp;<span style="color: blue; ">master</span><span style="color: gray; ">..</span><span style="color: green; ">sysprocesses</span><span style="color: black; ">&nbsp;pr</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: gray; ">INNER</span>&nbsp;<span style="color: gray; ">JOIN</span>&nbsp;<span style="color: green; ">sys</span><span style="color: gray; ">.</span><span style="color: green; ">databases</span><span style="color: black; ">&nbsp;da&nbsp;</span><span style="color: blue; ">ON</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: blue; ">dbid</span>&nbsp;<span style="color: gray; ">=</span><span style="color: black; ">&nbsp;da</span><span style="color: gray; ">.</span><span style="color: black; ">database_id</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">WHERE&nbsp;</span><span style="color: gray; ">(</span><span style="color: black; ">da</span><span style="color: gray; ">.</span><span style="color: black; ">name&nbsp;</span><span style="color: gray; ">=</span><span style="color: black; ">&nbsp;@dbName&nbsp;</span><span style="color: gray; ">OR</span>&nbsp;<span style="color: fuchsia; ">ISNULL</span><span style="color: gray; ">(</span><span style="color: black; ">@dbName</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;&#39;</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">=</span>&nbsp;<span style="color: red; ">&#39;&#39;</span><span style="color: gray; ">)</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: gray; ">AND</span>&nbsp;<span style="color: gray; ">(</span><span style="color: black; ">pr</span><span style="color: gray; ">.</span><span style="color: black; ">loginame&nbsp;</span><span style="color: gray; ">=</span><span style="color: black; ">&nbsp;@loginName&nbsp;</span><span style="color: gray; ">OR</span>&nbsp;<span style="color: fuchsia; ">ISNULL</span><span style="color: gray; ">(</span><span style="color: black; ">@loginName</span><span style="color: gray; ">,</span><span style="color: red; ">&#39;&#39;</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">=</span>&nbsp;<span style="color: red; ">&#39;&#39;</span><span style="color: gray; ">)</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: gray; ">AND</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">SPID&nbsp;</span><span style="color: gray; ">&lt;&gt;</span>&nbsp;<span style="color: fuchsia; ">@@SPID</span>&nbsp;<span style="color: green; ">&#8211;Can&#39;t kill this session(this script is running in it).</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">OPEN</span><span style="color: black; ">&nbsp;csurProcess</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">FETCH</span>&nbsp;<span style="color: blue; ">NEXT</span>&nbsp;<span style="color: blue; ">FROM</span><span style="color: black; ">&nbsp;csurProcess&nbsp;</span><span style="color: blue; ">INTO</span><span style="color: black; ">&nbsp;@spid&nbsp;</span><span style="color: blue; ">WHILE</span>&nbsp;<span style="color: fuchsia; ">@@FETCH_STATUS</span>&nbsp;<span style="color: gray; ">=</span><span style="color: black; ">&nbsp;0&nbsp;</span><span style="color: blue; ">BEGIN</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">PRINT</span>&nbsp;<span style="color: red; ">&#39;Killing process &#39;</span>&nbsp;<span style="color: gray; ">+</span>&nbsp;<span style="color: fuchsia; ">CONVERT</span><span style="color: gray; ">(</span><span style="color: blue; ">NVARCHAR</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;@spid</span><span style="color: gray; ">)</span>&nbsp;<span style="color: gray; ">+</span>&nbsp;<span style="color: red; ">&#39;.&#39;</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">SET</span><span style="color: black; ">&nbsp;@sql&nbsp;</span><span style="color: gray; ">=</span>&nbsp;<span style="color: red; ">&#39;KILL &#39;</span>&nbsp;<span style="color: gray; ">+</span>&nbsp;<span style="color: fuchsia; ">CONVERT</span><span style="color: gray; ">(</span><span style="color: blue; ">NVARCHAR</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;@spid</span><span style="color: gray; ">)</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">EXEC</span><span style="color: gray; ">(</span><span style="color: black; ">@sql</span><span style="color: gray; ">)</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">FETCH</span>&nbsp;<span style="color: blue; ">NEXT</span>&nbsp;<span style="color: blue; ">FROM</span><span style="color: black; ">&nbsp;csurProcess&nbsp;</span><span style="color: blue; ">INTO</span><span style="color: black; ">&nbsp;@spid</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">END</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">CLOSE</span><span style="color: black; ">&nbsp;csurProcess</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">DEALLOCATE</span><span style="color: black; ">&nbsp;csurProcess</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: green; ">&#8211;See what processes are current active.</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">SELECT</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">SPID</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;da</span><span style="color: gray; ">.</span><span style="color: black; ">name [dbName]</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">loginame</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">cpu</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">physical_io</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">memusage</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">login_time</span><span style="color: gray; ">,</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: black; ">last_batch</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: blue; ">FROM</span>&nbsp;<span style="color: blue; ">master</span><span style="color: gray; ">..</span><span style="color: green; ">sysprocesses</span><span style="color: black; ">&nbsp;pr</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: gray; ">INNER</span>&nbsp;<span style="color: gray; ">JOIN</span>&nbsp;<span style="color: green; ">sys</span><span style="color: gray; ">.</span><span style="color: green; ">databases</span><span style="color: black; ">&nbsp;da&nbsp;</span><span style="color: blue; ">ON</span><span style="color: black; ">&nbsp;pr</span><span style="color: gray; ">.</span><span style="color: blue; ">dbid</span>&nbsp;<span style="color: gray; ">=</span><span style="color: black; ">&nbsp;da</span><span style="color: gray; ">.</span><span style="color: black; ">database_id</span></div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; ">&nbsp;</div>
<div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; line-height: normal; font-size: 11pt; "><span style="color: black; ">&nbsp;Enjoy.</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=180</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning Google into a file sharing service.</title>
		<link>http://www.proficientit.com.au/blog/?p=161</link>
		<comments>http://www.proficientit.com.au/blog/?p=161#comments</comments>
		<pubDate>Fri, 25 Feb 2011 21:55:15 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Search]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=161</guid>
		<description><![CDATA[&#160; There is so much out there on the internet. So many shared directories, some of which may or may not have been shared on purpose, some are shared by people who simply don&#8217;t understand that on the internet, anybody &#8230; <a href="http://www.proficientit.com.au/blog/?p=161">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<div>There is so much out there on the internet. So many shared directories, some of which may or may not have been shared on purpose, some are shared by people who simply don&rsquo;t understand that on the internet, <strong>anybody </strong>can see it.</div>
<div>&nbsp;</div>
<div>The great thing is that one of those any bodies is Google. The trick is to find it. There are many different ways to search Google and you can do some very intense searching but some of these search terms would literally take 2 minutes just to type in.</div>
<div>&nbsp;</div>
<div>So to the rescue I have created this JavaScript shortcut to help find files on the internet.</div>
<div>&nbsp;</div>
<div>Simply create a shortcut in your favourite browser (only tested in Firefox and mainly Google Chrome) and paste the below text into the address bar. Name it File Search. Previously seemed to work in IE but no longer seems to allow the javascript dialogue box.</div>
<div>&nbsp;</div>
<div>Next just click the shortcut. Enter any file extentions you want searched separated by the &ldquo;|&rdquo; symbol. Then enter part of the filename you are searching for. It will then use Google to search web directories of file shares.</div>
<div>&nbsp;</div>
<div>Hopefully you will find what you are looking for. Remember some people like to bait Google and make sites that appear to be web directories but are just rude. Hopefully Google&#8217;s algorithms will get better and filter these out. Actually that goes for all Google searches.</div>
<div>&nbsp;</div>
<div><a href='javascript:var ext=prompt("Please enter file extensions separated by |.","mp3");var srh=prompt("Please search term.","");window.location = "http://www.google.com/search?&#038;q=-inurl:(htm|html|php) intitle:\"index of\" +\"last modified\" +\"parent directory\" +description +size +(" + ext + ") \"" + srh + "\"";'>Try It</a></div>
<div>The shortcut:</div>
<div>Copy all of the following text into a new internet shortcut in your browser. Exactly as it is.</div>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse;border:none;">
<tbody>
<tr>
<td style="width:462.1pt;border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt" valign="top" width="616">
<div style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:<br />
  normal">&nbsp;</div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:<br />
  normal"><strong><span style="color:#10253F;">javascript:var ext=prompt(&quot;Please enter file extensions separated by |.&quot;,&quot;mp3&quot;);var srh=prompt(&quot;Please search term.&quot;,&quot;&quot;);window.location = &quot;http://www.google.com/search?&amp;q=-inurl:(htm|html|php) intitle:\&quot;index of\&quot; +\&quot;last modified\&quot; +\&quot;parent directory\&quot; +description +size +(&quot; + ext + &quot;) \&quot;&quot; + srh + &quot;\&quot;&quot;;</span></strong></div>
<div style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:<br />
  normal">&nbsp;</div>
</td>
</tr>
</tbody>
</table>
<div>&nbsp;</div>
<div>Enjoy.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=161</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script user permissions in SQL for server migration.</title>
		<link>http://www.proficientit.com.au/blog/?p=153</link>
		<comments>http://www.proficientit.com.au/blog/?p=153#comments</comments>
		<pubDate>Sat, 29 Jan 2011 03:16:59 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=153</guid>
		<description><![CDATA[This script is a great help when you need to move a database to a different server as it dramatically speeds up the process and leaves a lot less room for errors compared with doing the process by hand. I &#8230; <a href="http://www.proficientit.com.au/blog/?p=153">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This script is a great help when you need to move a database to a different server as it dramatically speeds up the process and leaves a lot less room for errors compared with doing the process by hand. I can&#8217;t count how many times I have used this script.</p>
<p>The reason for needing the script is that even when you create a new SQL login by the same name on the new server, when you restore or attach the existing database the database user does not map the the new login. Even though they have the same name they have different identifiers.</p>
<p>The best approach is to prepare the move by running the below script on the database in it&#8217;s existing location. This will then generate a new script that you save for later use. Do this for all necessary database users.</p>
<p>Next restore/attach the database in it&#8217;s new location and delete the users from the database. Yes I said delete them.</p>
<p>Now run the scripts you generated at the start and it will recreate the Logins and map all the role and permissions from the last server. If you have multiple scripts for multiple users run them all sequentially.</p>
<p>Sometimes the script has an issue creating the actually server login. If it does create logins yourself by the same names. The password can be set to what ever you need. Also in the generated script you may need to comment out the part at the top that creates the login to prevent an error.</p>
<p>The script is written by Bradley Morris back in 2002 and I have had no problems, even today, using it on SQL Server 2008.</p>
<p>Find the script here.<br />
<a href="http://www.sql-server-performance.com/articles/dba/object_permission_scripts_p1.aspx">http://www.sql-server-performance.com/articles/dba/object_permission_scripts_p1.aspx</a></p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=153</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting a Facebook account.</title>
		<link>http://www.proficientit.com.au/blog/?p=141</link>
		<comments>http://www.proficientit.com.au/blog/?p=141#comments</comments>
		<pubDate>Fri, 14 Jan 2011 12:11:37 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=141</guid>
		<description><![CDATA[A very common question I get is &#8220;How do I delete my Facebook account?&#8221; Weird thing is, facebook wont tell you. Legally they want to give you the tools to do it, so they can say we have free will, but morally they want &#8230; <a href="http://www.proficientit.com.au/blog/?p=141">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A very common question I get is &#8220;How do I delete my Facebook account?&#8221; Weird thing is, facebook wont tell you. Legally they want to give you the tools to do it, so they can say we have free will, but morally they want your details stuck with them, own by them, for life.</p>
<p>Even once you have successfully deleted an account any activity on the account will re-create the account.</p>
<p>Well, luckily someone has gone to the effort to let us know how. Read this interesting post. Why does Facebook make it so hard to leave. Do they know something we dont know?</p>
<p><strong>Read it. <a href="http://www.wikihow.com/Permanently-Delete-a-Facebook-Account">Get rid of Facebook</a>.</strong></p>
<p>Is it because so may people are leaving, disgusted with how Facebook turned out. They joined just to see what was the fuss. They stayed just to see what changed. Perusing around trying to see who is doing what but all the while missing out on events due to the fact they where too busy looking and drooling over what everyone else was doing. On the the internet. Forgeting that there is is a real life outside of Facebook.</p>
<p>Facebook says it has reached 500 million users but how many of these users simply can&#8217;t delete their account?</p>
<p>So and so said so and so to so and so. Who cares you say? If I had no Facebook then my life would be simpler. I would be worrying about real events and getting further in my life.</p>
<p>Facebook is a diversion. <a href="http://www.wikihow.com/Permanently-Delete-a-Facebook-Account">Get on with life.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=141</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup your hard drive over the network with dd and ssh</title>
		<link>http://www.proficientit.com.au/blog/?p=139</link>
		<comments>http://www.proficientit.com.au/blog/?p=139#comments</comments>
		<pubDate>Sun, 02 Jan 2011 11:19:20 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=139</guid>
		<description><![CDATA[Came across this enlightening post about how to backup and restore a system using a Linux boot disk and a separate Linux box as a storage device. Hope you find as useful as I have. http://www.pantz.org/software/dd/drivecopywithsshanddd.html]]></description>
			<content:encoded><![CDATA[<p>Came across this enlightening post about how to backup and restore a system using a Linux boot disk and a separate Linux box as a storage device.</p>
<p>Hope you find as useful as I have.</p>
<p><a href="http://www.pantz.org/software/dd/drivecopywithsshanddd.html">http://www.pantz.org/software/dd/drivecopywithsshanddd.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=139</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using global variables inside PHP functions</title>
		<link>http://www.proficientit.com.au/blog/?p=127</link>
		<comments>http://www.proficientit.com.au/blog/?p=127#comments</comments>
		<pubDate>Sat, 01 Jan 2011 11:40:08 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=127</guid>
		<description><![CDATA[Within a function normal variable reference in the scope of the PHP file cannot be directly referenced. This is not a weakness of PHP but a feature meant to save programmers from themselves. Any variable that is to exist inside &#8230; <a href="http://www.proficientit.com.au/blog/?p=127">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Within a function normal variable reference in the scope of the PHP file cannot be directly referenced. This is not a weakness of PHP but a feature meant to save programmers from themselves. Any variable that is to exist inside of a function must have the express permission of the programmer.<span style="mso-spacerun: yes;"> </span>The protection this provides is that the programmer cannot accidentally or inadvertently create a variable by the same name as a variable inside a function creating unknown havoc.</p>
<p class="MsoNormal">Therefore, if you want to use any value inside of a PHP function that does originate from inside the function itself there are two ways to go about it.</p>
<p class="MsoNormal">The most simple and most would argue correct is to enter the variable as an input parameter of the function itself.</p>
<p class="MsoNormal">For example;</p>
<p class="MsoNormal"><span style="color: #0033cc;">&lt;?php</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">function myFunction(<strong>$myVariable</strong>){</span></p>
<p class="MsoNormal"><span style="color: #0033cc;"><span style="mso-spacerun: yes;"> </span>echo <strong>$myVariable</strong>;</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">}</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">myFunction(&#8220;myVariableValue&#8221;);</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">?&gt;</span></p>
<p class="MsoNormal">While simple and correct, it is not always what you want. If you are writing functions that are using the same variables over and over it just doesn’t make sense as a human to have to input the same information into multiple functions.<span style="mso-spacerun: yes;"> </span>One example is if you have a large number of functions that need the sites global connection string passed into everyone.</p>
<p class="MsoNormal">In this case you can allow your function to access the external variable <span style="mso-spacerun: yes;"> </span>using the global statement.</p>
<p class="MsoNormal">For example;</p>
<p class="MsoNormal"><span style="color: #0033cc;">&lt;?php</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">function myFunction() {</span></p>
<p class="MsoNormal"><span style="color: #0033cc;"><span style="mso-tab-count: 1;"> </span>global <strong>$myVariable</strong>;</span></p>
<p class="MsoNormal"><span style="color: #0033cc;"><span style="mso-tab-count: 1;"> </span>echo <strong>$myVariable</strong>;</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">}</span></p>
<p class="MsoNormal"><strong><span style="color: #0033cc;">$myVariable</span></strong><span style="color: #0033cc;"> = &#8220;myVariableValue&#8221;;</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">myFunction ();</span></p>
<p class="MsoNormal"><span style="color: #0033cc;">?&gt;</span></p>
<p class="MsoNormal">As you can see we have given explicit permission for the function to access data from the variable that was set outside the scope of the function.</p>
<p class="MsoNormal">I would recommend that you limit your usage of the global statement to variables that are unique and used extensively throughout your project. Things like a global database connection strings and similar would be acceptable. Outside this I would strongly recommend using function input parameters only. This will help keep your code clean and understandable for when someone else needs to look at your code or even when you yourself need to come back in the future and make a change. Another reason is that if you reuse your function in another project you rule out any chance of cross variable contamination.</p>
<p class="MsoNormal">
<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=127</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL – Creating a logon trigger</title>
		<link>http://www.proficientit.com.au/blog/?p=87</link>
		<comments>http://www.proficientit.com.au/blog/?p=87#comments</comments>
		<pubDate>Wed, 29 Dec 2010 11:07:27 +0000</pubDate>
		<dc:creator>Proficient IT</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://www.proficientit.com.au/blog/?p=87</guid>
		<description><![CDATA[This script will help you setup a database that will log all logins into a MSSQL server. This has only been tested on Windows SQL Server 2008 but it should be ok for 2005 as well. ** WARNING ** Don&#8217;t &#8230; <a href="http://www.proficientit.com.au/blog/?p=87">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This script will help you setup a database that will log all logins into a MSSQL server. This has only been tested on Windows SQL Server 2008 but it should be ok for 2005 as well.</p>
<div>
<table style="border-collapse: collapse;" border="0">
<colgroup>
<col style="width: 638px;"></col>
</colgroup>
<tbody>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border: solid 1.0pt;"><span style="color: #c00000;">** WARNING ** Don&#8217;t try this on your production server until you are feeling very comfortable about it. If you make a mistake and cause the trigger to error you may not be able to login. I suggest trying this on a testing server first. Also I always keep at least one query window connected at all times when setting this up.</span> If you do happen to lock yourself out try this great post <a href="http://www.codeproject.com/Tips/82007/SQL-Server-Logon-Triggers-Trouble.aspx"><span style="text-decoration: underline;">http://www.codeproject.com/Tips/82007/SQL-Server-Logon-Triggers-Trouble.aspx</span></a>.</td>
</tr>
</tbody>
</table>
</div>
<p><span style="color: black;">The Script <span style="font-family: Wingdings;"></span></span><span style="color: black;"> </span></p>
<p><span style="color: blue;">USE</span> <span style="&lt;br /&gt; color: blue;">master</span></p>
<div><span style="color: blue;">GO </span></div>
<div><span style="color: green;">&#8211;CREATE OUR NEW DATABASE</span></div>
<div><span style="color: blue;">CREATE</span> <span style="&lt;br /&gt; color: blue;">DATABASE</span><span style="color: black;"> LoginsDatabase</span></div>
<div><span style="color: blue;">GO</span></div>
<div><span style="color: green;">&#8211;OK LETS USE IT</span></div>
<div><span style="color: blue;">USE</span><span style="color: black;"> LoginsDatabase</span></div>
<div><span style="color: blue;">GO </span></div>
<div><span style="color: green;">&#8211;CREATE A LOGIN IN WHICH TO EXECUTE OUR TRIGGER AS</span></div>
<div><span style="color: blue;">CREATE</span> <span style="&lt;br /&gt; color: blue;">LOGIN</span><span style="color: black;"> LOG_USER </span><span style="color: blue;">WITH</span> <span style="color: blue;">PASSWORD</span><span style="&lt;br /&gt; color: gray;">=</span><span style="color: red;">N&#8217;LOG_u$er_01&#8242;</span><span style="color: gray;">,</span> <span style="color: blue;">DEFAULT_DATABASE</span><span style="&lt;br /&gt; color: gray;">=</span><span style="color: black;">LoginsDatabase</span></div>
<div><span style="color: blue;">GO</span></div>
<div><span style="color: green;">&#8211;CREATE A USER FOR CURRENT DATABASE WHICH IS NOW </span><span style="color: black;">LoginsDatabase</span></div>
<div><span style="color: blue;">CREATE</span> <span style="&lt;br /&gt; color: fuchsia;">USER</span><span style="color: black;"> LOG_USER </span><span style="color: blue;">FOR</span> <span style="color: blue;">LOGIN</span><span style="color: black;"> LOG_USER</span></div>
<div><span style="color: blue;">GO </span></div>
<div><span style="color: green;">&#8211;GRANT READ/WRITE PERMISSIONS TO OUR NEW USER</span></div>
<div><span style="color: blue;">EXEC</span> <span style="&lt;br /&gt; color: maroon;">sp_addrolemember</span><span> <span style="color: red;">N&#8217;db_datareader&#8217;</span><span style="color: gray;">,</span> <span style="color: red;">N&#8217;LOG_USER&#8217;</span></span></div>
<div><span style="color: blue;">GO</span></div>
<div><span style="color: blue;">EXEC</span> <span style="&lt;br /&gt; color: maroon;">sp_addrolemember</span><span> <span style="color: red;">N&#8217;db_datawriter&#8217;</span><span style="color: gray;">,</span> <span style="color: red;">N&#8217;LOG_USER&#8217;</span></span></div>
<div><span style="color: blue;">GO </span></div>
<div><span style="color: green;">&#8211;CREATE A TABLE TO HOLD OUR LOGIN DATA</span></div>
<div><span style="color: blue;">CREATE</span> <span style="&lt;br /&gt; color: blue;">TABLE</span><span style="color: black;"> [ServerLogins]</span><span style="color: gray;">(</span></div>
<div><span style="color: black;"> ID </span><span style="color: blue;">bigint</span> <span style="color: blue;">IDENTITY</span><span style="color: gray;">(</span><span style="color: black;">1</span><span style="color: gray;">,</span><span style="color: black;">1</span><span style="color: gray;">)</span> <span style="color: gray;">NOT</span> <span style="color: gray;">NULL</span></div>
<div><span style="color: black;"> </span><span style="color: gray;">,</span><span style="color: black;"> [EVENTDATA] </span><span style="color: blue;">xml</span> <span style="color: gray;">NOT</span> <span style="color: gray;">NULL</span></div>
<div><span style="color: gray;">)</span> <span style="&lt;br /&gt; color: blue;">ON</span><span style="color: black;"> [PRIMARY]</span></div>
<div><span style="color: blue;">GO </span></div>
<div><span style="color: green;">&#8211;CREATE OUR NEW TRIGGER THAT WILL RUN AS LOG_USER</span></div>
<div><span style="color: blue;">CREATE</span> <span style="&lt;br /&gt; color: blue;">TRIGGER</span><span style="color: black;"> logon_trigger_login_log</span></div>
<div><span style="color: blue;">ON</span> <span style="&lt;br /&gt; color: gray;">ALL</span> <span style="color: blue;">SERVER</span> <span style="color: blue;">WITH</span> <span style="&lt;br /&gt; color: blue;">EXECUTE</span> <span style="color: blue;">AS</span> <span style="color: red;">&#8216;LOG_USER&#8217;</span></div>
<div><span style="color: blue;">FOR</span><span style="color: black;"> LOGON</span><span style="&lt;br /&gt; color: green;">&#8211;DDL_LOGIN_EVENTS</span></div>
<div><span style="color: blue;">AS</span></div>
<div><span style="color: black;"> </span><span style="color: blue;">INSERT</span> <span style="color: blue;">INTO</span><span style="color: black;"> LoginsDatabase</span><span style="color: gray;">.</span><span style="color: black;">dbo</span><span style="color: gray;">.</span><span style="color: black;">ServerLogins</span><span style="color: gray;">(</span><span style="color: black;">[EVENTDATA]</span><span style="color: gray;">)</span> <span style="color: blue;">VALUES</span><span> <span style="color: gray;">(</span><span style="color: fuchsia;">EVENTDATA</span><span style="color: gray;">())</span></span></div>
<div><span style="color: blue;">GO</span></div>
<div></div>
<div><span style="color: green;">&#8211;LOGIN IN AND OUT OF THE DATABASE AS SOMEONE TO GENERATE DATA.</span></div>
<div></div>
<div><span style="color: green;">&#8211;RUN SELECT TO SEE WHAT WE HAVE RECORDED.</span></div>
<div><span style="color: blue;">SELECT</span> <span style="&lt;br /&gt; color: gray;">*</span></div>
<div><span style="color: blue;">FROM</span><span style="color: black;"> LoginsDatabase</span><span style="color: gray;">.</span><span style="color: black;">dbo</span><span style="color: gray;">.</span><span style="color: black;">ServerLogins</span></div>
<div></div>
<div><span style="color: green;">&#8211;EXAMPLE OUTPUT</span></div>
<div><span style="color: green;">&#8211;   &lt;EVENT_INSTANCE&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;EventType&gt;LOGON&lt;/EventType&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;PostTime&gt;2010-08-12T22:33:14.677&lt;/PostTime&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;SPID&gt;58&lt;/SPID&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;ServerName&gt;machine_name&lt;/ServerName&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;LoginName&gt;LOG_USER&lt;/LoginName&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;LoginType&gt;SQL Login&lt;/LoginType&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;SID&gt;eudUx3DfyESj/8yCaF2PpA==&lt;/SID&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;ClientHost&gt;&amp;lt;local machine&amp;gt;&lt;/ClientHost&gt;</span></div>
<div><span style="color: green;">&#8211;         &lt;IsPooled&gt;0&lt;/IsPooled&gt;</span></div>
<div><span style="color: green;">&#8211;   &lt;/EVENT_INSTANCE&gt;</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.proficientit.com.au/blog/?feed=rss2&#038;p=87</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

