<?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>Clarion Edge &#187; SQL</title>
	<atom:link href="http://www.clarionedge.com/category/clarion/sql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.clarionedge.com</link>
	<description>Get an Edge with Clarion!</description>
	<lastBuildDate>Mon, 06 Feb 2012 13:58:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>SQL Data Connection Dialog Source Code</title>
		<link>http://www.clarionedge.com/windows/development/sql-data-connection-dialog-source-code.html</link>
		<comments>http://www.clarionedge.com/windows/development/sql-data-connection-dialog-source-code.html#comments</comments>
		<pubDate>Tue, 09 Aug 2011 19:25:10 +0000</pubDate>
		<dc:creator>brahn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.clarionedge.com/windows/development/sql-data-connection-dialog-source-code.html</guid>
		<description><![CDATA[Whilst looking for something else today I came across this little nugget. Something that should&#160; be handy for anyone connecting to SQL servers wanting to build a connection string at runtime.
Here is a link to [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst looking for something else today I came across this little nugget. Something that should&#160; be handy for anyone connecting to SQL servers wanting to build a connection string at runtime.</p>
<p>Here is a link to the blog:</p>
<p><a href="http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-code-is-released-on-code-gallery.aspx" target="_blank">Data Connection Dialog Source Code is released on Code Gallery!</a></p>
<p>And a link to the source code just in case:</p>
<p><a title="http://code.msdn.microsoft.com/Connection/" href="http://code.msdn.microsoft.com/Connection/">http://code.msdn.microsoft.com/Connection/</a></p>
<p>&#160;</p>
<p>Enjoy,   <br />Brahn</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clarionedge.com/windows/development/sql-data-connection-dialog-source-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recommended reading for anyone dealing with MSSQL</title>
		<link>http://www.clarionedge.com/clarion/sql/recommended-reading-for-anyone-dealing-with-mssql.html</link>
		<comments>http://www.clarionedge.com/clarion/sql/recommended-reading-for-anyone-dealing-with-mssql.html#comments</comments>
		<pubDate>Fri, 17 Jun 2011 08:38:10 +0000</pubDate>
		<dc:creator>brahn</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.clarionedge.com/clarion/sql/recommended-reading-for-anyone-dealing-with-mssql.html</guid>
		<description><![CDATA[I am not sure if I have mentioned this blog before but it is worth mentioning again anyway. I always enjoy reading the articles over at SQL Fool, I have learnt a lot there! The [...]]]></description>
			<content:encoded><![CDATA[<p>I am not sure if I have mentioned this blog before but it is worth mentioning again anyway. I always enjoy reading the articles over at <a href="http://sqlfool.com/" target="_blank">SQL Fool</a>, I have learnt a lot there! The updates are not that frequent but they are worth waiting for. </p>
<p>Todays update: <a href="http://sqlfool.com/2011/06/index-defrag-script-v4-1/" target="_blank">Index Defrag Script, v4.1</a></p>
<p>-brahn</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clarionedge.com/clarion/sql/recommended-reading-for-anyone-dealing-with-mssql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Management Studio add-in</title>
		<link>http://www.clarionedge.com/windows/tools/sql-server-management-studio-add-in.html</link>
		<comments>http://www.clarionedge.com/windows/tools/sql-server-management-studio-add-in.html#comments</comments>
		<pubDate>Wed, 03 Nov 2010 09:14:49 +0000</pubDate>
		<dc:creator>brahn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.clarionedge.com/windows/tools/sql-server-management-studio-add-in.html</guid>
		<description><![CDATA[&#160;
I discovered this little beauty the other day, SSMS Tools Pack for Microsoft SQL Server Management Studio from a developer in Slovenia. I haven’t had a chance to make use of everything in the package [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>I discovered this little beauty the other day, <a href="http://www.ssmstoolspack.com" target="_blank">SSMS Tools Pack</a> for Microsoft SQL Server Management Studio from a <a href="http://www.ssmstoolspack.com/About" target="_blank">developer in Slovenia</a>. I haven’t had a chance to make use of everything in the package yet but so for it has been pretty neat. The <a href="http://www.ssmstoolspack.com/Features?f=2" target="_blank">Query Execution History</a> has been pretty handy.</p>
<p>&#160;</p>
<p>From the website:</p>
<blockquote><p>SSMS Tools Pack is an add-in for Microsoft SQL Server Management Studio (SSMS) 2005, 2008, 2008 R2 and their respective Express versions.     <br />It contains a few upgrades to the SSMS IDE that I thought were missing.</p>
</blockquote>
<p>&#160;</p>
<p><a href="http://www.clarionedge.com/wp-content/uploads/image33.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.clarionedge.com/wp-content/uploads/image_thumb25.png" width="244" height="191" /></a></p>
<p>&#160;</p>
<p>Get it here &#8211; <a title="http://www.ssmstoolspack.com/" href="http://www.ssmstoolspack.com/">http://www.ssmstoolspack.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clarionedge.com/windows/tools/sql-server-management-studio-add-in.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trailing spaces in strings &#8211; Clarion vs SQL</title>
		<link>http://www.clarionedge.com/clarion/trailing-spaces-in-strings-clarion-vs-sql.html</link>
		<comments>http://www.clarionedge.com/clarion/trailing-spaces-in-strings-clarion-vs-sql.html#comments</comments>
		<pubDate>Thu, 19 Feb 2009 16:54:22 +0000</pubDate>
		<dc:creator>brahn</dc:creator>
				<category><![CDATA[Clarion]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.clarionedge.com/?p=209</guid>
		<description><![CDATA[This topic came up at work a while ago when trying to perform database operations on strings containing a trailing space.
The Problem: One of our stored procedures was using CHARINDEX to search for strings within [...]]]></description>
			<content:encoded><![CDATA[<p>This topic came up at work a while ago when trying to perform database operations on strings containing a trailing space.</p>
<p>The Problem: One of our stored procedures was using CHARINDEX to search for strings within the database. The problem appeared when a user defined a search parameter containing a trailing space and the results of the search were not as expected.</p>
<h2>SQL and Trailing Blanks</h2>
<p>(From the section &#8220;Comparison operators, listed&#8221; in SQL help)</p>
<p>Trailing blanks are ignored in comparisons; for example, these are equivalent:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">WHERE</span> LastName <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'White'</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> LastName <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'White '</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> LastName <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'White'</span> <span style="color: #66cc66;">+</span> <span style="color: #993333; font-weight: bold;">SPACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This is an interesting article: <a href="http://support.microsoft.com/kb/316626">INF: How SQL Server Compares Strings with Trailing Spaces</a></p>
<p>Sort of related but actually about how data is stored is the ANSI_PADDING setting:</p>
<p><a href="http://technet.microsoft.com/en-us/library/ms187403.aspx">http://technet.microsoft.com/en-us/library/ms187403.aspx</a></p>
<h2>Display Trailing Space in Clarion</h2>
<p>The Clarion entry control and text control don&#8217;t appear to be able to show trailing spaces from data in a database. You can enter trailing spaces in an entry or text control and save the data but next time you view or edit the form those trailing spaces are not shown.</p>
<p>Funnily enough, if the data <em>does </em>have trailing spaces and the field is not edited then the trailing spaces remain intact when the form is saved.</p>
<h2>Fun with SELECT Statements</h2>
<p>Have a play with the following SQL to see some examples:</p>
<p><em>Note the use of &#8220;LIKE&#8221; rather than &#8220;=&#8221; and the &#8220;[^ ]&#8221; will force the WHERE to only match items without the trailing space.<br />
</em><em>Also, try setting the ANSI_PADDING to &#8220;OFF&#8221; and see the difference in the results.</em></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SET</span> ANSI_PADDING <span style="color: #993333; font-weight: bold;">ON</span>;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> t1 <span style="color: #66cc66;">&#40;</span>charcol <span style="color: #993333; font-weight: bold;">CHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span> varcharcol <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> t1 <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'No blanks'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'No blanks'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> t1 <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Trailing blank '</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Trailing blank '</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> t1 <span style="color: #993333; font-weight: bold;">WHERE</span> varcharcol <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'No blanks     '</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> t1 <span style="color: #993333; font-weight: bold;">WHERE</span> charcol <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'No blanks     '</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> t1 <span style="color: #993333; font-weight: bold;">WHERE</span> varcharcol <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Trailing blank[^ ]'</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> t1 <span style="color: #993333; font-weight: bold;">WHERE</span> charcol <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'Trailing blank[^ ]'</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> t1</pre></div></div>

<p>So there are a few thoughts and discoveries that came up in the course of investigating this issue. Of course once you know the reasons there are ways to workaround the problems but I will leave that up to your individual scenario&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clarionedge.com/clarion/trailing-spaces-in-strings-clarion-vs-sql.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Temp Tables, Scope and Clarion</title>
		<link>http://www.clarionedge.com/clarion/sql/temp-tables-scope-and-clarion.html</link>
		<comments>http://www.clarionedge.com/clarion/sql/temp-tables-scope-and-clarion.html#comments</comments>
		<pubDate>Tue, 11 Mar 2008 18:20:26 +0000</pubDate>
		<dc:creator>brahn</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.clarionedge.com/?p=17</guid>
		<description><![CDATA[I was discussing this with a colleague yesterday and thought everyone might be interested in the outcome.
Problem: 
I was getting an error &#8220;There is already an object named &#8216;PK_SUPPLIERPRODUCTID&#8217; in the database.&#8221; when trying to [...]]]></description>
			<content:encoded><![CDATA[<p>I was discussing this with a colleague yesterday and thought everyone might be interested in the outcome.</p>
<p><strong>Problem: </strong></p>
<p>I was getting an error &#8220;<em>There is already an object named &#8216;PK_SUPPLIERPRODUCTID&#8217; in the database.</em>&#8221; when trying to create a temp table.</p>
<p><strong>Scenario: </strong></p>
<ul>
<li>A temp table (&#8216;#Temp&#8217; &amp; Thread()) was created initially in a window procedure on thread 2.</li>
<li>That window was then closed and later opened on a different thread number e.g. 3.</li>
<li>When the CREATE TABLE is called the second time I was getting the above error.</li>
</ul>
<p><span id="more-17"></span></p>
<p><strong>Original SQL:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> #Temp <span style="color: #66cc66;">&#40;</span>SUPPLIERPRODUCTID <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> PK_SUPPLIERPRODUCTID <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p><strong>Gotcha&#8217;s:</strong></p>
<ul>
<li>Normally the details of a temp table are &#8220;session&#8221; dependent. It seems that because I was explicitly naming the primary key (PK_SUPPLIERPRODUCTID) this was somehow bypassing the way temp tables are assigned session unique names.</li>
<li>Scope of SQL temp tables:
<ul>
<li>&#8220;All other local temporary tables are dropped automatically at the end of the  current session.&#8221;</li>
</ul>
<ul>
<li>I had always thought that a &#8220;session&#8221; would mean the Clarion Thread connection.
<ul>
<li>It kinda does and kinda doesn&#8217;t.</li>
<li>Temp tables are assigned uniqueness based on the clarion thread connection <strong><em>but </em></strong>they are not removed from the database when the clarion thread closes.</li>
<li>They are only actually dropped from the SQL tempdb when the clarion application closes!</li>
</ul>
</li>
</ul>
</li>
</ul>
<p><strong>Solutions:</strong></p>
<ul>
<li>Don&#8217;t explicitly name the primary key! This works without error:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> #Temp <span style="color: #66cc66;">&#40;</span>SUPPLIERPRODUCTID <span style="color: #993333; font-weight: bold;">INT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

</li>
<li>If you do a &#8220;CREATE TABLE&#8221; then try and make sure to do a &#8220;DROP TABLE&#8221; once you are done (perhaps as well as before the create?).
<ul>
<li>This has the added benefit of keeping the tempdb cleaner.</li>
</ul>
<ul>
<li>I guess this is just basic house keeping like in clarion when you must always New/Dispose.</li>
</ul>
</li>
</ul>
<p><span class="info"> Disclaimer: I don&#8217;t claim to be an SQL expert, these are my observations and my solutions. I would love to hear any comments!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.clarionedge.com/clarion/sql/temp-tables-scope-and-clarion.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.clarionedge.com/category/clarion/sql/feed ) in 0.49717 seconds, on Feb 7th, 2012 at 11:17 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 7th, 2012 at 12:17 pm UTC -->
