<?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>Beakersoft Blog &#187; SQL Server</title>
	<atom:link href="http://www.beakersoft.co.uk/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.beakersoft.co.uk</link>
	<description>My (mis)adventures in the IT industry</description>
	<lastBuildDate>Thu, 11 Mar 2010 19:40:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
  <link>http://www.beakersoft.co.uk</link>
  <url>http://www.beakersoft.co.uk/wordpress/wp-content/themes/Beakersoft/favicon.ico</url>
  <title>Beakersoft Blog</title>
</image>
	<atom:link rel='hub' href='http://www.beakersoft.co.uk/?pushpress=hub'/>
		<item>
		<title>Passing Optional Parameters To Stored Procedure</title>
		<link>http://www.beakersoft.co.uk/2007/07/03/passing-optional-parameters-to-stored-procedure/</link>
		<comments>http://www.beakersoft.co.uk/2007/07/03/passing-optional-parameters-to-stored-procedure/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 16:31:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2007/07/03/passing-optional-parameters-to-stored-procedure/</guid>
		<description><![CDATA[Found quite a cool thing recently, that means you can have optional parameters in a SQL stored procedure. This means you can pass the options into the procedure if you have some, or if none are passed get the SP to use some defaults instead. It took a while to get the syntax correct, but [...]]]></description>
			<content:encoded><![CDATA[<p>Found quite a cool thing recently, that means you can have optional parameters in a SQL stored procedure.<br />
This means you can pass the options into the procedure if you have some, or if none are passed get the SP to use some defaults instead. It took a while to get the syntax correct, but its fairly straight forward, in this example we will use the year and month as optional parameters:</p>
<p>@year int = NULL, @month char(20) = NULL<br />
AS</p>
<p>if ISNULL (@year, 0) = 0<br />
begin<br />
SELECT @month = DATENAME(month, GETDATE())<br />
SELECT @year = DATENAME(year, GETDATE())<br />
end</p>
<p>First of all we declare the 2 variables, then we check if the first one is NULL (nothing passed). If it is then we set both the month and year to be the current month and year. Simple but effective!</p>
<p>I have another article published at <a href="http://www.aspfree.com/">aspfree.com</a>, this one is about creating a simple RSS feed using ASP.net, written in c#. Read it <a href="http://www.aspfree.com/c/a/C-Sharp/Creating-an-RSS-Feed-with-ASP-Net-Written-in-C-Sharp/">HERE</a><a href="http://www.aspfree.com/c/a/C-Sharp/Creating-an-RSS-Feed-with-ASP-Net-Written-in-C-Sharp/"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2007/07/03/passing-optional-parameters-to-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integration Heartache</title>
		<link>http://www.beakersoft.co.uk/2007/04/22/integration-heartache/</link>
		<comments>http://www.beakersoft.co.uk/2007/04/22/integration-heartache/#comments</comments>
		<pubDate>Sun, 22 Apr 2007 16:15:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2007/04/22/integration-heartache/</guid>
		<description><![CDATA[Not really been learning to much new over the last couple of weeks. We have been moving the Isle of Mans system &#8216;mainland&#8217; and integrating them into ours. Found a useful feature of the SQL 2005 Enterprise manager though. We were doing a lot of dumping and loading databases, and wanted to write a SQL [...]]]></description>
			<content:encoded><![CDATA[<p>Not really been learning to much new over the last couple of weeks. We have been moving the Isle of Mans system &#8216;mainland&#8217; and integrating them into ours.<br />
Found a useful feature of the SQL 2005 Enterprise manager though. We were doing a lot of dumping and loading databases, and wanted to write a SQL script that would do it, but couldn&#8217;t find the correct syntax.<br />
My boss then noticed that you can get Enterprise manager to &#8216;script&#8217; certain tasks. Restoring a database was on of them. When you do the restore there is an option at the top left, it will save to a script what is currently set, or output it to a new window. Very Useful.</p>
<p>On another project I found out how to send optional parameters to a SQL stored procedure. When you declare the variables, make them <span style="font-style: italic">= Null </span>and you don&#8217;t have to pass anything!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2007/04/22/integration-heartache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Memory Managment in SQL Server</title>
		<link>http://www.beakersoft.co.uk/2007/03/30/memory-managment-in-sql-server/</link>
		<comments>http://www.beakersoft.co.uk/2007/03/30/memory-managment-in-sql-server/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 17:04:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2007/03/30/memory-managment-in-sql-server/</guid>
		<description><![CDATA[For quite a while, we have had a problem with our main instance of SQL server not using all the memory available to it on the server. We have finally found out what the problem was thanks to this article - http://www.sql-server-performance.com/sql_server_performance_audit5.asp The scenario is we have a clustered instance of SQL, that can run [...]]]></description>
			<content:encoded><![CDATA[<p>For quite a while, we have had a problem with our main instance of SQL server not using all the memory available to it on the server. We have finally found out what the problem was thanks to this article -<a href="http://www.sql-server-performance.com/sql_server_performance_audit5.asp"> </a><a href="http://www.sql-server-performance.com/sql_server_performance_audit5.asp" style="color: #3333ff">http://www.sql-server-performance.com/sql_server_performance_audit5.asp</a></p>
<p>The scenario is we have a clustered instance of SQL, that can run on one of 3 identically spec&#8217;d server running Windows2003 Enterprise, SQL 2000 Enterprise and with 16gig of ram.</p>
<p>The sqlsvr process had only been running at about 3gig of memory, and was causing us some performance issues on busy days. We had found some articles about changing boot.ini that told windows to use the extra memory, but it didn&#8217;t seam to help. Here are the steps:</p>
<ol>
<li>Open up boot.ini (its normally hidden but lives in the root of c:\)</li>
<li>At the end of the line for the OS you boot to, add /3GB /PAE. This basicly tells Windows 2003 that it and SQL server have access to more than 4gig of Ram, and they can use it</li>
<li>Next you have to set the &#8216;awe enable&#8217; option of SQL server to 1. This enables the API in SQL server and give it access to the extra memory</li>
<li>Open up SQL query analyser,  and type:<br />
<span style="color: #3333ff">sp_configure &#8216;awe enabled&#8217;, 1</span><br />
<span style="color: #3333ff">go</span><br />
<span style="color: #3333ff">Reconfigure with overide</span><br />
<span style="color: #3333ff">go</span></li>
<li><span style="color: #3333ff"><span style="color: #000000">When you have done this, restart the server. When you bring it back up, SQL server should have access to all the memory available in the system. You can now tell SQL server how much memory to use in the servers properties, but you now have to specify a a specific amount and   not a range.</span></span></li>
</ol>
<p>Also something else I found while doing this, the port that a clustered instance of SQL runs on is 1267, the port it runs on when not clustered is 1433.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2007/03/30/memory-managment-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring SQL Server using SQL Server Health and History Tool (SQLH2)</title>
		<link>http://www.beakersoft.co.uk/2006/12/17/monitoring-sql-server-using-sql-server-health-and-history-tool-sqlh2/</link>
		<comments>http://www.beakersoft.co.uk/2006/12/17/monitoring-sql-server-using-sql-server-health-and-history-tool-sqlh2/#comments</comments>
		<pubDate>Sun, 17 Dec 2006 12:11:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2006/12/17/monitoring-sql-server-using-sql-server-health-and-history-tool-sqlh2/</guid>
		<description><![CDATA[A couple of weeks ago my boss came across this tool called SQLH2. Its purpose is to monitor Microsoft SQL server, by collecting data about how the machine is performing and optionally what the SQL server services are doing. The main part is one executable file that you schedule to run every day or so. [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago my boss came across this tool called SQLH2. Its purpose is to monitor Microsoft SQL server, by collecting data about how the machine is performing and optionally what the SQL server services are doing.</p>
<p>The main part is one executable file that you schedule to run every day or so. This collects data about the server, how it is performing and what the state of the sql servers are running on that machine. It logs all this info into a sql server database.</p>
<p>The second part is a service that runs every few mins, and collects SQL server performance counter data. These get put into a local file and when the afore mentioned exe runs this data gets put into the database as well.</p>
<p>Lastly there is a suite of SQL reporting services reports ready made to look at the database, and provide you with all the information it has collected.</p>
<p>I did run into a couple of problems when installing it, the documentation is quite good but the interface to configure it is a bit clumsy you might be better of editing the xml config files by hand.<br />
First thing is if you want to collect perf data from more than one machine at a central point, make sure you share the SQLH2\data directory&#8217;s on the remote servers out as SQLH2PerfCollector$, and make sure the user running the exe has access to this folder.<br />
Also I found it helped to run the perf collector service as a domain user.</p>
<p>Then, on the server that is collecting the data, make sure you add a new target section the the H2PerfConfigFile.xml file, with the relevant counters. There doesn&#8217;t seam to be anyway to do this using the GUI config application.</p>
<p>Once you are up and running it seams to create some very useful stats, that might help in your next push for a server upgrade!</p>
<p>The only thing I couldn&#8217;t get working (and I&#8217;m not sure if you can do it) was monitoring a SQL server instance on a cluster. When running the app, even on the server that was currently running the database it didn&#8217;t find the instance. If any one has got this working can you let drop me and email on how to get it working.</p>
<p>Download the SQLH2 <a href="http://www.microsoft.com/downloads/details.aspx?familyid=EEDD10D6-75F7-4763-86DE-D2347B8B5F89&amp;displaylang=en">here</a></p>
<p><span style="font-weight: bold">Update 28/12 </span>- I emailed Microsoft about using it on a cluster, and the responded saying that it was&#8217;nt cluster aware. They did say though that you should be able to use the performance counters section by adding it to the xml config file on another machine. I haven&#8217;t managed to get this working yet though. If anyone does please let me know</p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2006/12/17/monitoring-sql-server-using-sql-server-health-and-history-tool-sqlh2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting SQL Report Server usage</title>
		<link>http://www.beakersoft.co.uk/2006/12/03/getting-sql-report-server-usage/</link>
		<comments>http://www.beakersoft.co.uk/2006/12/03/getting-sql-report-server-usage/#comments</comments>
		<pubDate>Sun, 03 Dec 2006 19:23:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2006/12/03/getting-sql-report-server-usage/</guid>
		<description><![CDATA[A couple of days ago some of our users were complaining about the speed at witch the reports were running. I suspected that they were running some huge reports to get some year end data, but of course they denide that. I had seen a couple of tables that reporting services uses, and started poking [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago some of our users were complaining about the speed at witch the reports were running.</p>
<p>I suspected that they were running some huge reports to get some year end data, but of course they denide that. I had seen a couple of tables that reporting services uses, and started poking about in those.</p>
<p>After a bit i managed to come up with the following sql that gave me a list of what reports had been run, who ran them, what parameters they used and how long they took to run:</p>
<p>SELECT TOP (100) PERCENT dbo.Catalog.Name, dbo.ExecutionLog.UserName, DATEDIFF(mi, dbo.ExecutionLog.TimeStart, dbo.ExecutionLog.TimeEnd)<br />
AS Proc_time, dbo.ExecutionLog.Parameters, dbo.ExecutionLog.TimeStart<br />
FROM dbo.ExecutionLog RIGHT OUTER JOIN<br />
dbo.Catalog ON dbo.ExecutionLog.ReportID = dbo.Catalog.ItemID<br />
WHERE (dbo.ExecutionLog.TimeStart &gt; CONVERT(DATETIME, &#8217;2006-12-01 00:00:01&#8242;, 102))<br />
ORDER BY Proc_time</p>
<p>Please note that this works in SQL 2005 reporting services, i&#8217;m not sure if it will in previous versions. To run for different dates, just change TimeStart&#8217;s parameter</p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2006/12/03/getting-sql-report-server-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mail Profile in SQL Server</title>
		<link>http://www.beakersoft.co.uk/2006/11/28/mail-profile-in-sql-server/</link>
		<comments>http://www.beakersoft.co.uk/2006/11/28/mail-profile-in-sql-server/#comments</comments>
		<pubDate>Tue, 28 Nov 2006 19:44:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2006/11/28/mail-profile-in-sql-server/</guid>
		<description><![CDATA[Tried to setup SQL 2000 today so it would email me when certain events occurred, I have done it before but it took me a bit to work out why it wouldn&#8217;t work this time. Couple of things I had to do: I needed to install Outlook mail client on the pc. (I suppose any [...]]]></description>
			<content:encoded><![CDATA[<p>Tried to setup SQL 2000 today so it would email me when certain events occurred, I have done it before but it took me a bit to work out why it wouldn&#8217;t work this time. Couple of things I had to do:</p>
<ul>
<li>I needed to install Outlook mail client on the pc. (I suppose any mail client will  do as long as it allows you to setup a mail profile)</li>
<li>The account that I was running the sql server agent service as was a domain account not the default system one. To get it to see a mail profile I had to login to the server as the user I was running the service as, and setup outlook so it had a mail profile.</li>
<li>I was using a mailbox we setup to receive log files from, so it was created under a different user. I had to give the user the SQL agent service was running as rights into this mailbox.</li>
<li>After a restart of the Agent service I could then send mail.</li>
</ul>
<p>I also come across something else today witch look quite cool. Its called the SQL Server Health and History tool, and can be downloaded <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=eedd10d6-75f7-4763-86de-d2347b8b5f89&amp;DisplayLang=en">here</a><br />
It will log various things about SQL installs to a database, and there is a report pack you can download so you can look at the info.<br />
I&#8217;ve not managed to get the performance counters  working yet, and its only logging from one server but when I get it all working ill write it up on here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2006/11/28/mail-profile-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Usful SQL String Function (coalesce)</title>
		<link>http://www.beakersoft.co.uk/2006/11/26/usful-sql-string-function-coalesce/</link>
		<comments>http://www.beakersoft.co.uk/2006/11/26/usful-sql-string-function-coalesce/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 15:33:00 +0000</pubDate>
		<dc:creator>beakersoft</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.beakersoft.co.uk/2006/11/26/usful-sql-string-function-coalesce/</guid>
		<description><![CDATA[I found this function a couple of weeks ago and found it very usful. I had to add a filed to a report, that contained a list of other fileds from the report, each seperated by a comma. At first i thought i&#8217;d have to write some custom code, but then I found the COALESCE [...]]]></description>
			<content:encoded><![CDATA[<p>I found this function a couple of weeks ago and found it very usful. I had to add a filed to a report, that contained a list of other fileds from the report, each seperated by a comma. At first i thought i&#8217;d have to write some custom code, but then I found the COALESCE function.<br />
You can use this in the following way, to create one output from x number of records, seperated by a comma.</p>
<p>DECLARE @aa varchar(100)</p>
<p>SELECT @aa = COALESCE (@aa + &#8216;, &#8216;, &#8221;) + CAST(name AS varchar(5))<br />
FROM tbl_Customer</p>
<p>WHERE (Customer_bal &gt; 10)<br />
SELECT @aa AS Names</p>
<p>I then added this sql to a sub report and passed the id of the line to it, so I could then have this showing for each record. The time it took to render the report increased, but the user got the information they needed.<br />
I then had to write some custom code into the report so it would sort the results in a predictable way. You can read more about the function <a href="http://www.sqlteam.com/item.asp?ItemID=2368">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.beakersoft.co.uk/2006/11/26/usful-sql-string-function-coalesce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
