<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Flexuous</title>
	<atom:link href="http://blog.flexuous.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexuous.com</link>
	<description>Just another WordPress.com weblog</description>
	<pubDate>Mon, 10 Nov 2008 19:28:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/764a979eb5e6d7a04cb032aed1031343?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Flexuous</title>
		<link>http://blog.flexuous.com</link>
	</image>
			<item>
		<title>Alternating between CF7 and CF8 running under IIS</title>
		<link>http://blog.flexuous.com/2008/11/10/alternating-between-cf7-and-cf8-running-under-iis/</link>
		<comments>http://blog.flexuous.com/2008/11/10/alternating-between-cf7-and-cf8-running-under-iis/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 19:24:07 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/?p=62</guid>
		<description><![CDATA[I know everyone knows that you can run both ColdFusion 7 and ColdFusion 8 on the same machine at the same time.   The common way to do this is to run one or both using the built in web server.  Now while this works I found that it is quite easy to switch IIS integration between ColdFusion 7 and 8 allowing both to run this way when needed.]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Not sure if anyone else has a need for this information but I figured I would go ahead an post it just in case anyone might find it useful.</p>
<p>I know everyone knows that you can run both ColdFusion 7 and ColdFusion 8 on the same machine at the same time.   The common way to do this is to run one or both using the built in web server.  Now while this works I found that it is quite easy to switch IIS integration between ColdFusion 7 and 8 allowing both to run this way when needed.</p>
<p>I upgraded my local development environment to ColdFusion 8 about a year ago however my corporate development environment is still at ColdFusion 7.  90% of the time this is not a problem just as long as I am aware of what is and is not available.  (Mainly I have to make sure that I still use EQ, NEQ, GT etc&#8230;)    The one area that I found it necessary to have ColdFusion 7 for is for configuring the Flex / AMF gateway  (services-config.xml).</p>
<p>I do not have direct access to these configuration files on my corporate dev server (or ability to restart the server)  This is not usually a problem but can make for extra steps in this case.   In order for me to request a new channel or destination to be added to the config file I need to write it up and send it to the system administrator and have him add it and then restart the server.  Because to of the extra steps involved I have to make sure that it is configured exactly correctly.</p>
<p>When I was simply using CF7 on my local box I would just get a copy of the service-config.xml file from the dev server and then copy and paste the channel and destination sections from my local service-config.xml file and then send it back to the system administrator.  However now with CF8 my settings may not directly match.  First there is the issue that by default ColdFusion 8 splits the channel definitions and destination definitions into two separate files services-config.xml and remoting-config.xml.   OK not too big a deal however now I have to make sure to consolidate the settings into the one services-config.xml file for movement to the server.</p>
<p>OK Well to get back to my point.  I needed to be able to run both CF8 and CF7 as if they were the only version installed and running through IIS on my local box so that I could effectivly test these configuration files before sending them to our system administrator.    In the end my solution was to install both and switch between them.</p>
<p>The set up is not that difficult.  I first installed ColdFusion 8 using the default install path of C:\ColdFusion8\.  I then stopped the services and renamed the CFIDE directory in the Inetpub\wwwroot directory to CFIDE8.  Then I installed ColdFusion 7 to the default install path of C:\CFusionMX7\.   Then renamed the CFIDE directory it created in the the Inetpub\wwwroot directory to CFIDE7.   Then I pull the shortcuts each of the Web Server Configuration tools out of their respective start menu locations and put them on my desktop and renamed them so I would know which version applied to which.</p>
<p>Now to switch between them I just follow a fairly simple process&#8230; I stop IIS, and the version of coldfusion that is running.  Then I open up that version&#8217;s Web Server Configuration tool and remove IIS from the list. I close that Web Server Configuration tool and open the other version&#8217;s Web Server Configuration tool and then Add IIS to it.  Then I go into the Inetpub\wwwroot directory and rename the CFIDE directory that is there back what it should be (If i WAS running CF8 then CFIDE8) and then rename the other CFIDE? to CFIDE (say CFIDE7 to CFIDE)   Now the correct version of CF is connected up to IIS, the correct CFIDE directory is in place and I can just restart IIS and the appropriate ColdFusion server and now I&#8217;m running under the other version.</p>
<p>This set up is not as easy as running both versions concurently, however I found that I rarely did that anyway as it ate up system resources.  Once it is set up, this only adds a few steps to switching over from one version to the other and further I am running through IIS for both versions.</p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=62&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/11/10/alternating-between-cf7-and-cf8-running-under-iis/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>
	</item>
		<item>
		<title>Flash Window opening off screen</title>
		<link>http://blog.flexuous.com/2008/09/03/flash-window-opening-off-screen/</link>
		<comments>http://blog.flexuous.com/2008/09/03/flash-window-opening-off-screen/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 18:02:34 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/2008/09/03/flash-window-opening-off-screen/</guid>
		<description><![CDATA[Here is a discription of the problem&#8230;
You have a laptop or other machine where you sometimes have 2 screens or monitors and at other times you only have one.  Sometimes when you open the Flash CS3 IDE (more often when only using one screen but sometimes with both) The IDE or dialog boxes open [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here is a discription of the problem&#8230;</p>
<p>You have a laptop or other machine where you sometimes have 2 screens or monitors and at other times you only have one.  Sometimes when you open the Flash CS3 IDE (more often when only using one screen but sometimes with both) The IDE or dialog boxes open way off screen. You can&#8217;t move it back and no matter what you do it won&#8217;t reset and just open on your primary (or only) screen.</p>
<p>The simplest solution I could find was to just delete the settings registry key</p>
<p>run regedit.exe and navigate to the following &#8220;folder&#8221;</p>
<p>HKEY_CURRENT_USER\Software\Adobe\Flash 9\Settings\</p>
<p>you should just be able to delete the Window value or reset it but this doesn&#8217;t always work for some reason.  So just delete the whole Settings folder.  Don&#8217;t worry Flash will rebuild it when you restart it.   If this still doesn&#8217;t work delete the whole Flash 9 tree &#8230; again Flash will rebuild it when you restart it.  (as always with regedit you should back up at least this part of the registry before messing with it&#8230; Don&#8217;t say I didn&#8217;t warn you.)</p>
<p>This fixed my problem&#8230; YMMV</p>
<p>If this post helps you&#8230; please leave a reply  Thanks!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=59&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/09/03/flash-window-opening-off-screen/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>
	</item>
		<item>
		<title>Patent Issued</title>
		<link>http://blog.flexuous.com/2008/06/03/patent-issued-2/</link>
		<comments>http://blog.flexuous.com/2008/06/03/patent-issued-2/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 08:14:32 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/2008/06/04/patent-issued-2/</guid>
		<description><![CDATA[My first patent was issued today from the US Patent and Trademark office. Patent number 07380665 issued June 3, 2008.

It might not mean a lot to many people but for as long as I can remember I&#8217;ve had ideas and inventions floating around in my head. A couple years ago I decided to start patenting [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>My first patent was issued today from the US Patent and Trademark office. Patent number 07380665 issued June 3, 2008.</p>
<p><img src="http://flexuous.files.wordpress.com/2008/06/3onbucket.jpg?w=393&#038;h=370" alt="3 on bucket" vspace="20" width="393" height="370" /></p>
<p>It might not mean a lot to many people but for as long as I can remember I&#8217;ve had ideas and inventions floating around in my head. A couple years ago I decided to start patenting my ideas&#8230;</p>
<p><span id="more-50"></span></p>
<p>This was the first of what I hope will be many more to come. So far I am working on three other patents with over a dozen other ideas just waiting for the time and money to be able to file.</p>
<p>For those that are interested I originally filed this patent application back in mid 2005, It was published one year later. It took almost two full years before it worked its way through the queue to a patent examiner. It was returned to me for some minor corrections late last year and approved early this year. After paying the fee to have it issued about two months ago, it was finnally issued today. The whole process took about 3 1/2 years and cost about $8000.</p>
<p>Here is a pdf of the patent.</p>
<p><a href="http://justinohms.files.wordpress.com/2008/06/uspatent007380665.pdf">http://justinohms.files.wordpress.com/2008/06/uspatent007380665.pdf</a></p>
<p>The patent is available for license.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/50/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/50/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/50/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/50/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/50/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=50&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/06/03/patent-issued-2/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>

		<media:content url="http://flexuous.files.wordpress.com/2008/06/3onbucket.jpg" medium="image">
			<media:title type="html">3 on bucket</media:title>
		</media:content>
	</item>
		<item>
		<title>Install server or ca certificate in Coldfusion or Java Virtual Machine</title>
		<link>http://blog.flexuous.com/2008/04/22/install-server-or-ca-certificate-in-coldfusion-or-java-virtual-machine/</link>
		<comments>http://blog.flexuous.com/2008/04/22/install-server-or-ca-certificate-in-coldfusion-or-java-virtual-machine/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 18:26:08 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/2008/04/22/install-server-or-ca-certificate-in-coldfusion-or-java-virtual-machine/</guid>
		<description><![CDATA[The other day I was working on a project in ColdFusion where I wanted to connect to a secure web server using CFHttp and do some screen scrapes.  The problem I encountered was that the server was using a self issued certificate that therefore did not have a proper certificate chain.  ColdFusion simply [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The other day I was working on a project in ColdFusion where I wanted to connect to a secure web server using CFHttp and do some screen scrapes.  The problem I encountered was that the server was using a self issued certificate that therefore did not have a proper certificate chain.  ColdFusion simply returned the following error:</p>
<p>I/O Exception: peer not authenticated<br />
 <img height="210" alt="coldfusioncerterror" src="http://flexuous.files.wordpress.com/2008/04/coldfusioncerterror.jpg?w=336&#038;h=210" width="336" vspace="20" /></p>
<p>After some detective work.. found out what the problem was and devised an effective solution which I provide you with now&#8230;.  You will need a couple of free tools and access to your server.  These instructions are for Windows based machines but the concepts and tools should work on Mac or Unix based platforms.</p>
<p><strong>1. Install and Setup Tools</strong><br />
Download and Install the Cert Viewer Plus plug-in for Firefox<br />
<a href="https://addons.mozilla.org/en-US/firefox/addon/1964">https://addons.mozilla.org/en-US/firefox/addon/1964</a></p>
<p>Download and install Portecle JVM certificate manager<br />
 (portecle-1.3.zip)  You do not need the source (src) version<br />
<a href="https://sourceforge.net/projects/portecle">https://sourceforge.net/projects/portecle</a><br />
The easiest way to install Portecle is to unzip the contents of the zip file to a directory such as C:\Program Files\portecle-1.3\    Then find the file &#8220;Portecle.jar&#8221;, right click it and send it to your desktop as a shortcut.  You can then use this shortcut to launch Portecle.  (optionally you can also change the name of the shortcut and change the icon to use the portecle.ico file for the icon)</p>
<p><strong>2. Extract the Certificate</strong><br />
If you cannot get the certificate you need directly from the issuer, you can get the certificate for the website you are trying to access from the Firefox certificate store using the Cert Viewer Plus plug-in for Firefox.</p>
<p>Under the [Tools] menu in Firefox select [Certificate Manager]. <br />
In the Certificate Manager screen, select the certificate desired on either the [Web Sites] or [Authorities] tab.  Select the [View] button. <br />
On the Certificate Viewer screen select [Export…]<br />
Select a save location and name for the certificate, save as an X.509 Certificate<br />
Remember the name and location of this certificate.</p>
<p><strong>3. Install Certificate to Java Virtual Machine and/or ColdFusion server<br /></strong>Start Portecele.<br />
On the [File] menu, select [Open Keystore File] navigate to and locate the keystore you are interested in.<br />
For many java installations this will be located in your &#8220;jre\lib\security&#8221; directory and might be named &#8220;cacerts&#8221; <br />
For the ColdFusion 8 default developer install the path will be &#8220;c:\coldfusion8\runtime\jre\lib\security\cacerts&#8221;<br />
You will have to enter the password for the keystore.  The default password is &#8220;changeit&#8221;</p>
<p>Now you are ready to import the key. <br />
From the [Tools] menu select [Import Trusted Certificate]   <br />
Navigate to and locate the certificate you saved from Firefox and click [Import]<br />
You will need to reenter the keystore password.<br />
You can change the alias if you desire but I would recommend leaving it as the default<br />
Note: You may also be prompted to &#8220;trust&#8221; the certificate.</p>
<p><strong>4. Restart you Java Virtual Machine. <br /></strong> For ColdFusion not installed on top of JRun you just need to restart the ColdFusion service.  If you are running on top of JRun you also need to restart JRun.</p>
<p>
Let me know if this works for you or if you have any further suggestions.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/45/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/45/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=45&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/04/22/install-server-or-ca-certificate-in-coldfusion-or-java-virtual-machine/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>

		<media:content url="http://flexuous.files.wordpress.com/2008/04/coldfusioncerterror.jpg" medium="image">
			<media:title type="html">coldfusioncerterror</media:title>
		</media:content>
	</item>
		<item>
		<title>Can your code be too structured?</title>
		<link>http://blog.flexuous.com/2008/04/21/can-your-code-be-too-structured/</link>
		<comments>http://blog.flexuous.com/2008/04/21/can-your-code-be-too-structured/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 16:09:27 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/2008/04/21/can-your-code-be-too-structured/</guid>
		<description><![CDATA[I recently had the opportunity to work with some code developed by [NAME WITHHELD TO PROTECT THE INNOCENT]    The code is absolutely great code, does some interesting things however&#8230;. it was just TOO well organized and way to verbose.   Now normally if I&#8217;m going to criticize someone&#8217;s coding style, (which [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I recently had the opportunity to work with some code developed by <em>[NAME WITHHELD TO PROTECT THE INNOCENT]  </em>  The code is absolutely great code, does some interesting things however&#8230;. it was just TOO well organized and way to verbose.   Now normally if I&#8217;m going to criticize someone&#8217;s coding style, (which I generally do not do) it would be for the exact opposite reason as this.  However this code was so well structured as to make it difficult to follow, and understand, much less fit on a screen. </p>
<p>Every argument for every CF tag began on it&#8217;s own line with every new tag separated by at least one line.  Thus causing a single cffunction definition header (without any actual code in) to run to 40+ lines.  As here</p>
<p><em><font color="white">[VARIABLE AND METHOD NAMES HAVE BEEN MODIFIED IN THE FOLLOWING CODE TO PROTECT THE AUTHORS IDENTITY]</font></em></p>
<blockquote>
<p> <font color="navy">&lt;cffunction<br />
  name=&#8221;functionName&#8221;<br />
  access=&#8221;public&#8221;<br />
  returntype=&#8221;any&#8221;<br />
  output=&#8221;false&#8221;<br />
  hint=&#8221;provides blah blah blah blah.&#8221;&gt;</font></p>
<p><font color="navy">  &lt;!&#8212; Define arguments. &#8212;&gt;<br />
  &lt;cfargument<br />
   name=&#8221;Name&#8221;<br />
   type=&#8221;string&#8221;<br />
   required=&#8221;true&#8221;<br />
   hint=&#8221;some name.&#8221;<br />
   /&gt;</font></p>
<p><font color="navy">  &lt;cfargument<br />
   name=&#8221;Type&#8221;<br />
   type=&#8221;string&#8221;<br />
   required=&#8221;true&#8221;<br />
   hint=&#8221;sometype.&#8221;<br />
   /&gt;</font></p>
<p><font color="navy">  &lt;cfargument<br />
   name=&#8221;Location&#8221;<br />
   type=&#8221;string&#8221;<br />
   required=&#8221;false&#8221;<br />
   default=&#8221;here&#8221;<br />
   hint=&#8221;some location&#8221;<br />
   /&gt;</font></p>
<p><strong>ETC&#8230;..</strong></p>
</blockquote>
<p>Additionally inside of a CFswitch statement &#8230; every case statement was preceded by the exact same comment and more than sufficiently spaced apart.</p>
<blockquote>
<p><font color="navy">&lt;cfswitch expression=&#8221;#whatsittype#&#8221;&gt;</font></p>
<p><font color="navy">   &lt;cfcase value=&#8221;1&#8243;&gt;</font></p>
<p><font color="navy">    &lt;!&#8212; exact same comment create a type of whatsit&#8212;&gt;<br />
    &lt;cfset scope.var = {<br />
     x = x,<br />
     y = y<br />
     } /&gt;</font></p>
<p><font color="navy">   &lt;/cfcase&gt;</font></p>
<p><font color="navy">   &lt;cfcase value=&#8221;2&#8243;&gt;</font></p>
<p><font color="navy">    &lt;!&#8212; exact same comment create a type of whatsit&#8212;&gt;<br />
    &lt;cfset scope.var = {<br />
     x = x,<br />
     y = y<br />
     z = z<br />
     } /&gt;</font></p>
<p><font color="navy">   &lt;/cfcase&gt;</font></p>
<p><font color="navy">   &lt;cfcase value=&#8221;3&#8243;&gt;</font></p>
<p><font color="navy">    &lt;!&#8212; exact same comment create a type of whatsit&#8212;&gt;<br />
    &lt;cfset scope.var = {<br />
     x = x,<br />
     b = b<br />
     e = e<br />
     z = z<br />
     } /&gt;</font></p>
<p><font color="navy">   &lt;/cfcase&gt;</font></p>
<p><font color="navy">   &lt;cfcase value=&#8221;4&#8243;&gt;</font></p>
<p><font color="navy">    &lt;!&#8212; exact same comment create a type of whatsit&#8212;&gt;<br />
    &lt;cfset scope.var = {<br />
     d = d,<br />
     y = y<br />
     z = z<br />
     } /&gt;</font></p>
<p><font color="navy">   &lt;/cfcase&gt;</font></p>
<p><strong>ETC&#8230;.</strong></p>
</blockquote>
<p>Now don&#8217;t think that I believe that code needs to be short&#8230; I am a big fan of white space where needed&#8230;  however if I need to scroll the screen to just read the method definition, there is a little too much verbosity in the code.  </p>
<p>Coding is very much a matter of personal preference however when publishing code to the public it is generally accepted to follow some general guidelines on form.  If you code in this style and share your code with the world&#8230; please take the time to condense your code prior to posting. </p>
<p>If you code in this style&#8230; why?  What are your opinions on this coding style, is it helpful or does it make more work for the next programmer?  What kind of style do you program in?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=43&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/04/21/can-your-code-be-too-structured/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Script To generate SQL Script</title>
		<link>http://blog.flexuous.com/2008/04/15/sql-script-to-generate-sql-script/</link>
		<comments>http://blog.flexuous.com/2008/04/15/sql-script-to-generate-sql-script/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 02:15:00 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/?p=42</guid>
		<description><![CDATA[Update! click here to see the sql generation script in a PDF file

Sorry for the odd format but WordPress oddly enough doesn&#8217;t allow users to upload simple text files&#8230;. Go figure.
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
Well I started out looking for a nice programmatic way to generate my SQL scripts that would generate them in dependency order&#8230;. While I found [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a rel="attachment wp-att-51" href="http://blog.flexuous.com/2008/04/15/sql-script-to-generate-sql-script/sqlgenerationscript/">Update! click here to see the sql generation script in a PDF file<br />
</a></p>
<p>Sorry for the odd format but WordPress oddly enough doesn&#8217;t allow users to upload simple text files&#8230;. Go figure.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Well I started out looking for a nice programmatic way to generate my SQL scripts that would generate them in dependency order&#8230;. While I found a few things here and there ultimately I ended up taking several of these ideas and creating my own.</p>
<p>I borrowed the part of the code that generates the procs and orders the code from <a href="http://www.eggheadcafe.com/articles/20030609.asp" target="_blank">Robbe D. Morris</a>.</p>
<p>I borrowed some of the code to generate the tables from <a href="http://www.knowmysize.com/blog/index.cfm?t=Generate_SQL_Tool&amp;mode=entry&amp;entry=13C052A0-7E9C-B5BD-BF8FCC7D2B9DCF91&amp;dv=link" target="_blank">Adam Howitt</a>.  I took his ColdFusion Generate SQL Tool and moved it into SQL.</p>
<p>I also found <a href="http://www.databasejournal.com/features/mssql/article.php/2205291" target="_blank">this</a> interesting article on using the program that SQL server itself uses but found it not practical for my purposes where I did not have file level access to the SQL server.</p>
<p>This code will run in MS SQL-2005 server and with some modifications would run in MS SQL-2000 server.  The only modifications needed should be to replace the <em>varchar(max)</em> with <em>varchar(7500). </em> Of course doing this will truncate script parts that are longer than 7500&#8230;  The net result of this could be two fold.  Table definitions that are longer than 7500 (not likely) will be truncated.  For script based items, view, sp and functions, references that occur after the 7500 char will not be taken into consideration, however the script should still generated correctly.</p>
<p>I make no warranty on this code&#8230; it should work. I used it about a month ago but have not had time to go back through and make sure it is all correct.  If you see anything that needs correction or would suggest an improvement please post it here.</p>
<blockquote><p><span style="font-size:xx-small;color:navy;">/**************************************************************************************************<br />
BEGIN TABLE SCRIPT CREATION (this header is repeated at the end)<br />
**************************************************************************************************/<br />
declare @ScriptTable TABLE<br />
(Script varchar(7500), Table_Name varchar(255), ScriptRow int )</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8211; ** Add the create table statment and the columns for the tables<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
set nocount ON</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @ScriptTable<br />
select Script, Table_Name, ScriptRow from<br />
(<br />
select space(30) +<br />
case when [Column_ID] = 1 then &#8216; &#8216; else &#8216;,&#8217; end +<br />
&#8216;['+Column_Name+'] ['+ Column_Type +']&#8216; +<br />
case<br />
when Column_Type in (&#8217;decimal&#8217;,'numeric&#8217;) then &#8216;(&#8217; +[Column_Precision]+&#8217;,'+[Column_Scale]+&#8217;)&#8217;<br />
when Column_Type in (&#8217;nvarchar&#8217;,'nchar&#8217;,'varchar&#8217;,'char&#8217;,'varbinary&#8217;,'binary&#8217;) then &#8216;(&#8217;+ [Column_Length] + &#8216;)&#8217;<br />
else &#8221;<br />
end<br />
+ &#8216; &#8216; + Identity_Script + &#8216; &#8216; + Column_Nullable</span></p>
<p><span style="font-size:xx-small;color:navy;">as [Script], [Table_Name], 1000+[Column_ID] as [ScriptRow]<br />
&#8211;,*<br />
from(<br />
select<br />
SO.id as [Table_ID],<br />
SO.name as [Table_Name],<br />
AC.[column_id] as [Column_ID],<br />
AC.[Name] as [Column_Name],<br />
type_name(AC.system_type_id) as [Column_Type],<br />
coalesce(SC.text,&#8221;) as [Column_Formula],</span></p>
<p><span style="font-size:xx-small;color:navy;">case<br />
when AC.[max_length] &lt;0 then &#8216;max&#8217;<br />
when type_name(AC.system_type_id) in (&#8217;nchar&#8217;,'nvarchar&#8217;) then cast(AC.[max_length]/2 as varchar(10))<br />
else cast(AC.[max_length] as varchar(10)) end as [Column_Length],<br />
&#8211;convert(int, AC.[max_length]) as [Column_Length],</span></p>
<p><span style="font-size:xx-small;color:navy;">case when type_name(AC.system_type_id) in (&#8217;tinyint&#8217;,&#8217;smallint&#8217;,'decimal&#8217;,'int&#8217;,'real&#8217;,'money&#8217;,'float&#8217;,'numeric&#8217;,&#8217;smallmoney&#8217;) then<br />
cast(AC.precision as varchar(20)) else &#8221; end as [Column_Precision],</span></p>
<p><span style="font-size:xx-small;color:navy;">case when type_name(AC.system_type_id) in (&#8217;tinyint&#8217;,&#8217;smallint&#8217;,'decimal&#8217;,'int&#8217;,'real&#8217;,'money&#8217;,'float&#8217;,'numeric&#8217;,&#8217;smallmoney&#8217;) then<br />
cast(AC.scale as varchar(20)) else &#8221; end as [Column_Scale],</span></p>
<p><span style="font-size:xx-small;color:navy;">CASE WHEN AC.[is_nullable] = 1 THEN &#8216;NULL&#8217; ELSE &#8216;NOT NULL&#8217; END as [Column_Nullable],<br />
AC.[is_identity] as [Is_Identity],<br />
CASE WHEN AC.[is_replicated] = 0 AND ac.[is_identity] = 1 THEN &#8216;NOT FOR REPLICATION&#8217; ELSE &#8221; END as [Column_Replication],<br />
AC.[is_ansi_padded] as [Is_ANSI_Padded],<br />
coalesce(IC.[name],&#8221;) as [Identity_Name],<br />
CASE WHEN IC.[name] is not null THEN cast(ident_seed(SO.name) as varchar(10)) ELSE &#8221; END as [Identity_Seed],<br />
CASE WHEN IC.[name] is not null THEN cast(ident_incr(SO.name) as varchar(10)) ELSE &#8221; END as [Identity_Increment],</span></p>
<p><span style="font-size:xx-small;color:navy;">CASE WHEN IC.[name] is not null THEN &#8216;IDENTITY(&#8217;+ cast(ident_seed(SO.name) as varchar(10)) + &#8216;,&#8217; + cast(ident_incr(SO.name) as varchar(10)) + &#8216;)&#8217; ELSE &#8221; END as [Identity_Script]</span></p>
<p><span style="font-size:xx-small;color:navy;">from [sys].[all_columns] AC<br />
left join [syscomments] SC on AC.[object_id] = SC.[id] and AC.[column_id] = SC.[number]<br />
left join [sysobjects] SO on AC.[object_id] = SO.id<br />
left join [sys].[identity_columns] IC on AC.[object_id] = IC.[object_id] and AC.[column_id] = IC.[column_id]<br />
where SO.xtype = &#8216;U&#8217;<br />
) info</span></p>
<p><span style="font-size:xx-small;color:navy;">union &#8212; Add in the opening part<br />
select &#8216;CREATE TABLE [DBO].[' + SO.[Name] + &#8216;] (&#8217; as [Script], SO.[Name] as [Table_Name], 1000 as [ScriptRow] from [sysobjects] SO where xtype = &#8216;U&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">union &#8212; Add in the closeing part<br />
select &#8216;) &#8216; as [Script], SO.[Name] as [Table_Name], 2001 as [ScriptRow] from [sysobjects] SO where xtype = &#8216;U&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">union &#8212; Add in the closeing part<br />
select &#8216; &#8216; as [Script], SO.[Name] as [Table_Name], 2002 as [ScriptRow] from [sysobjects] SO where xtype = &#8216;U&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">) combined<br />
&#8211;where Table_Name like &#8216;air%&#8217;<br />
order by Table_Name, ScriptRow</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8211; ** Update for formulas for computed columns<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></p>
<p><span style="font-size:xx-small;color:navy;">update ST<br />
set Script = F.Script<br />
from<br />
@ScriptTable ST inner join<br />
&#8211;select Script, TableName, ScriptRow from<br />
(select space(30) +<br />
case when [Column_ID] = 1 then &#8216; &#8216; else &#8216;,&#8217; end +<br />
&#8216;[' + ac.name +'] AS &#8216; + sc.text as Script,<br />
so.name as Table_Name,<br />
sc.number + 1000 as ScriptRow<br />
from<br />
sysobjects so left join syscomments sc on so.id = sc.id<br />
left join sys.all_columns ac on sc.id = ac.[object_id] and sc.number = ac.[column_id]<br />
where<br />
so.xtype = &#8216;U&#8217; &#8212; Is user defined table<br />
and<br />
sc.number is not null &#8212; number is the column number<br />
) F<br />
on ST.Table_Name = F.Table_Name and ST.ScriptRow = F.ScriptRow</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8211; ** Add the index create statements (3000)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
declare @ScriptText varchar(7500)<br />
declare @TableNameText varchar(255)<br />
declare @ScriptRowInt int</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @i int<br />
declare @keyCols varchar(2000)</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @ScriptCursor CURSOR</span></p>
<p><span style="font-size:xx-small;color:navy;">set nocount ON</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @ScriptTable<br />
select<br />
&#8216;CREATE &#8216; + UniqueText + ClusterText + &#8216; INDEX [' + [Index_Name] + &#8216;] ON [DBO].['+[Table_Name]+&#8217;]&#8217; &#8212; (&#8217; + TargetField<br />
as [Script],<br />
Table_Name as [Table_Name],<br />
3000 + (indexID*2) as [ScriptRow]<br />
from(<br />
select<br />
i.index_id as IndexID,<br />
i.name as Index_Name,<br />
case when i.type_desc = &#8216;CLUSTERED&#8217; then &#8216;CLUSTERED&#8217; else &#8216;NONCLUSTERED&#8217; end as ClusterText,<br />
case when i.is_unique = 1 then &#8216;UNIQUE &#8216; else &#8221; end as UniqueText,<br />
s.[object_id] as Table_ID,<br />
so.name as Table_Name<br />
from [sys].[indexes] I<br />
left join [sys].[stats] S on I.[object_id] = S.[object_id] and I.[index_id] = S.[stats_id]<br />
left join [sysobjects] SO on S.[object_id] = SO.[id]<br />
&#8211;left join [sys].[all_columns] AC on S.[object_id] = AC.[object_id]<br />
where so.xtype = &#8216;U&#8217;<br />
) inside<br />
WHERE Table_Name in (Select distinct Table_Name from @ScriptTable)<br />
order by [Table_Name], [ScriptRow]</span></p>
<p><span style="font-size:xx-small;color:navy;">SET @ScriptCursor = CURSOR<br />
FOR<br />
select [Script], [Table_Name], [ScriptRow]<br />
from @ScriptTable<br />
where ScriptRow &gt; 3000 and ScriptRow &lt; 4000<br />
FOR UPDATE</span></p>
<p><span style="font-size:xx-small;color:navy;">set nocount ON</span></p>
<p><span style="font-size:xx-small;color:navy;">OPEN @ScriptCursor<br />
FETCH NEXT FROM @ScriptCursor INTO @ScriptText,@TableNameText, @ScriptRowInt<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
set @keyCols = &#8221;<br />
set @i = 1<br />
WHILE index_col( @TableNameText, (@ScriptRowInt - 3000)/2, @i) IS NOT NULL<br />
BEGIN<br />
if @i &gt; 1 begin set @keyCols = @keyCols + &#8216;,&#8217; end<br />
set @keyCols = @keyCols + index_col( @TableNameText, (@ScriptRowInt - 3000)/2, @i)<br />
set @i = @i + 1<br />
END<br />
UPDATE @ScriptTable SET [Script] = @ScriptText + &#8216; (&#8217; + @keyCols + &#8216;)&#8217; WHERE CURRENT OF @ScriptCursor<br />
&#8211;PRINT &#8216;&#8211;&#8217; + @ScriptText + &#8216;:&#8217; + @TableNameText + &#8216;:&#8217; + @keyCols &#8212; + @ScriptRowInt<br />
FETCH NEXT FROM @ScriptCursor INTO @ScriptText,@TableNameText, @ScriptRowInt<br />
END<br />
DEALLOCATE @ScriptCursor</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; ** Insert the &#8216;GO&#8217; Statements afer each index create<br />
insert into @ScriptTable<br />
select &#8216; &#8216; as Script, Table_Name, ScriptRow + 1 as ScriptRow from @ScriptTable where ScriptRow &gt; 3000 and ScriptRow &lt; 4000 and Script like &#8216;CREATE%&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8211; ** Add the DEFAULT contraints (4000)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
insert into @ScriptTable<br />
select<br />
&#8216; ADD CONSTRAINT ['+DC.[Name]+&#8217;] DEFAULT &#8216;+DC.[definition]+ &#8216; FOR ['+ col_name(SO.[parent_obj], [parent_column_id]) +&#8217;]&#8217; as Script,<br />
PSO.[Name] as Table_Name,<br />
([parent_column_id]*3) + 4000 as ScriptRow<br />
from sys.default_constraints DC<br />
left join sysobjects SO on DC.object_id = SO.id<br />
left join sysobjects PSO on SO.[parent_obj] = PSO.id<br />
where<br />
PSO.[Name] in (Select distinct Table_Name from @ScriptTable)</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; ** Insert the &#8216;GO&#8217; Statements afer each constraint create<br />
insert into @ScriptTable<br />
select &#8216; &#8216; as Script, Table_Name, ScriptRow + 1 as ScriptRow from @ScriptTable where ScriptRow &gt; 4000 and ScriptRow &lt; 5000 and Script like &#8216; ADD CONSTRAINT%&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; ** Insert the &#8216;ALTER TABLE&#8217; part of the statement before each constraint<br />
insert into @ScriptTable<br />
select &#8216;ALTER TABLE [DBO].['+Table_Name+']&#8216; as Script, Table_Name, ScriptRow - 1 as ScriptRow from @ScriptTable where ScriptRow &gt; 4000 and ScriptRow &lt; 5000 and Script like &#8216; ADD CONSTRAINT%&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
&#8211; ** Add the FOREIGN CONSTRAINTS<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
declare @fkcursor cursor<br />
declare @fkeyid int, @rkeyid int, @cnstid int, @fkeycol smallint, @rkeycol smallint, @fkeycounter int<br />
declare @parentTbl varchar(300), @referenceTble varchar(300), @keyName varchar(300), @keys varchar(500), @cnstdes varchar(500)</span></p>
<p><span style="font-size:xx-small;color:navy;">set @fkeycounter = 5001</span></p>
<p><span style="font-size:xx-small;color:navy;">set @fkcursor = cursor for<br />
select<br />
FK.[object_id], FK.parent_object_id, FK.referenced_object_id,<br />
SO.name as KeyName, PSO.name as ParentTable, RSO.name as ReferenceTable<br />
from<br />
sys.[foreign_keys] FK<br />
left join sysobjects SO on FK.object_id = SO.id<br />
left join sysobjects PSO on FK.[parent_object_id] = PSO.id<br />
left join sysobjects RSO on FK.[referenced_object_id] = RSO.id<br />
WHERE PSO.name in (Select distinct Table_Name from @ScriptTable)</span></p>
<p><span style="font-size:xx-small;color:navy;">open @fkcursor<br />
fetch @fkcursor into @cnstid, @fkeyid, @rkeyid, @keyName, @parentTbl, @referenceTble<br />
WHILE @@FETCH_STATUS = 0<br />
Begin<br />
declare ms_crs_fkey cursor local for<br />
select parent_column_id, referenced_column_id from sys.foreign_key_columns where constraint_object_id = @cnstid<br />
open ms_crs_fkey<br />
fetch ms_crs_fkey into @fkeycol, @rkeycol<br />
select @keys = col_name(@fkeyid, @fkeycol), @cnstdes = col_name(@rkeyid, @rkeycol)<br />
fetch ms_crs_fkey into @fkeycol, @rkeycol<br />
while @@fetch_status &gt;= 0<br />
begin<br />
select @keys = @keys + &#8216;, &#8216; + col_name(@fkeyid, @fkeycol),<br />
@cnstdes = @cnstdes + &#8216;, &#8216; + col_name(@rkeyid, @rkeycol)<br />
fetch ms_crs_fkey into @fkeycol, @rkeycol<br />
end</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @ScriptTable(Script,Table_Name,ScriptRow)<br />
values(&#8217;ALTER TABLE DBO.['+@parentTbl+'] ADD CONSTRAINT ['+@keyName+']&#8216;,@parentTbl ,@fkeycounter)</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @ScriptTable(Script,Table_Name,ScriptRow)<br />
values(&#8217; FOREIGN KEY (&#8217;+ @keys + &#8216;) REFERENCES DBO.[' + @referenceTble+ '] (&#8217; + @cnstdes +&#8217;)',@parentTbl,@fkeycounter+1)</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @ScriptTable(Script,Table_Name,ScriptRow)<br />
values(&#8217; &#8216;,@parentTbl,@fkeycounter+2)</span></p>
<p><span style="font-size:xx-small;color:navy;">deallocate ms_crs_fkey<br />
set @fkeycounter = @fkeycounter + 6<br />
fetch next from @fkcursor into @cnstid, @fkeyid, @rkeyid, @keyName, @parentTbl, @referenceTble<br />
end</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; ** Insert the &#8216;A comment before each table create and space after&#8217;<br />
insert into @ScriptTable<br />
select distinct<br />
&#8216;/* [' + Table_Name +'] */&#8217; as Script,<br />
Table_Name, 900 as ScriptRow from @ScriptTable</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @ScriptTable<br />
select distinct<br />
&#8216; &#8216; as Script,<br />
Table_Name, 9000 as ScriptRow from @ScriptTable</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; Clean the Results<br />
delete from @scripttable where table_name like &#8217;sys%&#8217; or table_name = &#8216;dtproperties&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; Parse the code into the final table<br />
declare @tablesScript TABLE (table_name varchar(255), script varchar(7500))</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @finalCursor CURSOR</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @builduptext varchar(7500)<br />
set @builduptext = &#8221;</span></p>
<p><span style="font-size:xx-small;color:navy;">set @finalCursor = cursor for<br />
select Script, Table_Name, ScriptRow from @scripttable order by table_name, scriptrow</span></p>
<p><span style="font-size:xx-small;color:navy;">OPEN @finalCursor<br />
FETCH NEXT FROM @finalCursor INTO @ScriptText,@TableNameText, @ScriptRowInt<br />
WHILE @@FETCH_STATUS = 0<br />
Begin<br />
if(@ScriptRowInt = 9000)<br />
begin<br />
insert into @tablesScript(table_name, script) values (@TableNameText, @BuildUpText + char(13) + @ScriptText )<br />
set @builduptext = &#8221;<br />
end<br />
else<br />
begin<br />
set @builduptext = @builduptext + char(13) + @ScriptText<br />
end<br />
FETCH NEXT FROM @finalCursor INTO @ScriptText,@TableNameText, @ScriptRowInt<br />
END<br />
deallocate @finalcursor</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; Contents of table script are now located in the @tablesScript temporary table<br />
/**************************************************************************************************<br />
END TABLE SCRIPT CREATION (this footer is repeated at the begining)<br />
**************************************************************************************************/</span></p>
<p><span style="font-size:xx-small;color:navy;">/**************************************************************************************************<br />
BEGIN PROGRAMABILITY SCRIPT CREATION (this footer is repeated at the end)<br />
**************************************************************************************************/</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @procsCursor CURSOR</span></p>
<p><span style="font-size:xx-small;color:navy;">set @procsCursor = CURSOR FOR<br />
select distinct<br />
upper(SysObjects.Name) as ObjectName<br />
from SysObjects<br />
where (SysObjects.Category = 0) and<br />
SysObjects.type in (&#8217;P',&#8217;FN&#8217;,'TF&#8217;,'V&#8217;) and &#8211;Only want procs, functions and views<br />
not (upper(left([SysObjects].[Name],3)) in (&#8217;SP_&#8217;,'DT_&#8217;,'XP_&#8217;,'ZZZ&#8217;,'FN_&#8217;))</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @objectName varchar(255)<br />
declare @OutStringP varchar(MAX)<br />
declare @InStringP varchar(255)<br />
declare @TempCursorP CURSOR</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @TempTableP TABLE<br />
( [text] varchar(7500) )</span></p>
<p><span style="font-size:xx-small;color:navy;"><br />
declare @programScript TABLE ([object_name] varchar(255), script varchar(max) ) &#8212; varchar(8000))</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @scriptString varchar(max)<br />
set @scriptString = &#8221;</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @tlen float</span></p>
<p><span style="font-size:xx-small;color:navy;">INSERT into @programScript([object_name],script) values(@objectName, &#8221;)<br />
</span></p>
<p><span style="font-size:xx-small;color:navy;">OPEN @procsCursor FETCH NEXT FROM @procsCursor into @objectName<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
set @tlen = 0</span></p>
<p><span style="font-size:xx-small;color:navy;">set @OutStringP = &#8221;<br />
set nocount ON<br />
insert into @TempTableP exec sp_helptext @objectName<br />
SET @TempCursorP = CURSOR FAST_FORWARD FOR select [Text] from @TempTableP</span></p>
<p><span style="font-size:xx-small;color:navy;">OPEN @TempCursorP FETCH NEXT FROM @TempCursorP INTO @InStringP<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
IF(len(@InStringP) &lt; 255)<br />
BEGIN<br />
IF(LEN(LTRIM(RTRIM(@OutStringP + @InStringP))) &gt; 0)<br />
BEGIN<br />
set @scriptString = @scriptString + CAST(@OutStringP AS varchar(max)) + CAST(@InStringP AS varchar(max))<br />
set @tlen = @tlen + len(@outStringP + @InStringP)<br />
&#8211;UPDATE @programScript set [script] = [script] + @OutString + @Instring where [object_name] = @objectName</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211;print RTRIM(@OutString + @InString)<br />
END<br />
set @OutStringP = &#8221;<br />
END<br />
ELSE<br />
BEGIN<br />
set @OutStringP = @OutStringP + @InStringP<br />
END</span></p>
<p><span style="font-size:xx-small;color:navy;">FETCH NEXT FROM @TempCursorP INTO @InStringP<br />
END</span></p>
<p><span style="font-size:xx-small;color:navy;">INSERT into @programScript([object_name],script) values(@objectName, @scriptString)</span></p>
<p><span style="font-size:xx-small;color:navy;">set @scriptString = &#8221;</span></p>
<p><span style="font-size:xx-small;color:navy;">CLOSE @TempCursorP<br />
DEALLOCATE @TempCursorP<br />
DELETE FROM @TempTableP<br />
FETCH NEXT FROM @procsCursor INTO @objectName<br />
END</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211; Contents of procs/views/functions script are now located in the @programScript temporary table<br />
/**************************************************************************************************<br />
END PROGRAMABILITY SCRIPT CREATION (this footer is repeated at the begining)<br />
**************************************************************************************************/</span></p>
<p><span style="font-size:xx-small;color:navy;">set nocount on</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @ProcName nvarchar(100)<br />
declare @ProcSortOrder varchar(30)<br />
declare @MyCursor CURSOR<br />
declare @ObjectType char(2)<br />
declare @TypeString varchar(20)<br />
declare @CheckParm varchar(20)</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @ProcedureCode varchar(7500)</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @TempCursor CURSOR<br />
declare @InString varchar(7500)<br />
declare @OutString varchar(7500)<br />
declare @TempTable TABLE<br />
( [text] varchar(7500) )</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @StoredProcs TABLE<br />
(<br />
SortOrder int,<br />
ProcedureName varchar(255),<br />
ProcedureCode varchar(max),<br />
ObjectType char(2),<br />
TypeString varchar(20),<br />
CheckParm varchar(20),<br />
UsedBy int,<br />
Uses int</span></p>
<p><span style="font-size:xx-small;color:navy;">)</span></p>
<p><span style="font-size:xx-small;color:navy;">set nocount ON<br />
Insert Into @StoredProcs<br />
select distinct<br />
case SysObjects.type<br />
when &#8216;FN&#8217; then 1 &#8211;IsScalarFunction<br />
when &#8216;TF&#8217; then 2 &#8211;IsTableFunction<br />
when &#8216;V &#8216; then 5 &#8211;IsView<br />
when &#8216;U&#8217; then 4 &#8211;IsTable<br />
ELSE 3 &#8211;IsProcedure<br />
end as SortOrder,</span></p>
<p><span style="font-size:xx-small;color:navy;">upper(SysObjects.Name),<br />
case SysObjects.type<br />
when &#8216;U&#8217; then TS.script<br />
else PS.script &#8212; SysComments.Text<br />
END as ProcedureCode,<br />
SysObjects.type,<br />
case SysObjects.type<br />
when &#8216;P &#8216; then &#8216;Procedure&#8217;<br />
when &#8216;V &#8216; then &#8216;View&#8217;<br />
when &#8216;U&#8217; then &#8216;Table&#8217;<br />
ELSE &#8216;Function&#8217;<br />
END as TypeString,<br />
case SysObjects.type<br />
when &#8216;FN&#8217; then &#8216;IsScalarFunction&#8217;<br />
when &#8216;TF&#8217; then &#8216;IsTableFunction&#8217;<br />
when &#8216;V &#8216; then &#8216;IsView&#8217;<br />
when &#8216;U&#8217; then &#8216;IsTable&#8217;<br />
ELSE &#8216;IsProcedure&#8217;<br />
END as CheckParm,<br />
0 as UsedBy,<br />
0 as Uses</span></p>
<p><span style="font-size:xx-small;color:navy;">from SysObjects &#8211;left join SysComments on SysObjects.ID = SysComments.ID<br />
left join @tablesScript TS on SysObjects.Name = TS.table_name<br />
left join @programScript PS on SysObjects.Name = PS.[object_name]<br />
where<br />
SysObjects.type in (&#8217;P',&#8217;FN&#8217;,'TF&#8217;,'V&#8217;,'U&#8217;) and &#8211;Only want procs, functions and views<br />
(SysObjects.Category = 0)<br />
and not (upper(left([SysObjects].[Name],3)) in (&#8217;SP_&#8217;,'DT_&#8217;,'XP_&#8217;,'ZZZ&#8217;,'FN_&#8217;)) &#8211;exclude system and ZZZ hidden stuff<br />
&#8211;order by SysObjects.Name ASC</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211;select count(sortorder), procedureName from @StoredProcs group by procedureName order by ProcedureName</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211;create table ##SPuses<br />
declare @SPuses TABLE<br />
(<br />
[ObjectName] varchar(255),<br />
UsesName varchar(255),<br />
Lvl int,<br />
Ord int<br />
)</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @level int<br />
set @level = 1</span></p>
<p><span style="font-size:xx-small;color:navy;">declare @rowsAffected int<br />
set @rowsAffected = 1000</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211;insert into @spuses<br />
insert into @SPuses<br />
select<br />
A2.ProcedureName as [ObjectName],<br />
B2.ProcedureName as [UsesName],<br />
1 as Lvl,<br />
0 as Ord<br />
from @StoredProcs A2 left join @StoredProcs B2<br />
on (REPLACE(UPPER(A2.ProcedureCode),A2.ProcedureName,&#8221;)<br />
LIKE &#8216;%&#8217; + upper(B2.ProcedureName) + &#8216;%&#8217;)<br />
order by A2.SortOrder DESC</span></p>
<p><span style="font-size:xx-small;color:navy;">update SP set<br />
UsedBy = coalesce(SPAg.UsedByCount,0),<br />
Uses = coalesce(SPAg2.UsesCount,0)<br />
from @StoredProcs SP<br />
left join<br />
(select count(ObjectName) as UsedByCount, UsesName from @SPuses &#8211;@spuses<br />
group by UsesName) SPAg<br />
on SP.ProcedureName = SPAg.usesName<br />
left join<br />
(select count(UsesName) as UsesCount, ObjectName from @SPuses &#8211;@spuses<br />
where UsesName is not null group by ObjectName) SPAg2<br />
on SP.ProcedureName = SPAg2.ObjectName</span></p>
<p><span style="font-size:xx-small;color:navy;">while @rowsAffected &gt; 0<br />
begin<br />
insert into @SPuses<br />
select distinct<br />
SP1.ObjectName as [ObjectName],<br />
SP2.UsesName as [UsesName],<br />
@level + 1 as Lvl,<br />
0 as Ord<br />
from<br />
@SPuses SP1 left join @SPuses SP2 on SP1.UsesName = SP2.ObjectName<br />
where SP1.UsesName is not null and SP2.UsesName is not null<br />
and<br />
SP1.lvl = @level</span></p>
<p><span style="font-size:xx-small;color:navy;">set @rowsAffected = @@rowcount<br />
&#8211;print @rowsAffected</span></p>
<p><span style="font-size:xx-small;color:navy;">set @level = @level + 1<br />
end</span></p>
<p><span style="font-size:xx-small;color:navy;">insert into @SPuses<br />
select distinct ObjectName, UsesName, 0 as Lvl, 1 as Ord<br />
from @SPuses order by ObjectName</span></p>
<p><span style="font-size:xx-small;color:navy;">delete from @SPuses where Ord = 0</span></p>
<p><span style="font-size:xx-small;color:navy;">update @SPuses set Ord = 0</span></p>
<p><span style="font-size:xx-small;color:navy;">set @level = 1<br />
update @SPuses set Ord = @level where usesName is null<br />
set @rowsAffected = @@rowcount<br />
&#8211;print @rowsAffected</span></p>
<p><span style="font-size:xx-small;color:navy;">while @rowsAffected &gt; 0<br />
begin<br />
update @SPuses set Ord = @level + 1 where usesName in (select ObjectName from @SPuses where Ord = @level)</span></p>
<p><span style="font-size:xx-small;color:navy;">set @rowsAffected = @@rowcount<br />
&#8211; print @rowsAffected</span></p>
<p><span style="font-size:xx-small;color:navy;">set @level = @level + 1<br />
end</span></p>
<p><span style="font-size:xx-small;color:navy;">set nocount ON</span></p>
<p><span style="font-size:xx-small;color:navy;">SET @MyCursor = CURSOR SCROLL &#8211;FAST_FORWARD<br />
FOR<br />
select ProcedureName,<br />
cast(outC.SortOrder as varchar(2)) +&#8217;.'+ cast(outC.MxOrd as varchar(2)) +&#8217;.'+ cast(outC.AvOrd as varchar(2)) +&#8217;.'+ cast(outC.MnOrd as varchar(2)) as SortOrder<br />
,ObjectType<br />
,TypeString<br />
,CheckParm<br />
,ProcedureCode<br />
from<br />
(<br />
select distinct ProcedureName,<br />
SortOrder</span></p>
<p><span style="font-size:xx-small;color:navy;">,ObjectType<br />
,TypeString<br />
,CheckParm<br />
,ProcedureCode<br />
,B.MxOrd, B.AvOrd, B.MnOrd<br />
from @StoredProcs A</span></p>
<p><span style="font-size:xx-small;color:navy;">left join (select max(ord) as MxOrd, Avg(ord) as AvOrd, min(ord) as MnOrd, ObjectName from @SPuses group by ObjectName ) B</span></p>
<p><span style="font-size:xx-small;color:navy;">on A.ProcedureName = B.ObjectName<br />
) outC<br />
order by outC.SortOrder, outC.MxOrd, outC.AvOrd, outC.MnOrd</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211;select max(ord) as MxOrd, Avg(ord) as AvOrd, min(ord) as MnOrd, ObjectName from @SPuses group by ObjectName order by MxOrd, AvOrd, MnOrd</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
set nocount ON</span></p>
<p><span style="font-size:xx-small;color:navy;">print&#8217;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8217;<br />
Print &#8216;&#8211; The procs/functions and views will be generated in the following order [Rank]&#8216;<br />
print &#8216; &#8216;<br />
OPEN @MyCursor<br />
FETCH NEXT FROM @MyCursor INTO @ProcName,@ProcSortOrder, @ObjectType, @TypeString, @CheckParm, @ProcedureCode<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
PRINT &#8216;&#8211;&#8217; + @ObjectType + &#8216; : &#8216;+ left(@TypeString+&#8217; &#8216;,10) + &#8216;: &#8216;+ @ProcName + &#8216; ['+ cast(@ProcSortOrder as varchar(20)) +']&#8216;<br />
FETCH NEXT FROM @MyCursor INTO @ProcName,@ProcSortOrder, @ObjectType, @TypeString, @CheckParm, @ProcedureCode<br />
END<br />
set nocount ON</span></p>
<p><span style="font-size:xx-small;color:navy;">FETCH FIRST FROM @MyCursor<br />
INTO @ProcName,@ProcSortOrder,@ObjectType,@TypeString,@CheckParm, @ProcedureCode<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
print &#8216;&#8211;===============================================================================&#8217;<br />
&#8211;PRINT &#8216;if exists (select * from dbo.sysobjects &#8216;<br />
&#8211;PRINT &#8216; where id = object_id(N&#8217; + char(39) + &#8216;[dbo].[' + @ProcName + ']&#8216; + char(39) + &#8216;)&#8217;<br />
&#8211;PRINT &#8216; and OBJECTPROPERTY(id, N&#8217; + char(39) + @CheckParm + char(39) + &#8216;) = 1) &#8216;<br />
&#8211; PRINT &#8216; drop &#8216; + @TypeString+&#8217; &#8216; + @ProcName<br />
&#8211; PRINT &#8216; GO &#8216;<br />
&#8211; PRINT &#8216; SET QUOTED_IDENTIFIER OFF &#8216;<br />
&#8211; PRINT &#8216; GO &#8216;<br />
&#8211; PRINT &#8216; SET ANSI_NULLS OFF &#8216;<br />
&#8211; PRINT &#8216; GO&#8217;</span></p>
<p><span style="font-size:xx-small;color:navy;">/*if @TypeString = &#8216;Function&#8217; or @TypeString = &#8216;Procedure&#8217; or @TypeString = &#8216;View&#8217;<br />
begin</span></p>
<p><span style="font-size:xx-small;color:navy;">end*/</span></p>
<p><span style="font-size:xx-small;color:navy;">if @TypeString = &#8216;Table&#8217;<br />
begin<br />
print @ProcedureCode<br />
end<br />
else<br />
begin<br />
print &#8216;GO&#8217;<br />
&#8211; exec sp_helptext @ProcName<br />
&#8211; The following section compensates for the way sp_helptext handles wrapping<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
set @OutString = &#8221;<br />
set nocount ON<br />
insert into @TempTable exec sp_helptext @ProcName<br />
SET @TempCursor = CURSOR FAST_FORWARD FOR select [Text] from @TempTable</span></p>
<p><span style="font-size:xx-small;color:navy;">OPEN @TempCursor FETCH NEXT FROM @TempCursor INTO @InString<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
IF(len(@InString) &lt; 255)<br />
BEGIN<br />
IF(LEN(LTRIM(RTRIM(@OutString + @InString))) &gt; 0)<br />
BEGIN<br />
print RTRIM(@OutString + @InString)<br />
END<br />
set @OutString = &#8221;<br />
END<br />
ELSE<br />
BEGIN<br />
set @OutString = @OutString + @InString<br />
END</span></p>
<p><span style="font-size:xx-small;color:navy;">FETCH NEXT FROM @TempCursor INTO @InString<br />
END</span></p>
<p><span style="font-size:xx-small;color:navy;">CLOSE @TempCursor<br />
DEALLOCATE @TempCursor<br />
DELETE FROM @TempTable</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8211;if @TypeString = &#8216;Function&#8217; or @TypeString = &#8216;Procedure&#8217; or @TypeString = &#8216;View&#8217;<br />
&#8211;begin<br />
print &#8216;GO&#8217;<br />
&#8211;end</span></p>
<p><span style="font-size:xx-small;color:navy;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
end<br />
&#8211; PRINT &#8216; GO &#8216;<br />
&#8211; PRINT &#8216; SET QUOTED_IDENTIFIER OFF &#8216;<br />
&#8211; PRINT &#8216; GO &#8216;<br />
&#8211; PRINT &#8216; SET ANSI_NULLS ON &#8216;<br />
&#8211; PRINT &#8216; GO &#8216;<br />
&#8211; PRINT &#8221;<br />
&#8211; PRINT &#8216; GRANT EXECUTE ON [dbo].[' + @ProcName + '] TO [' + @ProcUser + ']&#8216;<br />
&#8211; PRINT &#8216; GO &#8216;</span></p>
<p><span style="font-size:xx-small;color:navy;">FETCH NEXT FROM @MyCursor</span></p>
<p><span style="font-size:xx-small;color:navy;">INTO @ProcName,@ProcSortOrder,@ObjectType,@TypeString,@CheckParm, @ProcedureCode<br />
END</span></p>
<p><span style="font-size:xx-small;color:navy;">CLOSE @MyCursor<br />
DEALLOCATE @MyCursor</span></p></blockquote>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/42/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/42/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=42&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/04/15/sql-script-to-generate-sql-script/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>
	</item>
		<item>
		<title>banner puzzle game is OVER</title>
		<link>http://blog.flexuous.com/2008/03/25/banner-puzzle-game-is-over/</link>
		<comments>http://blog.flexuous.com/2008/03/25/banner-puzzle-game-is-over/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 06:17:09 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/?p=40</guid>
		<description><![CDATA[Well it had to come to an end&#8230;.  after a little over a year I figured it was time to finally swap out my banner and end my little hidden puzzle challenge.  Since moving to wordpress, I no longer have ColdFusion server space.  Therefore the way to get to the puzzle solution [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Well it had to come to an end&#8230;.  after a little over a year I figured it was time to finally swap out my banner and end my little hidden puzzle challenge.  Since moving to wordpress, I no longer have ColdFusion server space.  Therefore the way to get to the puzzle solution is no longer available.   Over the course of the last year or so I had just 16 people (that I know of) guess that there was a hidden message in the banner.  Of those 16 only 5 people figured out what the message was and how to get to the secret page on the site.  I wish that I was able to leave the solution page up but it just was not possible without the ColdFusion server.  For those people who solved the puzzle and found the solution page&#8230;.  &#8220;Toe (see). Do (see)&#8230;.&#8221;  For everyone else I&#8217;ll leave the banner here if you think you can figure it out let me know what your solution would be.  If you are correct I&#8217;ll send you a static copy of the solution page.  As a hint&#8230; this is a two parter, both the map and the key are embedded in the banner. <img src="http://flexuous.files.wordpress.com/2008/03/flexusbanner.gif?w=615&#038;h=407" alt="flexusbanner" height="407" vspace="20" width="615" /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=40&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/03/25/banner-puzzle-game-is-over/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>

		<media:content url="http://flexuous.files.wordpress.com/2008/03/flexusbanner.gif" medium="image">
			<media:title type="html">flexusbanner</media:title>
		</media:content>
	</item>
		<item>
		<title>Blog Moved</title>
		<link>http://blog.flexuous.com/2008/03/24/blog-moved/</link>
		<comments>http://blog.flexuous.com/2008/03/24/blog-moved/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 05:09:34 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/2008/03/24/blog-moved/</guid>
		<description><![CDATA[I finally did it&#8230; I got tired of paying for my crippled ColdFusion hosting account so I&#8217;ve moved my blog over to wordpress.    I have also taken the extra step of splitting up my personal blog from my programming blog.  I have gotten increasing amounts of traffic for both areas and [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I finally did it&#8230; I got tired of paying for my crippled ColdFusion hosting account so I&#8217;ve moved my blog over to wordpress.    I have also taken the extra step of splitting up my personal blog from my programming blog.  I have gotten increasing amounts of traffic for both areas and felt it was just time to separate the two out.  Officially the URLS are now:</p>
<p>For my programming blog:  <a href="http://blog.flexuous.com/">http://blog.flexuous.com/</a></p>
<p>For my personal blog: <a href="http://blog.justinohms.com/">http://blog.justinohms.com/</a></p>
<p>In one of my future posts I plan to include my methodology for moving my blog over including redirects for search engines so that I don&#8217;t loose my page rankings and any other links that are out there.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=38&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2008/03/24/blog-moved/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>
	</item>
		<item>
		<title>Yippie !! New Phone&#8230;.</title>
		<link>http://blog.flexuous.com/2007/10/18/yippie-new-phone/</link>
		<comments>http://blog.flexuous.com/2007/10/18/yippie-new-phone/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 04:17:50 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/?p=26</guid>
		<description><![CDATA[So I&#8217;ve had my Treo 600 for 4 or 5 years now ever since they first came out. When I first got my Treo I absolutely loved it but as time went on well&#8230; there were newer and cooler phones out. Steph got a new Blackberry through work about a year ago so stopped using [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So I&#8217;ve had my Treo 600 for 4 or 5 years now ever since they first came out. When I first got my Treo I absolutely loved it but as time went on well&#8230; there were newer and cooler phones out. Steph got a new Blackberry through work about a year ago so stopped using her Treo and then earlier this month one of the chargers for the Treo broke&#8230;. I took that as a sign and decided to stop putting of the inevitable and just go buy a new phone.</p>
<p>I&#8217;ve had my eye on a number of phones/pdas over the last 2 years&#8230;. the Cingular 8525, the Treo 700p, the iPhone while they each had their pluses and minuses I decided eventually to settle on the Nokia N95. This had all the features I wanted and is only lacking in one small way.</p>
<p>Here is a quick summary of the features&#8230;</p>
<p>&#8220;GSM, EDGE and 3G support</p>
<p>WIFI 802.11b/g support</p>
<p>Bluetooth (GPS, keyboard, or as a modem)</p>
<p>MicroSD (comes with a 1G card but I bought an extra 2G)</p>
<p>GPS with voice navigation (via internal GPS antenna or external bluetooth device)</p>
<p>infrared</p>
<p>5 Mega Pixel camera with flash and lens cover</p>
<p>Video recorder capable</p>
<p>2nd camera on the front</p>
<p>supports video conferenceing</p>
<p>MP3 music player</p>
<p>MP4 video player</p>
<p>FM radio</p>
<p>Internet Tellephone (VOIP)</p>
<p>Internet browser based on the web kit engine</p>
<p>Flash Lite</p>
<p>Java J2ME applications</p>
<p>email (POP &amp; IMAP)</p>
<p>contacts/IM/Video IM/calendar/notes/to do/ (and it syncs to Outlook)</p>
<p>PDF reader</p>
<p>MS Office document support (Word, Excel, Power Point)</p>
<p>Zip File support</p>
<p>bar code reader (using the camera)</p>
<p>Voice recorder</p>
<p>Oh yeah I almost forgot the best part&#8230; It&#8217;s also a cell phone.</p>
<p>Here is a photo of my new phone next to my old Treo</p>
<p><img src="http://flexuous.files.wordpress.com/2008/03/pict5256.jpg?w=575&#038;h=530" style="width:575px;height:458px;" alt="Treo 600 and Nokia N95" height="530" width="575" /></p>
<p>The front cover/screen can slide up/left to work in portrait mode and reveal the phone keypad, or down/right to work in landscape mode and reveal the media player controls. Now to top it all off the N95 is quite a bit smaller than my Treo (and it doesn&#8217;t have the antenna sticking up)</p>
<p>I haven&#8217;t had a chance to really play with all of the features yet but I am looking forward to testing them all out on our trip to St. Louis next week. Oh and that one thing that is lacking&#8230; the N95 does not have a full alpha keyboard like the Treo or a BlackBerry so you have to use the standard telephone keypad to enter alpha characters.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=26&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2007/10/18/yippie-new-phone/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>

		<media:content url="http://flexuous.files.wordpress.com/2008/03/pict5256.jpg" medium="image">
			<media:title type="html">Treo 600 and Nokia N95</media:title>
		</media:content>
	</item>
		<item>
		<title>ColdFusion 8  flex2gateway  Error 500 java.lang.NullPointerException</title>
		<link>http://blog.flexuous.com/2007/10/09/coldfusion-8-flex2gateway-error-500-javalangnullpointerexception/</link>
		<comments>http://blog.flexuous.com/2007/10/09/coldfusion-8-flex2gateway-error-500-javalangnullpointerexception/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 15:52:00 +0000</pubDate>
		<dc:creator>justinohms</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://flexuous.wordpress.com/2008/03/14/coldfusion-8-flex2gateway-error-500-javalangnullpointerexception/</guid>
		<description><![CDATA[I recently upgraded to CF8 and experienced a small problem when i went to configure my AMF end points and channels. First I must say that I like the new method of keeping the channel definitions in the services-config while breaking out the destination settings into separate files like remoting-config. Now all that being said [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I recently upgraded to CF8 and experienced a small problem when i went to configure my AMF end points and channels. First I must say that I like the new method of keeping the channel definitions in the services-config while breaking out the destination settings into separate files like remoting-config. Now all that being said I encountered the following error when going to http://localhost/flex2gateway/<br />
after copying over my old settings into these files.</p>
<p>500</p>
<p>java.lang.NullPointerException<br />
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:283)<br />
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)<br />
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)<br />
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)<br />
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)<br />
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)<br />
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)</p>
<p>The problem occurs because apparently while it was ok to have two channels share the same endpoint uri URL in CF7&#8230;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/flexuous.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/flexuous.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/flexuous.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/flexuous.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/flexuous.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/flexuous.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/flexuous.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/flexuous.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/flexuous.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/flexuous.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/flexuous.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/flexuous.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.flexuous.com&blog=3072563&post=6&subd=flexuous&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexuous.com/2007/10/09/coldfusion-8-flex2gateway-error-500-javalangnullpointerexception/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/265f8fef23f99b7192248b37c2c584ac?s=96&#38;d=identicon" medium="image">
			<media:title type="html">justinohms</media:title>
		</media:content>
	</item>
	</channel>
</rss>