<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tropical Coding</title>
	
	<link>http://tropicalcoding.com</link>
	<description>Laid Back and Code Wasted</description>
	<lastBuildDate>Thu, 20 Sep 2012 15:40:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TropicalCoding" /><feedburner:info uri="tropicalcoding" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>TropicalCoding</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>VS 2012 T4 Template Code Gen Stored Proc from SQL Server 2008 Sample</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/kNCqTRoqj2U/</link>
		<comments>http://tropicalcoding.com/vs-2012-t4-template-code-gen-stored-proc-sample/#comments</comments>
		<pubDate>Thu, 20 Sep 2012 15:38:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Generation]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Stored Procedure]]></category>
		<category><![CDATA[T4 Templates]]></category>
		<category><![CDATA[C# Code Gen]]></category>
		<category><![CDATA[Code Gen]]></category>
		<category><![CDATA[T4 Templates Samples]]></category>
		<category><![CDATA[Visual Studio 2012]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=1007</guid>
		<description><![CDATA[I have been working on trying to use the T4 Templates to Code Gen stored procs, DTO/Model classes, and Enterprise Library 5.0 data access layer. I thought I&#8217;d post these so people have an example. There are bits and pieces out there, but not a whole lot of basic samples. They say you can include [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on trying to use the T4 Templates to Code Gen stored procs, DTO/Model classes, and Enterprise Library 5.0 data access layer.  I thought I&#8217;d post these so people have an example.  There are bits and pieces out there, but not a whole lot of basic samples.    </p>
<p>They say you can include the T4 in your existing projects, and it will automatically update all the database changes.  For me, I prefer to have a separate Code Gen solution and update them when I feel it is necessary. I don&#8217;t want to accidentally overwrite something I&#8217;ve added manually.</p>
<p>So, I created a separate VS 2012 solution, added a project and created folders for stored procedures, the Model, the BLL, and the DAL.</p>
<p>Here is the T4 template for generating CRUD procedures.  I am teaching myself C#, so go easy on me (I have been doing VB.NET for over 6 years)!  These will output to one file (my preference).  However, when I post the others, they will output to separate .cs files.  Below, you will see the code, and then the results. You will need to change the database name to your specific database.</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br />282<br />283<br />284<br />285<br />286<br />287<br />288<br />289<br />290<br />291<br />292<br />293<br />294<br />295<br />296<br />297<br />298<br />299<br />300<br />301<br />302<br />303<br />304<br />305<br />306<br />307<br />308<br />309<br />310<br />311<br />312<br />313<br />314<br />315<br />316<br />317<br />318<br />319<br />320<br />321<br />322<br />323<br />324<br />325<br />326<br />327<br />328<br />329<br />330<br />331<br />332<br />333<br />334<br />335<br />336<br />337<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ template &nbsp; debug=&quot;true&quot; hostSpecific=&quot;true&quot; #&gt;</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ output extension=&quot;sql&quot; #&gt;</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ assembly name=&quot;System.Xml&quot; #&gt;</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ assembly name=&quot;Microsoft.SqlServer.ConnectionInfo&quot;#&gt;</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ assembly name=&quot;Microsoft.SqlServer.Smo&quot; #&gt;</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ import namespace=&quot;Microsoft.SqlServer.Management.Smo&quot; #&gt;</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#@ assembly name=&quot;Microsoft.SqlServer.Management.Sdk.Sfc&quot; #&gt;</span><br />
<br />
<br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> serverName <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;(local)&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> databaseName <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;MyDatabaseName&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; Server server <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Server<span style="color: #008000;">&#40;</span>serverName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; Database database <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Database<span style="color: #008000;">&#40;</span>server, databaseName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; database<span style="color: #008000;">.</span><span style="color: #0000FF;">Refresh</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <br />
<br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">int</span> count<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>Table table <span style="color: #0600FF; font-weight: bold;">in</span> database<span style="color: #008000;">.</span><span style="color: #0000FF;">Tables</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008080;">#&gt;</span><br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #008080; font-style: italic;">/* DELETE SCRIPTS */</span><br />
<span style="color: #008080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; &lt;#= table.Name #&gt;DeleteBy&lt;#= table.Name#&gt;ID<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">IF</span> &nbsp;EXISTS <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">SELECT</span> <span style="color: #008000;">*</span> <span style="color: #0600FF; font-weight: bold;">FROM</span> sys<span style="color: #008000;">.</span><span style="color: #0000FF;">objects</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">WHERE</span> object_id <span style="color: #008000;">=</span> OBJECT_ID<span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'&lt;#= &nbsp;table.Name #&gt;DeleteBy&lt;#= table.Name#&gt;ID'</span><span style="color: #008000;">&#41;</span> AND type <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'P'</span>, N<span style="color: #666666;">'PC'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DROP PROCEDURE &nbsp;<span style="color: #008000;">&lt;</span><span style="color: #008080;">#= &nbsp;table.Name &nbsp;#&gt;DeleteBy&lt;#= table.Name#&gt;ID</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GO<br />
<br />
SET ANSI_NULLS ON<br />
GO<br />
<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
<br />
CREATE PROCEDURE <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= table.Name #&gt;DeleteBy&lt;#= table.Name#&gt;ID </span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//int count=0;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; count<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PushIndent<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">InPrimaryKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;,&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span><span style="color: #008000;">+</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span><span style="color: #666666;">&quot; &quot;</span><span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008080;">#&gt;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">AS</span> <br />
&nbsp; &nbsp; SET NOCOUNT ON<span style="color: #008000;">;</span><br />
<br />
DELETE <span style="color: #0600FF; font-weight: bold;">FROM</span> <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= table.Name #&gt; </span><br />
<span style="color: #0600FF; font-weight: bold;">WHERE</span> <span style="color: #008000;">&lt;</span><span style="color: #008080;"># &nbsp; &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">InPrimaryKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; AND &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = @&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;GO&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008080;">#&gt;</span><br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #008080; font-style: italic;">/* SELECT BY PRIMARY KEY SCRIPTS */</span><br />
<span style="color: #008080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; &lt;#= table.Name #&gt;SelectBy&lt;#= table.Name#&gt;ID<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">IF</span> &nbsp;EXISTS <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">SELECT</span> <span style="color: #008000;">*</span> <span style="color: #0600FF; font-weight: bold;">FROM</span> sys<span style="color: #008000;">.</span><span style="color: #0000FF;">objects</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">WHERE</span> object_id <span style="color: #008000;">=</span> OBJECT_ID<span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'&lt;#= &nbsp;table.Name #&gt;SelectBy&lt;#= table.Name#&gt;ID'</span><span style="color: #008000;">&#41;</span> AND type <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'P'</span>, N<span style="color: #666666;">'PC'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DROP PROCEDURE &nbsp;<span style="color: #008000;">&lt;</span><span style="color: #008080;">#= &nbsp;table.Name &nbsp;#&gt;SelectBy&lt;#= table.Name#&gt;ID</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GO<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
SET ANSI_NULLS ON<br />
GO<br />
<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
<br />
CREATE PROCEDURE <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= table.Name #&gt;SelectBy&lt;#= table.Name#&gt;ID </span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; count<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PushIndent<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">InPrimaryKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;,&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span><span style="color: #008000;">+</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span><span style="color: #666666;">&quot; &quot;</span><span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008080;">#&gt;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">AS</span> <br />
SET NOCOUNT ON<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">SELECT</span> <span style="color: #008000;">*</span> <span style="color: #0600FF; font-weight: bold;">FROM</span> <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= table.Name #&gt; </span><br />
<span style="color: #0600FF; font-weight: bold;">WHERE</span> <span style="color: #008000;">&lt;</span><span style="color: #008080;"># &nbsp; &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">InPrimaryKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; AND &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = @&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;GO&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008080;">#&gt;</span><br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #008080; font-style: italic;">/* INSERT TABLE SCRIPTS */</span><br />
<span style="color: #008080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; &lt;#= table.Name #&gt;Insert<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">IF</span> &nbsp;EXISTS <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">SELECT</span> <span style="color: #008000;">*</span> <span style="color: #0600FF; font-weight: bold;">FROM</span> sys<span style="color: #008000;">.</span><span style="color: #0000FF;">objects</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">WHERE</span> object_id <span style="color: #008000;">=</span> OBJECT_ID<span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'&lt;#= &nbsp;table.Name #&gt;Insert'</span><span style="color: #008000;">&#41;</span> AND type <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'P'</span>, N<span style="color: #666666;">'PC'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DROP PROCEDURE &nbsp;<span style="color: #008000;">&lt;</span><span style="color: #008080;">#= &nbsp;table.Name &nbsp;#&gt;Insert</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GO<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
SET ANSI_NULLS ON<br />
GO<br />
<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; CREATE PROCEDURE <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= &nbsp;table.Name &nbsp;#&gt;Insert</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;"># </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//int count = 0;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; count<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> primarykeyname <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PushIndent</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Identity</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; , &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;varchar&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span><span style="color: #008000;">+</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span><span style="color: #666666;">&quot; &quot;</span><span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;(&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Properties</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Length&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;)&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;varchar&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span><span style="color: #008000;">+</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span><span style="color: #666666;">&quot; &quot;</span><span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;(&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Properties</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Length&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;)&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span> &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; primarykeyname <span style="color: #008000;">=</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;,@&quot;</span> <span style="color: #008000;">+</span> primarykeyname <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; int OUTPUT&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">AS</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SET NOCOUNT ON<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; INSERT INTO <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= table.Name #&gt; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&lt;</span><span style="color: #008080;"># </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PushIndent</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Identity</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span>&nbsp; <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; , &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#41;</span> VALUES <span style="color: #008000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&lt;</span><span style="color: #008080;"># &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PushIndent</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Identity</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span>&nbsp; <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; , &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt; </span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;"># </span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;)&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;SELECT @&quot;</span> <span style="color: #008000;">+</span> primarykeyname <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = SCOPE_IDENTITY()&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;GO&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <br />
<br />
<span style="color: #008080;">#&gt;</span><br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #008080; font-style: italic;">/* UPDATE TABLE SCRIPTS */</span><br />
<span style="color: #008080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #008080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; &lt;#= table.Name #&gt;Update<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">IF</span> &nbsp;EXISTS <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">SELECT</span> <span style="color: #008000;">*</span> <span style="color: #0600FF; font-weight: bold;">FROM</span> sys<span style="color: #008000;">.</span><span style="color: #0000FF;">objects</span> <br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">WHERE</span> object_id <span style="color: #008000;">=</span> OBJECT_ID<span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'&lt;#= &nbsp;table.Name #&gt;Update'</span><span style="color: #008000;">&#41;</span> AND type <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #008000;">&#40;</span>N<span style="color: #666666;">'P'</span>, N<span style="color: #666666;">'PC'</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
DROP PROCEDURE &nbsp;<span style="color: #008000;">&lt;</span><span style="color: #008080;">#= &nbsp;table.Name &nbsp;#&gt;Update</span><br />
GO<br />
<br />
SET ANSI_NULLS ON<br />
GO<br />
<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; CREATE PROCEDURE <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= &nbsp;table.Name &nbsp;#&gt;Update</span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;"># </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PushIndent</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; , &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;varchar&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span><span style="color: #008000;">+</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span><span style="color: #666666;">&quot; &quot;</span><span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;(&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Properties</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Length&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;)&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;@&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">DataType</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">AS</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; SET NOCOUNT ON<br />
&nbsp; &nbsp; &nbsp; &nbsp; UPDATE <span style="color: #008000;">&lt;</span><span style="color: #008080;">#= table.Name #&gt; SET</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&lt;</span><span style="color: #008080;"># </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">InPrimaryKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span>&nbsp; <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = @&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt; &nbsp; &nbsp; &nbsp;WHERE &lt;# &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>Column column <span style="color: #0600FF; font-weight: bold;">in</span> table<span style="color: #008000;">.</span><span style="color: #0000FF;">Columns</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">InPrimaryKey</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span>&nbsp; <span style="color: #008000;">&#40;</span>count<span style="color: #008000;">&gt;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; , &quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span>column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = @&quot;</span> <span style="color: #008000;">+</span> column<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count <span style="color: #008000;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt; </span><br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;"># </span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;GO&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PopIndent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; WriteLine<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#&gt;</span><br />
<br />
<br />
<span style="color: #008000;">&lt;</span><span style="color: #008080;">#&nbsp; &nbsp; &nbsp; </span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <br />
<span style="color: #008080;">#&gt;</span></div></td></tr></tbody></table></div>
<p>Here is what it outputs:</p>
<div class="codecolorer-container sql vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br />282<br />283<br />284<br />285<br />286<br />287<br />288<br />289<br />290<br />291<br />292<br />293<br />294<br />295<br />296<br />297<br />298<br />299<br />300<br />301<br />302<br />303<br />304<br />305<br />306<br />307<br />308<br />309<br />310<br />311<br />312<br />313<br />314<br />315<br />316<br />317<br />318<br />319<br />320<br />321<br />322<br />323<br />324<br />325<br />326<br />327<br />328<br />329<br />330<br />331<br />332<br />333<br />334<br />335<br />336<br />337<br />338<br />339<br />340<br /></div></td><td><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* DELETE SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; ActivityDeleteByActivityID<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'ActivityDeleteByActivityID'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;ActivityDeleteByActivityID<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> ActivityDeleteByActivityID <br />
&nbsp; &nbsp; &nbsp;@ActivityID <span style="color: #993333; font-weight: bold;">INT</span><br />
<br />
<span style="color: #993333; font-weight: bold;">AS</span> <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> Activity <br />
<span style="color: #993333; font-weight: bold;">WHERE</span> ActivityID <span style="color: #66cc66;">=</span> @ActivityID<br />
<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* SELECT BY PRIMARY KEY SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; ActivitySelectByActivityID<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'ActivitySelectByActivityID'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;ActivitySelectByActivityID<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> ActivitySelectByActivityID <br />
&nbsp; &nbsp; &nbsp;@ActivityID <span style="color: #993333; font-weight: bold;">INT</span><br />
<br />
<span style="color: #993333; font-weight: bold;">AS</span> <br />
<span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> Activity <br />
<span style="color: #993333; font-weight: bold;">WHERE</span> ActivityID <span style="color: #66cc66;">=</span> @ActivityID<br />
<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* INSERT TABLE SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; ActivityInsert<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'ActivityInsert'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;ActivityInsert<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> ActivityInsert<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@DestinationID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityTypeID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityName <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityDescription <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityStartTime datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityEndTime datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @URL <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @Cost <span style="color: #993333; font-weight: bold;">DECIMAL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DateCreated datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @CreatedBy <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span>@ActivityID <span style="color: #993333; font-weight: bold;">INT</span> OUTPUT &nbsp; &nbsp;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AS</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> Activity <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestinationID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> ActivityTypeID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> ActivityName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> ActivityDescription<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> ActivityStartTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> ActivityEndTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> URL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> Cost<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> DateCreated<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> CreatedBy<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DestinationID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityTypeID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityDescription<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityStartTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityEndTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @URL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @Cost<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DateCreated<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @CreatedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SELECT</span> @ActivityID <span style="color: #66cc66;">=</span> SCOPE_IDENTITY<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* UPDATE TABLE SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; ActivityUpdate<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'ActivityUpdate'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;ActivityUpdate<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> ActivityUpdate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @ActivityID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityTypeID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityName <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityDescription <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityStartTime datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @ActivityEndTime datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @URL <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @Cost <span style="color: #993333; font-weight: bold;">DECIMAL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DateCreated datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @CreatedBy <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AS</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">UPDATE</span> Activity <span style="color: #993333; font-weight: bold;">SET</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestinationID <span style="color: #66cc66;">=</span> @DestinationID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> ActivityTypeID <span style="color: #66cc66;">=</span> @ActivityTypeID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> ActivityName <span style="color: #66cc66;">=</span> @ActivityName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> ActivityDescription <span style="color: #66cc66;">=</span> @ActivityDescription<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> ActivityStartTime <span style="color: #66cc66;">=</span> @ActivityStartTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> ActivityEndTime <span style="color: #66cc66;">=</span> @ActivityEndTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> URL <span style="color: #66cc66;">=</span> @URL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> Cost <span style="color: #66cc66;">=</span> @Cost<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> DateCreated <span style="color: #66cc66;">=</span> @DateCreated<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> CreatedBy <span style="color: #66cc66;">=</span> @CreatedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> ActivityID <span style="color: #66cc66;">=</span> @ActivityID <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<br />
<br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* DELETE SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; DestinationDeleteByDestinationID<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'DestinationDeleteByDestinationID'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;DestinationDeleteByDestinationID<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> DestinationDeleteByDestinationID <br />
&nbsp; &nbsp; &nbsp;@DestinationID <span style="color: #993333; font-weight: bold;">INT</span><br />
<br />
<span style="color: #993333; font-weight: bold;">AS</span> <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<br />
<span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #993333; font-weight: bold;">FROM</span> Destination <br />
<span style="color: #993333; font-weight: bold;">WHERE</span> DestinationID <span style="color: #66cc66;">=</span> @DestinationID<br />
<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* SELECT BY PRIMARY KEY SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; DestinationSelectByDestinationID<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'DestinationSelectByDestinationID'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;DestinationSelectByDestinationID<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> DestinationSelectByDestinationID <br />
&nbsp; &nbsp; &nbsp;@DestinationID <span style="color: #993333; font-weight: bold;">INT</span><br />
<br />
<span style="color: #993333; font-weight: bold;">AS</span> <br />
<span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> Destination <br />
<span style="color: #993333; font-weight: bold;">WHERE</span> DestinationID <span style="color: #66cc66;">=</span> @DestinationID<br />
<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* INSERT TABLE SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; DestinationInsert<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'DestinationInsert'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;DestinationInsert<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> DestinationInsert<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@DestinationStatusID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationName <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationDetails <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @StartDate datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @EndDate datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @OwnedBy <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @CreatedBy <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DateCreated datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span>@DestinationID <span style="color: #993333; font-weight: bold;">INT</span> OUTPUT &nbsp; &nbsp;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AS</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> Destination <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestinationStatusID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> DestinationName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> DestinationDetails<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> StartDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> EndDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> OwnedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> CreatedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> DateCreated<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DestinationStatusID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationDetails<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @StartDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @EndDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @OwnedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @CreatedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DateCreated<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SELECT</span> @DestinationID <span style="color: #66cc66;">=</span> SCOPE_IDENTITY<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------*/</span><br />
<span style="color: #808080; font-style: italic;">/* UPDATE TABLE SCRIPTS */</span><br />
<span style="color: #808080; font-style: italic;">/* ------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #808080; font-style: italic;">/* -------------------------------------------------------------------------------------<br />
/ &nbsp; &nbsp; DestinationUpdate<br />
/ &nbsp;------------------------------------------------------------------------------------- */</span><br />
<br />
<span style="color: #993333; font-weight: bold;">IF</span> &nbsp;<span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> sys<span style="color: #66cc66;">.</span>objects <br />
&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> object_id <span style="color: #66cc66;">=</span> OBJECT_ID<span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'DestinationUpdate'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AND</span> <span style="color: #993333; font-weight: bold;">TYPE</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span>N<span style="color: #ff0000;">'P'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'PC'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> &nbsp;DestinationUpdate<br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
<br />
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER <span style="color: #993333; font-weight: bold;">ON</span><br />
<span style="color: #993333; font-weight: bold;">GO</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">PROCEDURE</span> DestinationUpdate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @DestinationID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationStatusID <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationName <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DestinationDetails <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @StartDate datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @EndDate datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @OwnedBy <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @CreatedBy <span style="color: #993333; font-weight: bold;">INT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">,</span> @DateCreated datetime<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">AS</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">UPDATE</span> Destination <span style="color: #993333; font-weight: bold;">SET</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestinationStatusID <span style="color: #66cc66;">=</span> @DestinationStatusID<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> DestinationName <span style="color: #66cc66;">=</span> @DestinationName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> DestinationDetails <span style="color: #66cc66;">=</span> @DestinationDetails<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> StartDate <span style="color: #66cc66;">=</span> @StartDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> EndDate <span style="color: #66cc66;">=</span> @EndDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> OwnedBy <span style="color: #66cc66;">=</span> @OwnedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> CreatedBy <span style="color: #66cc66;">=</span> @CreatedBy<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">,</span> DateCreated <span style="color: #66cc66;">=</span> @DateCreated<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHERE</span> DestinationID <span style="color: #66cc66;">=</span> @DestinationID <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">GO</span></div></td></tr></tbody></table></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=kNCqTRoqj2U:kRU-66WDEXs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=kNCqTRoqj2U:kRU-66WDEXs:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=kNCqTRoqj2U:kRU-66WDEXs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=kNCqTRoqj2U:kRU-66WDEXs:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/kNCqTRoqj2U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/vs-2012-t4-template-code-gen-stored-proc-sample/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/vs-2012-t4-template-code-gen-stored-proc-sample/</feedburner:origLink></item>
		<item>
		<title>How to Backup Your WordPress Website</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/DlamqvlMw2I/</link>
		<comments>http://tropicalcoding.com/how-to-backup-your-wordpress-website/#comments</comments>
		<pubDate>Mon, 16 Jul 2012 13:53:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=1004</guid>
		<description><![CDATA[Found a pretty comprehensive tutorial on how to backup your WordPress website with either the WordPress import/export function or using cPanel. http://www.noupe.com/wordpress/how-to-backup-your-wordpress-website.html]]></description>
			<content:encoded><![CDATA[<p>Found a pretty comprehensive tutorial on how to backup your WordPress website with either the WordPress import/export function or using cPanel.  </p>
<p>http://www.noupe.com/wordpress/how-to-backup-your-wordpress-website.html</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=DlamqvlMw2I:THGskTwEDGg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=DlamqvlMw2I:THGskTwEDGg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=DlamqvlMw2I:THGskTwEDGg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=DlamqvlMw2I:THGskTwEDGg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/DlamqvlMw2I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/how-to-backup-your-wordpress-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/how-to-backup-your-wordpress-website/</feedburner:origLink></item>
		<item>
		<title>.NET Separate Address, City, State, and Zip</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/Zl6TeB4Uil8/</link>
		<comments>http://tropicalcoding.com/net-function-to-separate-address-city-state-and-zip/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 05:07:19 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[DataRow]]></category>
		<category><![CDATA[DataRowView]]></category>
		<category><![CDATA[Datatable]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[String Function]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=992</guid>
		<description><![CDATA[In this scenario, I was importing an Excel spreadsheet, and I was provided an address in the following format: Street, City, State, Zip I needed to strip each one out so that I could store them in separate fields in the database. 123456789'My datarowview and datatable For Each drvMyDataRowViewName In dtMyDataTableName.DefaultView 'Set the results of [...]]]></description>
			<content:encoded><![CDATA[<p>In this scenario, I was importing an Excel spreadsheet, and I was provided an address in the following format:</p>
<p>Street, City, State, Zip</p>
<p>I needed to strip each one out so that I could store them in separate fields in the database.</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">'My datarowview and datatable</span><br />
<span style="color: #990099; font-weight: bold;">For</span> <span style="color: #990099; font-weight: bold;">Each</span> drvMyDataRowViewName <span style="color: #990099; font-weight: bold;">In</span> dtMyDataTableName.<span style="color: #9900cc;">DefaultView</span><br />
<br />
<span style="color: #008000;">'Set the results of the SeparateFullAddressFunction to an array</span><br />
<span style="color: #990099; font-weight: bold;">Dim</span> fullAddress <span style="color: #330066;">As</span> <span style="color: #330066;">Array</span><br />
<br />
<span style="color: #008000;">'Pass in FullAddress as a string</span><br />
fullAddress <span style="color: #006600; font-weight: bold;">=</span> SeparateFullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>drvMyDataRowViewName<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;TheAddressColumnNameInTheDatatable&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<span style="color: #990099; font-weight: bold;">Next</span></div></td></tr></tbody></table></div>
<p>Here is the SeparateFullAddress function:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #990099; font-weight: bold;">Private</span> <span style="color: #0000ff; font-weight: bold;">Function</span> SeparateFullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #990099; font-weight: bold;">ByVal</span> FullAddress <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #330066;">As</span> <span style="color: #330066;">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> AddressArray <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> Street <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> City <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> State <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> ZipCode <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> lastIndex <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastIndex <span style="color: #006600; font-weight: bold;">=</span> FullAddress.<span style="color: #9900cc;">LastIndexOf</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot; &quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ZipCode <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">'Remove Zip Code From String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FullAddress <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Remove</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastIndex <span style="color: #006600; font-weight: bold;">=</span> FullAddress.<span style="color: #9900cc;">LastIndexOf</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;,&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; State <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Replace</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;,&quot;</span>, <span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Trim</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">'Remove State From String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FullAddress <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Remove</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastIndex <span style="color: #006600; font-weight: bold;">=</span> FullAddress.<span style="color: #9900cc;">LastIndexOf</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; City <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Replace</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;;&quot;</span>, <span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Trim</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">'Remove City From String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FullAddress <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Remove</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Street <span style="color: #006600; font-weight: bold;">=</span> FullAddress<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressArray <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">New</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight:bold;">&#123;</span>Street, City, State, ZipCode<span style="color: #006600; font-weight:bold;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return AddressArray<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Catch ex <span style="color: #330066;">As</span> Exception<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressArray <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">New</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight:bold;">&#123;</span><span style="color: #cc0000;">&quot;Error&quot;</span><span style="color: #006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return AddressArray<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">End</span> Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">End</span> <span style="color: #0000ff; font-weight: bold;">Function</span></div></td></tr></tbody></table></div>
<p>After the array called &#8220;fulladdress&#8221; was returned, I split it out and inserted it into another datatable, but you can replace row(&#8220;MailingAddress1&#8243;),etc with whatever you want.</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">If</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">0</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;Error&quot;</span> <span style="color: #990099; font-weight: bold;">Then</span><br />
<span style="color: #008000;">'This was added because the spreadsheets often had weird, unpredictable data (imagine that), so rather than have an ambiguous error message, I had to give the user some feedback. I had previously declared &quot;ErrorMessage&quot; (Dim ErrorMessage As New StringBuilder)</span><br />
<br />
&nbsp;ErrorMessage.<span style="color: #9900cc;">Append</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;ERROR: Address is in an incorrect format.&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp;row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Error&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> ErrorMessage<br />
<span style="color: #990099; font-weight: bold;">Else</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingAddress1&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">0</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingCity&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">1</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingState&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">2</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingZipCode&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">3</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span></div></td></tr></tbody></table></div>
<p>Full code:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">'My datarowview and datatable</span><br />
<span style="color: #990099; font-weight: bold;">For</span> <span style="color: #990099; font-weight: bold;">Each</span> drvMyDataRowViewName <span style="color: #990099; font-weight: bold;">In</span> dtMyDataTableName.<span style="color: #9900cc;">DefaultView</span><br />
<br />
<span style="color: #008000;">'Set the results of the SeparateFullAddressFunction to an array</span><br />
<span style="color: #990099; font-weight: bold;">Dim</span> fullAddress <span style="color: #330066;">As</span> <span style="color: #330066;">Array</span><br />
<br />
<span style="color: #008000;">'Pass in FullAddress as a string</span><br />
fullAddress <span style="color: #006600; font-weight: bold;">=</span> SeparateFullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>drvMyDataRowViewName<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;TheAddressColumnNameInTheDatatable&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<span style="color: #990099; font-weight: bold;">Next</span><br />
<br />
<br />
&nbsp;<span style="color: #990099; font-weight: bold;">Private</span> <span style="color: #0000ff; font-weight: bold;">Function</span> SeparateFullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #990099; font-weight: bold;">ByVal</span> FullAddress <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #330066;">As</span> <span style="color: #330066;">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> AddressArray <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> Street <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> City <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> State <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> ZipCode <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">Dim</span> lastIndex <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastIndex <span style="color: #006600; font-weight: bold;">=</span> FullAddress.<span style="color: #9900cc;">LastIndexOf</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot; &quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ZipCode <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">'Remove Zip Code From String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FullAddress <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Remove</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastIndex <span style="color: #006600; font-weight: bold;">=</span> FullAddress.<span style="color: #9900cc;">LastIndexOf</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;,&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; State <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Replace</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;,&quot;</span>, <span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Trim</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">'Remove State From String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FullAddress <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Remove</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastIndex <span style="color: #006600; font-weight: bold;">=</span> FullAddress.<span style="color: #9900cc;">LastIndexOf</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; City <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Substring</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Replace</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;;&quot;</span>, <span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #330066;">Trim</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">'Remove City From String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FullAddress <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #330066;">Trim</span><span style="color: #006600; font-weight:bold;">&#40;</span>FullAddress.<span style="color: #9900cc;">Remove</span><span style="color: #006600; font-weight:bold;">&#40;</span>lastIndex<span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Street <span style="color: #006600; font-weight: bold;">=</span> FullAddress<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressArray <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">New</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight:bold;">&#123;</span>Street, City, State, ZipCode<span style="color: #006600; font-weight:bold;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return AddressArray<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Catch ex <span style="color: #330066;">As</span> Exception<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressArray <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #0000ff; font-weight: bold;">New</span> <span style="color: #990099; font-weight: bold;">String</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight:bold;">&#123;</span><span style="color: #cc0000;">&quot;Error&quot;</span><span style="color: #006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return AddressArray<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">End</span> Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #990099; font-weight: bold;">End</span> <span style="color: #0000ff; font-weight: bold;">Function</span><br />
<br />
<span style="color: #990099; font-weight: bold;">If</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">0</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;Error&quot;</span> <span style="color: #990099; font-weight: bold;">Then</span><br />
<span style="color: #008000;">'This was added because the spreadsheets often had weird, unpredictable data (imagine that), so rather than have an ambiguous error message, I had to give the user some feedback. I had previously declared &quot;ErrorMessage&quot; (Dim ErrorMessage As New StringBuilder)</span><br />
<br />
&nbsp;ErrorMessage.<span style="color: #9900cc;">Append</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;ERROR: Address is in an incorrect format.&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp;row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;Error&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> ErrorMessage<br />
<span style="color: #990099; font-weight: bold;">Else</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingAddress1&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">0</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingCity&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">1</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingState&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">2</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; row<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;MailingZipCode&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> fullAddress<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #800000;">3</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span></div></td></tr></tbody></table></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=Zl6TeB4Uil8:wbwvoraTmjQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=Zl6TeB4Uil8:wbwvoraTmjQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=Zl6TeB4Uil8:wbwvoraTmjQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=Zl6TeB4Uil8:wbwvoraTmjQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/Zl6TeB4Uil8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/net-function-to-separate-address-city-state-and-zip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/net-function-to-separate-address-city-state-and-zip/</feedburner:origLink></item>
		<item>
		<title>.NET Gridview TemplateField Change Boolean to Yes or No</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/fMDI7GYv7Ak/</link>
		<comments>http://tropicalcoding.com/net-gridview-templatefield-change-boolean-to-yes-or-no/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 04:26:06 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Gridview]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Templatefield]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=985</guid>
		<description><![CDATA[When you bind boolean data to a gridview, and you wish to change the 1 or 0 to something meaningful such as Yes or No, try the following: 12345678&#160; &#160;&#60;asp:GridView ID=&#34;MyFancyGridviewName&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;False&#34; &#62; &#160; &#160; &#160; &#160; &#60;Columns&#62; &#160; &#160; &#160; &#160; &#160; &#160; &#60;asp:TemplateField HeaderText=&#34;Active?&#34;&#62; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>When you bind boolean data to a gridview, and you wish to change the 1 or 0 to something meaningful such as Yes or No, try the following:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;&lt;asp:GridView ID=&quot;MyFancyGridviewName&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; &gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;Columns&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:TemplateField HeaderText=&quot;Active?&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ItemTemplate&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;%</span>#IIf<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #990099; font-weight: bold;">Boolean</span>.<span style="color: #9900cc;">Parse</span><span style="color: #006600; font-weight:bold;">&#40;</span>Eval<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;ItemStatus&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #9900cc;">ToString</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #006600; font-weight:bold;">&#41;</span>, <span style="color: #cc0000;">&quot;Yes&quot;</span>, <span style="color: #cc0000;">&quot;No&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>&lt;/ItemTemplate&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/asp:TemplateField&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/Columns&gt;<br />
&nbsp; &nbsp; &lt;/asp:GridView&gt;</div></td></tr></tbody></table></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=fMDI7GYv7Ak:pvFu0LW1OKo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=fMDI7GYv7Ak:pvFu0LW1OKo:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=fMDI7GYv7Ak:pvFu0LW1OKo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=fMDI7GYv7Ak:pvFu0LW1OKo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/fMDI7GYv7Ak" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/net-gridview-templatefield-change-boolean-to-yes-or-no/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/net-gridview-templatefield-change-boolean-to-yes-or-no/</feedburner:origLink></item>
		<item>
		<title>Developers’ Blog Network is Now Live</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/2baJY7CkJaM/</link>
		<comments>http://tropicalcoding.com/developers-blog-network-is-now-live/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 02:11:52 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[developer blogs]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=979</guid>
		<description><![CDATA[Over the years, I have looked for sites that would list quality blogs about programming/development – especially when I was trying to learn something new.  However, I have only found a few here and there.  I’d often have to slog through the search results to find some useful sites.  My intention is to gather up [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years, I have looked for sites that would list quality blogs about programming/development – especially when I was trying to learn something new.  However, I have only found a few here and there.  I’d often have to slog through the search results to find some useful sites.  My intention is to gather up these useful sites to minimize the time wasted filtering through the junk.</p>
<p>So, I started another site called <a title="Developers Blog Network" href="http://developersblognetwork.com" target="_blank">Developers&#8217; Blog Network</a> that has listings of all kinds of blogs/articles that are helpful to us programmers. I will be adding more as time goes on. If you have any you&#8217;d like to add, <a title="Developers Blog Network Submit Listing" href="http://developersblognetwork.com/how-to-get-listed/submit-listing/" target="_blank">please submit a listing</a>.</p>
<p>Thanks!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=2baJY7CkJaM:DpkPsLzZe_c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=2baJY7CkJaM:DpkPsLzZe_c:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=2baJY7CkJaM:DpkPsLzZe_c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=2baJY7CkJaM:DpkPsLzZe_c:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/2baJY7CkJaM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/developers-blog-network-is-now-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/developers-blog-network-is-now-live/</feedburner:origLink></item>
		<item>
		<title>Install WordPress Locally on Windows with Xampp</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/vbp_B3Kt8s8/</link>
		<comments>http://tropicalcoding.com/install-wordpress-locally-on-windows-with-xampp/#comments</comments>
		<pubDate>Fri, 06 Jul 2012 17:08:29 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Xampp]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=970</guid>
		<description><![CDATA[Found this great site that walks you through the steps of setting up WordPress on a Windows machine using Xampp. http://wpmu.org/install-wordpress-locally-on-windows-with-xampp/ &#160; If you encounter any problems, you might want to check out this site, as it documents one person&#8217;s problems (and solutions) when trying to get Xampp to play nicely with Windows: http://www.conflicteddeveloper.com/?p=5]]></description>
			<content:encoded><![CDATA[<p>Found this great site that walks you through the steps of setting up WordPress on a Windows machine using Xampp.</p>
<p><a href="http://wpmu.org/install-wordpress-locally-on-windows-with-xampp/">http://wpmu.org/install-wordpress-locally-on-windows-with-xampp/</a></p>
<p>&nbsp;</p>
<p>If you encounter any problems, you might want to check out this site, as it documents one person&#8217;s problems (and solutions) when trying to get Xampp to play nicely with Windows:</p>
<p><a href="http://www.conflicteddeveloper.com/?p=5">http://www.conflicteddeveloper.com/?p=5</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=vbp_B3Kt8s8:5KCWQQ1ggEg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=vbp_B3Kt8s8:5KCWQQ1ggEg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=vbp_B3Kt8s8:5KCWQQ1ggEg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=vbp_B3Kt8s8:5KCWQQ1ggEg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/vbp_B3Kt8s8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/install-wordpress-locally-on-windows-with-xampp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/install-wordpress-locally-on-windows-with-xampp/</feedburner:origLink></item>
		<item>
		<title>SSRS Formatting: Remove Date from DateTime</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/rJdSWKKUzkY/</link>
		<comments>http://tropicalcoding.com/ssrs-formatting-remove-time-from-datetime/#comments</comments>
		<pubDate>Mon, 02 Jul 2012 12:21:46 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[SSRS]]></category>
		<category><![CDATA[SSRS Formatting]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[DateTime]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=823</guid>
		<description><![CDATA[When writing reports, sometimes you need to remove the date and just view the time&#8230;.perhaps in the case of an appointment time, or a manager is checking up on his/her employees because they didn&#8217;t finish something on time. 1) Make sure that your column is a textbox.  If not drag a textbox from the toolbox [...]]]></description>
			<content:encoded><![CDATA[<p>When writing reports, sometimes you need to remove the date and just view the time&#8230;.perhaps in the case of an appointment time, or a manager is checking up on his/her employees because they didn&#8217;t finish something on time.</p>
<p>1) Make sure that your column is a textbox.  If not drag a textbox from the toolbox into the cell.</p>
<p>2) Right-click textbox, and choose &#8216;Text Box Properties&#8230;&#8217;</p>
<p>3) Click on &#8216;General&#8217; on the left-hand side.  Look for the &#8216;Value:&#8217; prompt, and click &#8216;<em>fx</em>&#8216;.</p>
<p>4) Paste the following:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-weight: bold;">=</span>Format<span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">Fields</span><span style="color: #006600; font-weight: bold;">!</span>FieldIAmTryingToBendToMyWill.<span style="color: #9900cc;">Value</span>,”t”<span style="color: #006600; font-weight:bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>This code will take this:</p>
<p>2012-06-30 12:13:52.893</p>
<p>And format it to look like this:<br />
12:13 PM</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=rJdSWKKUzkY:O1kMl6Y5-YU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=rJdSWKKUzkY:O1kMl6Y5-YU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=rJdSWKKUzkY:O1kMl6Y5-YU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=rJdSWKKUzkY:O1kMl6Y5-YU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/rJdSWKKUzkY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/ssrs-formatting-remove-time-from-datetime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/ssrs-formatting-remove-time-from-datetime/</feedburner:origLink></item>
		<item>
		<title>PHPMyAdmin/MySQL Error: “You probably tried to upload too large file” when trying to import database</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/yqj5PxxdgZw/</link>
		<comments>http://tropicalcoding.com/phpmyadminmysql-error-you-probably-tried-to-upload-too-large-file-when-trying-to-import-database/#comments</comments>
		<pubDate>Sat, 30 Jun 2012 19:53:04 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[PHPMyAdmin]]></category>
		<category><![CDATA[Xampp]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=730</guid>
		<description><![CDATA[Yesterday, I was attempting to backup and restore a local copy of my WordPress database on a Windows 7 64 bit machine running Xampp. Since I was working locally, I am the master of my universe (ok, Super Admin), and I can do whatever I want.  I was able to increase the upload size and [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I was attempting to backup and restore a local copy of my WordPress database on a Windows 7 64 bit machine running Xampp.</p>
<p>Since I was working locally, I am the master of my universe (ok, Super Admin), and I can do whatever I want.  I was able to increase the upload size and successfully import the .sql file.</p>
<p>Here are the instructions:</p>
<p>1) Find your php.ini file (for me, it was where I installed Xampp: C:\xampp\php.ini).</p>
<p>2) Find the following values and increase them to whatever you want: upload_max_filesize, memory_limit and post_max_size.</p>
<p>3) Restart the Xampp server.  You can do this by going to the Xampp Control Panel and stopping the service.</p>
<p>4) If you try to stop the service, and receive an &#8220;error: -1&#8243; message, then exit the control panel (shut it down).  You don&#8217;t have permissions to do this.</p>
<p>5) Relaunch the Xampp Control Panel  as an Admin by Right clicking and running it as administrator.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=yqj5PxxdgZw:QtSYq4eyL2A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=yqj5PxxdgZw:QtSYq4eyL2A:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=yqj5PxxdgZw:QtSYq4eyL2A:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=yqj5PxxdgZw:QtSYq4eyL2A:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/yqj5PxxdgZw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/phpmyadminmysql-error-you-probably-tried-to-upload-too-large-file-when-trying-to-import-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/phpmyadminmysql-error-you-probably-tried-to-upload-too-large-file-when-trying-to-import-database/</feedburner:origLink></item>
		<item>
		<title>.NET Objectdatasource Sum Column</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/oSNmkthilcY/</link>
		<comments>http://tropicalcoding.com/net-objectdatasource-sum-column/#comments</comments>
		<pubDate>Mon, 11 Jun 2012 16:04:42 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Datatable]]></category>
		<category><![CDATA[DataView]]></category>
		<category><![CDATA[Objectdatasource]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Format]]></category>
		<category><![CDATA[Formatting]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=961</guid>
		<description><![CDATA[If you have the need to sum a column of a recordset tied to an objectdatasource, you can try the following.  This is just returning sum of the column&#8217;s value, which is useful when you just need a piece of information for display purposes.  In this scenario, I am totaling the number of hours worked [...]]]></description>
			<content:encoded><![CDATA[<p>If you have the need to sum a column of a recordset tied to an objectdatasource, you can try the following.  This is just returning sum of the column&#8217;s value, which is useful when you just need a piece of information for display purposes.  In this scenario, I am totaling the number of hours worked (a decimal value).</p>
<p>1) Declare the dataview and assign the objectdatasource to it:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">Dim</span> dv <span style="color: #330066;">As</span> DataView<br />
<br />
dv <span style="color: #006600; font-weight: bold;">=</span> MyObjectdatasourceName.<span style="color: #990099; font-weight: bold;">Select</span></div></td></tr></tbody></table></div>
<p>2) Declare a new datatable and assign it to the dataview&#8217;s table object:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">Dim</span> dt <span style="color: #330066;">As</span> <span style="color: #0000ff; font-weight: bold;">New</span> DataTable<br />
<br />
dt <span style="color: #006600; font-weight: bold;">=</span> dv.<span style="color: #9900cc;">ToTable</span></div></td></tr></tbody></table></div>
<p>3) Create a variable to hold the value:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">Dim</span> TotalHours <span style="color: #330066;">As</span> Decimal</div></td></tr></tbody></table></div>
<p>4) I like to make sure there actually rows before I try to sum:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">If</span> dt.<span style="color: #9900cc;">Rows</span>.<span style="color: #9900cc;">Count</span> <span style="color: #006600; font-weight: bold;">&gt;</span> <span style="color: #800000;">0</span> <span style="color: #990099; font-weight: bold;">Then</span><br />
<br />
TotalHours <span style="color: #006600; font-weight: bold;">=</span> dt.<span style="color: #9900cc;">Compute</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;SUM(ColumnYouAreTryingToSum)&quot;</span>, <span style="color: #990099; font-weight: bold;">String</span>.<span style="color: #9900cc;">Empty</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<span style="color: #990099; font-weight: bold;">Else</span><br />
TotalHours <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span><br />
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span></div></td></tr></tbody></table></div>
<p>5) I then printed it out to a label:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">lblTimeEntryRecordsResult.<span style="color: #9900cc;">Text</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;Total Hours For This Issue: &quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> TotalHours</div></td></tr></tbody></table></div>
<p>Full Code:</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">Dim</span> dv <span style="color: #330066;">As</span> DataView<br />
<br />
dv <span style="color: #006600; font-weight: bold;">=</span> MyObjectdatasourceName.<span style="color: #990099; font-weight: bold;">Select</span><br />
<br />
<span style="color: #990099; font-weight: bold;">Dim</span> dt <span style="color: #330066;">As</span> <span style="color: #0000ff; font-weight: bold;">New</span> DataTable<br />
<br />
dt <span style="color: #006600; font-weight: bold;">=</span> dv.<span style="color: #9900cc;">ToTable</span><br />
<br />
<span style="color: #990099; font-weight: bold;">Dim</span> TotalHours <span style="color: #330066;">As</span> Decimal<br />
<br />
<span style="color: #990099; font-weight: bold;">If</span> dt.<span style="color: #9900cc;">Rows</span>.<span style="color: #9900cc;">Count</span> <span style="color: #006600; font-weight: bold;">&gt;</span> <span style="color: #800000;">0</span> <span style="color: #990099; font-weight: bold;">Then</span><br />
<br />
TotalHours <span style="color: #006600; font-weight: bold;">=</span> dt.<span style="color: #9900cc;">Compute</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;SUM(Duration)&quot;</span>, <span style="color: #990099; font-weight: bold;">String</span>.<span style="color: #9900cc;">Empty</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<span style="color: #990099; font-weight: bold;">Else</span><br />
TotalHours <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span><br />
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span><br />
<br />
lblTimeEntryRecordsResult.<span style="color: #9900cc;">Text</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;Total Hours For This Issue: &quot;</span> <span style="color: #006600; font-weight: bold;">&amp;</span> TotalHours</div></td></tr></tbody></table></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=oSNmkthilcY:5wiYg4fdFu0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=oSNmkthilcY:5wiYg4fdFu0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=oSNmkthilcY:5wiYg4fdFu0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=oSNmkthilcY:5wiYg4fdFu0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/oSNmkthilcY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/net-objectdatasource-sum-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/net-objectdatasource-sum-column/</feedburner:origLink></item>
		<item>
		<title>.NET Datatable: Loop Columns to Remove Spaces in Column Name</title>
		<link>http://feedproxy.google.com/~r/TropicalCoding/~3/BDpZJePP9qs/</link>
		<comments>http://tropicalcoding.com/net-datatable-loop-columns-to-remove-spaces-in-column-name/#comments</comments>
		<pubDate>Sun, 10 Jun 2012 09:37:47 +0000</pubDate>
		<dc:creator>tropicalcoding</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Datatable]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Looping]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://tropicalcoding.com/?p=942</guid>
		<description><![CDATA[In one project, I had to loop through the datatable columns and remove the spaces in the column name.  I had to import an Excel spreadsheet into a datatable, and sometimes, the spreadsheet provider did not follow the instructions and name the column properly.  In this scenario, the column names had additional spaces in them. [...]]]></description>
			<content:encoded><![CDATA[<p>In one project, I had to loop through the datatable columns and remove the spaces in the column name.  I had to import an Excel spreadsheet into a datatable, and sometimes, the spreadsheet provider did not follow the instructions and name the column properly.  In this scenario, the column names had additional spaces in them.  However, you could apply this technique to replace anything else.</p>
<div class="codecolorer-container asp vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="asp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">For</span> i <span style="color: #330066;">As</span> <span style="color: #990099; font-weight: bold;">Integer</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span> <span style="color: #990099; font-weight: bold;">To</span> TheNameOfMyDataTable.<span style="color: #9900cc;">Columns</span>.<span style="color: #9900cc;">Count</span> - <span style="color: #800000;">1</span><br />
<br />
TheNameOfMyDataTable.<span style="color: #9900cc;">Columns</span><span style="color: #006600; font-weight:bold;">&#40;</span>i<span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #9900cc;">ColumnName</span> <span style="color: #006600; font-weight: bold;">=</span> TheNameOfMyDataTable.<span style="color: #9900cc;">Columns</span><span style="color: #006600; font-weight:bold;">&#40;</span>i<span style="color: #006600; font-weight:bold;">&#41;</span>.<span style="color: #9900cc;">ColumnName</span>.<span style="color: #9900cc;">ToString</span>.<span style="color: #330066;">Trim</span>.<span style="color: #330066;">Replace</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot; &quot;</span>, <span style="color: #cc0000;">&quot;&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span><br />
<span style="color: #990099; font-weight: bold;">Next</span></div></td></tr></tbody></table></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=BDpZJePP9qs:ToMy02QG_SM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=BDpZJePP9qs:ToMy02QG_SM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/TropicalCoding?a=BDpZJePP9qs:ToMy02QG_SM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/TropicalCoding?i=BDpZJePP9qs:ToMy02QG_SM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/TropicalCoding/~4/BDpZJePP9qs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tropicalcoding.com/net-datatable-loop-columns-to-remove-spaces-in-column-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tropicalcoding.com/net-datatable-loop-columns-to-remove-spaces-in-column-name/</feedburner:origLink></item>
	</channel>
</rss>
