<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: VBA, SQL, Dates and Strings - the habits we form.</title>
	<link>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/</link>
	<description></description>
	<pubDate>Sun, 12 Oct 2008 08:18:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.1</generator>

	<item>
		<title>by: Dick Kusleika</title>
		<link>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-24946</link>
		<pubDate>Tue, 16 Oct 2007 20:57:19 +0000</pubDate>
		<guid>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-24946</guid>
					<description>IIRC = If I recall correctly</description>
		<content:encoded><![CDATA[<p>IIRC = If I recall correctly
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ralph W Lundvall</title>
		<link>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-24942</link>
		<pubDate>Tue, 16 Oct 2007 19:32:47 +0000</pubDate>
		<guid>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-24942</guid>
					<description>In the example I gave, there were no line continuations. String variables were concantenated together. What is IIRC?</description>
		<content:encoded><![CDATA[<p>In the example I gave, there were no line continuations. String variables were concantenated together. What is IIRC?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Dianne Butterworth</title>
		<link>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-19794</link>
		<pubDate>Thu, 26 Jul 2007 16:25:28 +0000</pubDate>
		<guid>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-19794</guid>
					<description>There is a limit to how line continuations you can use (IIRC it's 24) and my SQL statements are frequently longer than that!</description>
		<content:encoded><![CDATA[<p>There is a limit to how line continuations you can use (IIRC it&#8217;s 24) and my SQL statements are frequently longer than that!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ralph W Lundvall</title>
		<link>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-11965</link>
		<pubDate>Tue, 29 May 2007 21:40:05 +0000</pubDate>
		<guid>http://www.blog.methodsinexcel.co.uk/2007/03/21/vba-sql-dates-and-strings-and-the-habits-we-form/#comment-11965</guid>
					<description>Since most of my SQL statements are to be manipulated by code I first make an Access query in query designer. Then switch it to the SQL text. That text is copied to the inside of a formula like this:
Function SQLdemo(var1 as String.....,) as string
SQL text goes here.

End Function

Then I make 4 or 5 variables named line1, line2... line5 (one for each line of the SQL statement)

So it looks like this:
Function SQLdemo(tablenamehere as String.....,) as string
Dim line1, line2, line3, line4, line5 as String
line1 = &quot;INSERT INTO......&quot;
line2 = &quot;SELECT ....&quot;
line3 = &quot;FROM &quot; &amp;#38; tablenamehere &amp;#38; &quot; INNER JOIN.....&quot;
line4 = &quot;WHERE....&quot;
'etc. as needed.
SQLdemo = line1 &amp;#38; line2 &amp;#38; line3 &amp;#38; line4 &amp;#38; ....
End Function

Then I go through the text and place the variables.  Above just demonstrates the variable tablenamehere being the name of a table.
When done I have a formula which will output a valid SQL statement and I have control of what values I will feed it in the code that does the work. 

Most of these SQL creation functions will add to a collector database table. When finished, the table has all the answers needed. I pull out the answer I need using Excel and other formulas (using Application.vlookup).

Anyway, that's how I do it.</description>
		<content:encoded><![CDATA[<p>Since most of my SQL statements are to be manipulated by code I first make an Access query in query designer. Then switch it to the SQL text. That text is copied to the inside of a formula like this:<br />
Function SQLdemo(var1 as String&#8230;..,) as string<br />
SQL text goes here.</p>
<p>End Function</p>
<p>Then I make 4 or 5 variables named line1, line2&#8230; line5 (one for each line of the SQL statement)</p>
<p>So it looks like this:<br />
Function SQLdemo(tablenamehere as String&#8230;..,) as string<br />
Dim line1, line2, line3, line4, line5 as String<br />
line1 = &#8220;INSERT INTO&#8230;&#8230;&#8221;<br />
line2 = &#8220;SELECT &#8230;.&#8221;<br />
line3 = &#8220;FROM &#8221; &amp; tablenamehere &amp; &#8221; INNER JOIN&#8230;..&#8221;<br />
line4 = &#8220;WHERE&#8230;.&#8221;<br />
&#8216;etc. as needed.<br />
SQLdemo = line1 &amp; line2 &amp; line3 &amp; line4 &amp; &#8230;.<br />
End Function</p>
<p>Then I go through the text and place the variables.  Above just demonstrates the variable tablenamehere being the name of a table.<br />
When done I have a formula which will output a valid SQL statement and I have control of what values I will feed it in the code that does the work. </p>
<p>Most of these SQL creation functions will add to a collector database table. When finished, the table has all the answers needed. I pull out the answer I need using Excel and other formulas (using Application.vlookup).</p>
<p>Anyway, that&#8217;s how I do it.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
