<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7799903173670515239</id><updated>2011-08-03T01:00:42.839+10:00</updated><category term='Regular Expression selective replace'/><category term='VBA'/><category term='XML Render Internet Explorer .NET WebBrowser'/><category term='AJAX Atlas UpdatePanel UpdateProgress GridView Javascript'/><category term='sql rowcount analysis table view'/><category term='Range'/><category term='SQL 2005 2008 Table Type CREATE TABLE LIKE'/><category term='Macro'/><category term='Multi-line regular expression'/><category term='SQL Character Analysis ASCII count'/><category term='Xml Comparison Excel'/><category term='DataSet Xml Schemas Excel'/><category term='Regular Expression phrase contain keywords'/><category term='Excel'/><title type='text'>"Net Thread" - George Zabanah's Blog</title><subtitle type='html'>Let's discuss Development and technical management. Technologies include C#, SQL, VB.NET, ORACLE, and many many more.  I would definitely welcome any suggestions on interesting topics, technical problems etc.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-2223048140074930251</id><published>2010-11-04T22:51:00.006+11:00</published><updated>2010-11-05T22:13:19.771+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VBA'/><category scheme='http://www.blogger.com/atom/ns#' term='Range'/><category scheme='http://www.blogger.com/atom/ns#' term='Excel'/><category scheme='http://www.blogger.com/atom/ns#' term='Macro'/><title type='text'>Excel-lent VBA Range Macro Examples</title><content type='html'>You learn something new every day. Needed some range examples in Excel - couldn't find some appropriate examples on the internet ... so I created my own. Hope this is helpful to someone. :)&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Sub RangeExamples()&lt;br /&gt;Dim r As Range&lt;br /&gt;Set r = Sheet1.Range("E5:G11")&lt;br /&gt;' The range&lt;br /&gt;Debug.Print "The Range: " &amp;amp; r.Address&lt;br /&gt;' Last Column in the range&lt;br /&gt;Debug.Print "Last Column: " &amp;amp; r.Columns(r.Columns.Count).EntireColumn.Address&lt;br /&gt;' First Column in the range&lt;br /&gt;Debug.Print "First Column: " &amp;amp; r.Columns(1).EntireColumn.Address&lt;br /&gt;' First Row in the range&lt;br /&gt;Debug.Print "First Row: " &amp;amp; r.Rows(1).EntireRow.Address&lt;br /&gt;' Last Row in the range&lt;br /&gt;Debug.Print "Last Row: " &amp;amp; r.Rows(r.Rows.Count).EntireRow.Address&lt;br /&gt;&lt;br /&gt;' Top-right Cell in the range&lt;br /&gt;Debug.Print "Top-right: " &amp;amp; r.Cells(, r.Columns.Count).Address&lt;br /&gt;' Top-left Cell in the range&lt;br /&gt;Debug.Print "Top-left: " &amp;amp; r.Cells(1).Address&lt;br /&gt;' Bottom-right Cell in the range&lt;br /&gt;Debug.Print "Bottom-right: " &amp;amp; r.Cells(r.Rows.Count, r.Columns.Count).Address&lt;br /&gt;' Bottom-left Cell in the range&lt;br /&gt;Debug.Print "Bottom-left: " &amp;amp; r.Cells(r.Rows.Count, 1).Address&lt;br /&gt;&lt;br /&gt;' Intersection of range&lt;br /&gt;Dim r2, r3, r4, r5 As Range&lt;br /&gt;Set r2 = Sheet1.Range("$F:$F")&lt;br /&gt;Set r3 = Intersect(r, r2)&lt;br /&gt;Debug.Print "Intersection is: " &amp;amp; r3.Address&lt;br /&gt;&lt;br /&gt;Set r4 = Sheet1.Range("$L:$L")&lt;br /&gt;Set r5 = Union(r4, r3)&lt;br /&gt;&lt;br /&gt;' the range between ranges&lt;br /&gt;' between separate columns&lt;br /&gt;Debug.Print Sheet1.Range(Sheet1.Cells(, r3.Column), Sheet1.Cells(, r4.Column)).EntireColumn.Address&lt;br /&gt;&lt;br /&gt;' between separate rows&lt;br /&gt;Dim r6, r7 As Range&lt;br /&gt;Set r6 = Sheet1.Rows(10)&lt;br /&gt;Set r7 = Sheet1.Rows(3)&lt;br /&gt;&lt;br /&gt;Debug.Print Sheet1.Range(r7.Row &amp;amp; ":" &amp;amp; r6.Row).Address&lt;br /&gt;End Sub&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-2223048140074930251?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/2223048140074930251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=2223048140074930251' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2223048140074930251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2223048140074930251'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2010/11/vba-excel-macro-examples.html' title='Excel-lent VBA Range Macro Examples'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-610896967408897571</id><published>2008-03-30T23:12:00.003+11:00</published><updated>2008-03-31T00:33:39.018+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AJAX Atlas UpdatePanel UpdateProgress GridView Javascript'/><title type='text'>AJAX/Atlas UpdatePanel and UpdateProgress with GridView</title><content type='html'>There are a few basic tricks that I have discovered today.&lt;br /&gt;&lt;br /&gt;1) When you click on a button to update an UpdatePanel, you can hide a GridView by adding code to the OnClientClickEvent (so only the UpdateProgress shows while the UpdatePanel is updating)&lt;br /&gt;&lt;br /&gt;i.e.&lt;br /&gt;&lt;br /&gt;OnClientClick="if(window.document.all('GridView')) window.document.all('GridView1').style.visibility = 'hidden';"&lt;br /&gt;&lt;br /&gt;2) You can intercept the __doPostBack to add functionality by injecting Javascript code. The benefit of this is when you enable Paging on the GridView and the user clicks on another page. i.e.&lt;br /&gt;inject the following code using Page.ClientScript.RegisterStartupScript(this.GetType(), "script" ...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// save the original function pointer of the .NET __doPostBack function&lt;br /&gt;// in a global variable netPostBack&lt;br /&gt;var netPostBack = __doPostBack&lt;br /&gt;// replace __doPostBack with your own function&lt;br /&gt;__doPostBack = GridViewHide;&lt;br /&gt;&lt;br /&gt;function GridViewHide (eventTarget, eventArgument)&lt;br /&gt;{ alert('test');&lt;br /&gt;if(eventArgument.indexOf('Page') == 0) window.document.all(eventTarget).style.visibility = 'hidden';&lt;br /&gt;// call base functionality&lt;br /&gt;&lt;br /&gt;return netPostBack (eventTarget, eventArgument);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The effect is pretty cool.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-610896967408897571?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/610896967408897571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=610896967408897571' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/610896967408897571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/610896967408897571'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2008/03/ajaxatlas-updatepanel-and.html' title='AJAX/Atlas UpdatePanel and UpdateProgress with GridView'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-3254415756145816194</id><published>2008-03-28T23:03:00.003+11:00</published><updated>2008-03-28T23:06:22.508+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Regular Expression phrase contain keywords'/><title type='text'>Fun with Regular Expressions</title><content type='html'>I found a post on the Microsoft Forums that I had a bit of fun with.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2941690&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2941690&amp;amp;SiteID=1&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;My response shows how to find a fixed length phrase in a document that start with certain words.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-3254415756145816194?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/3254415756145816194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=3254415756145816194' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/3254415756145816194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/3254415756145816194'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2008/03/fun-with-regular-expressions.html' title='Fun with Regular Expressions'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-6879250839819060629</id><published>2008-03-24T19:07:00.006+11:00</published><updated>2008-03-29T14:21:59.129+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL 2005 2008 Table Type CREATE TABLE LIKE'/><title type='text'>SQL2008 - Create Table Based on User-Defined Table Type</title><content type='html'>Table types are really neat. Mind you, one of the features I would love to see is the ability to create a table based on a table type (i.e. CREATE TABLE &lt;mytable&gt; LIKE &lt;mytabletype&gt;).&lt;br/&gt;&lt;br /&gt;Imagine this scenario, you define all your table types up front with extended property "TableType" i.e. (each Table Type will have whatever columns it needs - but will have extended property "TableType")&lt;br/&gt;&lt;br /&gt;"TableType" 1 = Lookup table,&lt;br/&gt;&lt;br /&gt;"TableType" 2 = Lookup table,&lt;br/&gt;&lt;br /&gt;"TableType" 3 = Fact table,&lt;br/&gt;&lt;br /&gt;"TableType" 4 = Dimension table&lt;br/&gt; &lt;br /&gt;(Assuming a data warehouse here.)&lt;br/&gt;&lt;br /&gt;... OR ...&lt;br /&gt;Table Type 1 = Lookup table,&lt;br/&gt;&lt;br /&gt;Table Type 2 = Data table,&lt;br/&gt;&lt;br /&gt;Table Type 3 = History table&lt;br/&gt;&lt;br /&gt;(Assuming an OLTP system)&lt;br/&gt;&lt;br /&gt;You would be able to define the table types in one location, and the extended properties and indexes (optionally) could be propagated to the tables you create based on those types.  I picture it almost like inheritance, you could create a table based on a table type - then extend the table type to include additional properties.&lt;br/&gt;&lt;br /&gt;Advantages of this would be that you could apply manageability rules (similar to what VS2005 has and standard sets of unit tests to your tables that are created based on such types).  Until such a time as this becomes reality, here are some workarounds. (Of course, you will have to do some work to propagate extended properties from tables/table types that you inherit from.)&lt;br/&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;1. Create Table based on another table&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SELECT top 0 * INTO mynewtable from mytable&lt;br /&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;2. Create Temporary Table based on another table&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SELECT top 0 * INTO #mynewtable from mytable&lt;br /&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;3. Create Table based on table type&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;DECLARE @mytable MyTableType&lt;br /&gt;SELECT TOP 0 * INTO mynewtable FROM @mytable&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-6879250839819060629?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/6879250839819060629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=6879250839819060629' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/6879250839819060629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/6879250839819060629'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2008/03/sql20052008-create-table-based-on-user.html' title='SQL2008 - Create Table Based on User-Defined Table Type'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-1398874755287206405</id><published>2008-03-20T23:13:00.003+11:00</published><updated>2008-03-20T23:19:58.104+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataSet Xml Schemas Excel'/><title type='text'>DataSets, Xml Schemas, and Excel - Oh My!</title><content type='html'>I have created another article on code project detailing the transformation power of the dataset.  It isn't just for getting data from the database.  You can find it &lt;a href="http://www.codeproject.com/KB/cs/DataSetMagic.aspx"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-1398874755287206405?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/1398874755287206405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=1398874755287206405' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/1398874755287206405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/1398874755287206405'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2008/03/datasets-xml-schemas-and-excel-oh-my.html' title='DataSets, Xml Schemas, and Excel - Oh My!'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-4710130128158462587</id><published>2008-03-14T00:32:00.002+11:00</published><updated>2008-03-14T00:38:16.312+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML Render Internet Explorer .NET WebBrowser'/><title type='text'>Xml String Browser</title><content type='html'>I created my first web article.  The title was "XML String Browser (just like Internet Explorer) using WebBrowser Control".  You can find this article on Code Project by clicking on the following link.  It was great fun to do and I hope to write a few more articles.  I was motivated to do this because the .NET Web Browser control does not support pretty rendering of XML strings or XML Documents (unless you are viewing XML files). &lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.codeproject.com/KB/cs/XMLBrowser.aspx"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-4710130128158462587?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/4710130128158462587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=4710130128158462587' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/4710130128158462587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/4710130128158462587'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2008/03/xml-string-browser.html' title='Xml String Browser'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-6543099930673152657</id><published>2008-03-06T19:11:00.003+11:00</published><updated>2008-12-11T05:58:11.433+11:00</updated><title type='text'>Execute cmd/bat from VS2005</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/_RZXjVl05I5o/R8-oHx15LgI/AAAAAAAAABc/jgkCRist8G0/s1600-h/garbage.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5174539348463922690" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://2.bp.blogspot.com/_RZXjVl05I5o/R8-oHx15LgI/AAAAAAAAABc/jgkCRist8G0/s320/garbage.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_RZXjVl05I5o/R8-ndh15LfI/AAAAAAAAABU/1TK3uro03LY/s1600-h/garbage.jpg"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I haven't blogged for a while. Unfortunately, I have been really busy. Here is a helpful tip that I discovered a while ago .... It is an incredibly handy one&lt;a href="http://4.bp.blogspot.com/_RZXjVl05I5o/R89dSR15LeI/AAAAAAAAABI/yrrfZ3UfggI/s1600-h/deleteme.bmp"&gt; &lt;/a&gt;. &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;1. First, you need to go to Tools-&gt;External Tools in the Visual Studio IDE. &lt;/div&gt;&lt;div&gt;2. Then, add a new one with the settings depicted in the picture below. &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;I would be interested to know if people find this one as useful as I have. I have been using it for a number of purposes (including executing various Nant scripts). &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Also, An important note - you have to Customize the context menu before you can use the Execute Command External Tool.  This is done by:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;1. Clicking on Tools-&gt;Customize and select Context Menu.  &lt;/div&gt;&lt;div&gt;2. Drag and drop the External Tool to the Project Items -&gt; Project Item context menu.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-6543099930673152657?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/6543099930673152657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=6543099930673152657' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/6543099930673152657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/6543099930673152657'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2008/03/execute-cmdbat-from-vs2005_06.html' title='Execute cmd/bat from VS2005'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_RZXjVl05I5o/R8-oHx15LgI/AAAAAAAAABc/jgkCRist8G0/s72-c/garbage.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-3679837110970430563</id><published>2007-01-12T20:38:00.000+11:00</published><updated>2007-01-15T19:38:10.384+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Multi-line regular expression'/><title type='text'>More on Regular Expression patterns</title><content type='html'>Regular expression patterns are powerful. I have been recently using Log4Net to log system activity and created a regular expression similar to the one below to allow multi-line text log parsing.&lt;br /&gt;&lt;br /&gt;Sample Text:&lt;br /&gt;&lt;br /&gt;2007-01-01 00:00:00 Test log message&lt;br /&gt;Another line&lt;br /&gt;Yet one more line&lt;br /&gt;2002-01-01 00:01:01 Another test log message&lt;br /&gt;&lt;br /&gt;Regular Expression Pattern:&lt;br /&gt;&lt;br /&gt;^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})[ ]*((?:(?!\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*(?:(?!\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*\n?)*))&lt;br /&gt;&lt;br /&gt;The above regular expression pattern will capture Date and parse the LogText where the additional lines don't begin with the Date.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-3679837110970430563?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/3679837110970430563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=3679837110970430563' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/3679837110970430563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/3679837110970430563'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2007/01/more-on-regular-expression-patterns.html' title='More on Regular Expression patterns'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-2856917260528560540</id><published>2007-01-02T21:58:00.000+11:00</published><updated>2007-01-02T22:15:02.667+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Regular Expression selective replace'/><title type='text'>Happy New Year!</title><content type='html'>It is a New Year.  It is a time to look ahead and time to look behind. Back to a favorite topic of mine. Regular expressions. Today I discovered a cool way to do selective search and replace on a substring. Take the following example:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Sample Text:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;i before e, except after c&lt;br /&gt;Man very early made jars stand up! Nearly perfect&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Regular Expression Pattern&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;(?&lt;=^[^,!]*)e&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Regular Expression Replace String&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;E&lt;br /&gt;&lt;br /&gt;Use a tool like &lt;a href="http://www.ultrapico.com/"&gt;Expresso&lt;/a&gt; to work with regular expressions. Other free tools are &lt;a href="http://www.radsoftware.com.au/regexdesigner/"&gt;RegEx Designer&lt;/a&gt; or &lt;a href="http://sourceforge.net/projects/regulator/"&gt;The Regulator&lt;/a&gt;. The result you will get when you run the replace with the above Regular Expression is as follows:&lt;br /&gt;&lt;br /&gt;i bEforE E, except after c&lt;br /&gt;Man vEry Early madE jars stand up! Nearly perfect&lt;br /&gt;&lt;br /&gt;Notice the selective replacement of &lt;em&gt;e&lt;/em&gt; with a capital &lt;em&gt;E&lt;/em&gt;. How does this work? Take a look at the analysis for the above regular expression pattern:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;Match a prefix but exclude it from the capture. [^[^,!]*]&lt;br /&gt;^[^,!]*&lt;br /&gt;Beginning of line or string&lt;br /&gt;Any character that is not in this class: [,!], any number of repetitions&lt;br /&gt;e&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What this effectively does is look behind any letter e in a string that is not preceded by a , or !.  In effect, that allows us to limit the replacement to all occurrences of e that occur &lt;em&gt;before&lt;/em&gt; a , or !.   Pretty cool, no?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-2856917260528560540?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/2856917260528560540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=2856917260528560540' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2856917260528560540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2856917260528560540'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2007/01/happy-new-year.html' title='Happy New Year!'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-519443630722518310</id><published>2006-12-14T20:33:00.000+11:00</published><updated>2006-12-14T21:08:45.954+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Character Analysis ASCII count'/><title type='text'>SQL Character Analysis</title><content type='html'>I love working with a development team.  The great thing about it is you can tell other people about the cool things you figure out and how silly you are when you do something wrong. (As a rule, I like to take the blame for everything. Hey, it happens sometimes that things break because of me!) Also you can complain about unexpected "features" using different technologies or approaches.&lt;br /&gt;&lt;br /&gt;I wrote the following bit of SQL script for a problem that was brought to my attention by a friend a while ago.  It involved a string that had some unprintable characters that were causing the string to be difficult to parse.  The following SQL generates a random string of 8000 characters (with character codes between 1 and 255) (for use within this example) and it also rips apart the random string to tell you the character composition of the string - by ascii code, character, and frequency of the character within the string (count).&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #596 1px solid; PADDING-RIGHT: 15px; BORDER-TOP: #596 1px solid; DISPLAY: block; PADDING-LEFT: 15px; PADDING-BOTTOM: 5px; MARGIN: 0.75em 0px; FONT: x-small Verdana, Arial, Sans-serif; OVERFLOW: scroll; BORDER-LEFT: #596 1px solid; WIDTH: 100%; PADDING-TOP: 5px; BORDER-BOTTOM: #596 1px solid; POSITION: relative; HEIGHT: 500px;background-color:white;" &gt;&lt;br /&gt;&lt;font color="#008000"&gt;&lt;font face="Courier New"&gt;&lt;span style="font-size:10pt"&gt;/*&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008000"&gt;COPYRIGHT &amp;copy; 2006 George Zabanah&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008000"&gt;Please feel free to use this code and distribute, &lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008000"&gt;but leave this header at the top.&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008000"&gt;No warranty of any kind is implied by using this code. &lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008000"&gt;Use at your own risk.&lt;br&gt;&lt;br /&gt;*/&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;DECLARE &lt;font color="#000000"&gt;@RandomNumber&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;float&lt;br&gt;&lt;br /&gt;DECLARE &lt;font color="#000000"&gt;@MaxValue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;int&lt;br&gt;&lt;br /&gt;DECLARE &lt;font color="#000000"&gt;@MinValue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;int&lt;br&gt;&lt;br /&gt;DECLARE &lt;font color="#000000"&gt;@RandomString&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;varchar&lt;font color="#000000"&gt;(8000)&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;DECLARE &lt;font color="#000000"&gt;@StringLength&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;int&lt;br&gt;&lt;br /&gt;DECLARE &lt;font color="#000000"&gt;@count&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;int&lt;br&gt;&lt;br /&gt;DECLARE &lt;font color="#000000"&gt;@singlechar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;char&lt;font color="#000000"&gt;(1)&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008000"&gt;-- SET INITIAL VARIABLES&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;SELECT &lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@MaxValue = 255,&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@StringLength = 8000,&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@MinValue = 1,&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@count = 1,&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@RandomString = &lt;font color="#800000"&gt;''&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008000"&gt;-- GENERATE A RANDOM STRING THAT IS 8000 CHARACTERS&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;WHILE&lt;font color="#000000"&gt;(@count &amp;lt;= @StringLength)&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;SELECT &lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@RandomNumber&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;= &lt;font color="#0000ff"&gt;RAND&lt;font color="#000000"&gt;(),&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@RandomString&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;= @randomstring + &lt;font color="#0000ff"&gt;CHAR&lt;font color="#000000"&gt;(((@MaxValue + 1) - @MinValue) * @RandomNumber + @MinValue),&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@count&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;= @count + 1&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;END&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;DECLARE &lt;font color="#000000"&gt;@tablevar &lt;font color="#0000ff"&gt;TABLE &lt;font color="#000000"&gt;(onechar &lt;font color="#0000ff"&gt;char&lt;font color="#000000"&gt;(1))&lt;br&gt;&lt;br /&gt;&lt;font color="#008000"&gt;-- DECONSTRUCT THE STRING INTO SINGLE CHARACTERS AND INSERT INTO A TABLE VARIABLE&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;SET &lt;font color="#000000"&gt;@count = 1&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;WHILE&lt;font color="#000000"&gt;(@count &amp;lt;= @StringLength)&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;SELECT&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@singlechar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;= &lt;font color="#0000ff"&gt;LEFT&lt;font color="#000000"&gt;(@RandomString,1),&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@RandomString&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;= &lt;font color="#0000ff"&gt;RIGHT&lt;font color="#000000"&gt;(@RandomString,&lt;font color="#0000ff"&gt;LEN&lt;font color="#000000"&gt;(@RandomString) - 1),&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;@count&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;= @count + 1&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;SET NOCOUNT ON&lt;br&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;INSERT &lt;font color="#000000"&gt;@tablevar &lt;font color="#0000ff"&gt;values&lt;font color="#000000"&gt;(@singlechar)&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;font color="#0000ff"&gt;SET NOCOUNT OFF&lt;br&gt;&lt;br /&gt;END&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008000"&gt;-- RETURN THE RESULT SET OF CHARACTER ANALYSIS&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;SELECT ASCII&lt;font color="#000000"&gt;(onechar) AsciiCode, onechar SingleCharacter, &lt;font color="#0000ff"&gt;count&lt;font color="#000000"&gt;(*) CharacterCount&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;FROM &lt;font color="#000000"&gt;@tablevar&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;GROUP BY ASCII&lt;font color="#000000"&gt;(onechar),onechar&lt;br&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;ORDER BY ASCII&lt;font color="#000000"&gt;(onechar),onechar&lt;font color="#0000ff"&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-519443630722518310?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/519443630722518310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=519443630722518310' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/519443630722518310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/519443630722518310'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2006/12/sql-character-analysis.html' title='SQL Character Analysis'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-7803889981986424520</id><published>2006-12-13T22:36:00.004+11:00</published><updated>2008-03-07T19:43:39.096+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Xml Comparison Excel'/><title type='text'>Xml Compare and Excel Routines</title><content type='html'>A few days ago I mentioned the Xml Compare and Excel Routines that I use for testing. I'm posting them here ... they are quite handy routines. Both are written in C#.&lt;br /&gt;&lt;br /&gt;Xml Compare:&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #596 1px solid; PADDING-RIGHT: 15px; BORDER-TOP: #596 1px solid; DISPLAY: block; PADDING-LEFT: 15px; PADDING-BOTTOM: 5px; MARGIN: 0.75em 0px; FONT: x-small Verdana, Arial, Sans-serif; OVERFLOW: scroll; BORDER-LEFT: #596 1px solid; WIDTH: 100%; PADDING-TOP: 5px; BORDER-BOTTOM: #596 1px solid; POSITION: relative; HEIGHT: 500px;background-color:white;" &gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10;"&gt;/*&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;COPYRIGHT © 2006 George Zabanah&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;Please feel free to use this code and distribute,&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;but leave this header at the top.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;No warranty of any kind is implied by using this code.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;Use at your own risk.&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10;"&gt;&lt;span style="color:#808080;"&gt;///&lt;span style="color:#008000;"&gt; &lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#808080;"&gt;///&lt;span style="color:#008000;"&gt; Displays the difference between two xml strings&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#808080;"&gt;///&lt;span style="color:#008000;"&gt; &lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#808080;"&gt;///&lt;span style="color:#008000;"&gt; &lt;span style="color:#808080;"&gt;&amp;lt;param name="expected"&amp;gt;&lt;span style="color:#008000;"&gt;expected result&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#808080;"&gt;///&lt;span style="color:#008000;"&gt; &lt;span style="color:#808080;"&gt;&amp;lt;param name="actual"&amp;gt;&lt;span style="color:#008000;"&gt;actual result&lt;span style="color:#808080;"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;void&lt;span style="color:#000000;"&gt; XmlCompare(&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt; expected,&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt; actual)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;XmlDocument xExpected = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; XmlDocument();&lt;br /&gt;&lt;br /&gt;xExpected.LoadXml(expected);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;XmlDocument xActual = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; XmlDocument();&lt;br /&gt;&lt;br /&gt;xActual.LoadXml(actual);&lt;br /&gt;&lt;br /&gt;System.Xml.XPath.XPathNavigator xeNav = xExpected.CreateNavigator();&lt;br /&gt;&lt;br /&gt;System.Xml.XPath.XPathNavigator xaNav = xActual.CreateNavigator();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;// Move to the first non-comment element.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;xeNav.MoveToChild(System.Xml.XPath.XPathNodeType.Element);&lt;br /&gt;&lt;br /&gt;xaNav.MoveToChild(System.Xml.XPath.XPathNodeType.Element);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;System.Xml.XPath.XPathNodeIterator xeNodeIterator = xeNav.SelectDescendants(System.Xml.XPath.XPathNodeType.Element,&lt;span style="color:#0000ff;"&gt;true&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;System.Xml.XPath.XPathNodeIterator xaNodeIterator = xaNav.SelectDescendants(System.Xml.XPath.XPathNodeType.Element,&lt;span style="color:#0000ff;"&gt;true&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt;.Empty.PadLeft(80, &lt;span style="color:#800000;"&gt;'='&lt;span style="color:#000000;"&gt;));&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#800000;"&gt;"XML COMPARISON"&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt;.Empty.PadLeft(80, &lt;span style="color:#800000;"&gt;'='&lt;span style="color:#000000;"&gt;));&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;while&lt;span style="color:#000000;"&gt; (xeNodeIterator.MoveNext() &amp;amp;&amp;amp; xaNodeIterator.MoveNext())&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;span style="color:#000000;"&gt; (xeNodeIterator.Current.Name != xaNodeIterator.Current.Name)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#800000;"&gt;"Actual Node Name: {0} Expected Node Name: {1}"&lt;span style="color:#000000;"&gt;, xaNodeIterator.Current.Name, xeNodeIterator.Current.Name);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;// return;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;span style="color:#000000;"&gt; ((xeNodeIterator.Current.Value == xeNodeIterator.Current.InnerXml xaNodeIterator.Current.Value == xaNodeIterator.Current.InnerXml) &amp;amp;&amp;amp; xeNodeIterator.Current.Value != xaNodeIterator.Current.Value)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#008080;"&gt;String&lt;span style="color:#000000;"&gt;.Empty.PadLeft(80, &lt;span style="color:#800000;"&gt;'-'&lt;span style="color:#000000;"&gt;));&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#800000;"&gt;"Actual Node \t{0}: {1} \r\nExpected Node \t{2}: {3}"&lt;span style="color:#000000;"&gt;, xaNodeIterator.Current.Name,xaNodeIterator.Current.Value, xeNodeIterator.Current.Name,xeNodeIterator.Current.Value);&lt;br /&gt;&lt;br /&gt;TestContext.WriteLine(&lt;span style="color:#008080;"&gt;String&lt;span style="color:#000000;"&gt;.Empty.PadLeft(80, &lt;span style="color:#800000;"&gt;'-'&lt;span style="color:#000000;"&gt;));&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:MS Shell Dlg 2;"&gt;&lt;span style="font-size:8;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Excel Routines:&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #596 1px solid; PADDING-RIGHT: 15px; BORDER-TOP: #596 1px solid; DISPLAY: block; PADDING-LEFT: 15px; PADDING-BOTTOM: 5px; MARGIN: 0.75em 0px; FONT: x-small Verdana, Arial, Sans-serif; OVERFLOW: scroll; BORDER-LEFT: #596 1px solid; WIDTH: 100%; PADDING-TOP: 5px; BORDER-BOTTOM: #596 1px solid; POSITION: relative; HEIGHT: 500px;background-color:white;" &gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10;"&gt;/*&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;COPYRIGHT © 2006 George Zabanah&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;Please feel free to use this code and distribute,&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;but leave this header at the top.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;No warranty of any kind is implied by using this code.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;   &lt;span style="color:#008000;"&gt;Use at your own risk.&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;static&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;class&lt;span style="color:#000000;"&gt; ExcelFunctions&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;static&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;void&lt;span style="color:#000000;"&gt; WriteToExcel(DataSet ds, &lt;span style="color:#008080;"&gt;String&lt;span style="color:#000000;"&gt; MyFileName, &lt;span style="color:#0000ff;"&gt;bool&lt;span style="color:#000000;"&gt; Append)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt; connect3 = &lt;span style="color:#800000;"&gt;"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\""&lt;span style="color:#000000;"&gt; + MyFileName + &lt;span style="color:#800000;"&gt;"\";User ID=Admin;Password=;Extended Properties=\"Excel 8.0;HDR=YES\";"&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;OleDbConnection _to = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; OleDbConnection(connect3);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;bool&lt;span style="color:#000000;"&gt; blnFileExists = &lt;span style="color:#008080;"&gt;File&lt;span style="color:#000000;"&gt;.Exists(MyFileName);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;span style="color:#000000;"&gt; (blnFileExists &amp;amp;&amp;amp; !Append) &lt;span style="color:#008080;"&gt;File&lt;span style="color:#000000;"&gt;.Delete(MyFileName);&lt;br /&gt;&lt;br /&gt;_to.Open();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;foreach&lt;span style="color:#000000;"&gt; (DataTable dt &lt;span style="color:#0000ff;"&gt;in&lt;span style="color:#000000;"&gt; ds.Tables)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;span style="color:#000000;"&gt; (!Append !blnFileExists)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008080;"&gt;String&lt;span style="color:#000000;"&gt; table = &lt;span style="color:#800000;"&gt;"CREATE TABLE "&lt;span style="color:#000000;"&gt; + dt.TableName + &lt;span style="color:#800000;"&gt;" ("&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;foreach&lt;span style="color:#000000;"&gt; (DataColumn dc &lt;span style="color:#0000ff;"&gt;in&lt;span style="color:#000000;"&gt; ds.Tables[dt.TableName].Columns)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008080;"&gt;String&lt;span style="color:#000000;"&gt; typename = &lt;span style="color:#800000;"&gt;" ["&lt;span style="color:#000000;"&gt; + dc.ColumnName + &lt;span style="color:#800000;"&gt;"] "&lt;span style="color:#000000;"&gt; + (dc.DataType.ToString() == &lt;span style="color:#800000;"&gt;"System.Int64"&lt;span style="color:#000000;"&gt; dc.DataType.ToString() == &lt;span style="color:#800000;"&gt;"System.Double"&lt;span style="color:#000000;"&gt; dc.DataType.ToString() == &lt;span style="color:#800000;"&gt;"System.Int32"&lt;span style="color:#000000;"&gt; ? &lt;span style="color:#800000;"&gt;"NUMERIC"&lt;span style="color:#000000;"&gt; : &lt;span style="color:#800000;"&gt;"TEXT"&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;table += typename + (dc == ds.Tables[dt.TableName].Columns[ds.Tables[dt.TableName].Columns.Count - 1] ? &lt;span style="color:#800000;"&gt;")"&lt;span style="color:#000000;"&gt; : &lt;span style="color:#800000;"&gt;","&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OleDbCommand cmd = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; OleDbCommand(table, _to);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;try&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;{&lt;br /&gt;&lt;br /&gt;cmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;catch&lt;span style="color:#000000;"&gt; (&lt;span style="color:#008080;"&gt;Exception&lt;span style="color:#000000;"&gt; e)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;_to.Close();&lt;br /&gt;&lt;br /&gt;_to.Dispose();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008080;"&gt;Console&lt;span style="color:#000000;"&gt;.Error.WriteLine(e.Message);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008080;"&gt;Console&lt;span style="color:#000000;"&gt;.Error.WriteLine(e.StackTrace);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;return&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OleDbDataAdapter daTo = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; OleDbDataAdapter(&lt;span style="color:#800000;"&gt;"select * from ["&lt;span style="color:#000000;"&gt; + dt.TableName + &lt;span style="color:#800000;"&gt;"$]"&lt;span style="color:#000000;"&gt;, _to);&lt;br /&gt;&lt;br /&gt;OleDbCommandBuilder x = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; OleDbCommandBuilder(daTo);&lt;br /&gt;&lt;br /&gt;x.QuotePrefix = &lt;span style="color:#800000;"&gt;"["&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;x.QuoteSuffix = &lt;span style="color:#800000;"&gt;"]"&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;daTo.InsertCommand = x.GetInsertCommand();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;try&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;{&lt;br /&gt;&lt;br /&gt;daTo.Update(ds, dt.TableName);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;catch&lt;span style="color:#000000;"&gt; (&lt;span style="color:#008080;"&gt;Exception&lt;span style="color:#000000;"&gt; e)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008080;"&gt;Console&lt;span style="color:#000000;"&gt;.Error.WriteLine(e.Message);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008080;"&gt;Console&lt;span style="color:#000000;"&gt;.Error.WriteLine(e.StackTrace);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;_to.Close();&lt;br /&gt;&lt;br /&gt;_to.Dispose();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;static&lt;span style="color:#000000;"&gt; DataSet ReadFromExcel(&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt; MyFileName)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;string&lt;span style="color:#000000;"&gt; connect3 = &lt;span style="color:#800000;"&gt;"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\""&lt;span style="color:#000000;"&gt; + MyFileName + &lt;span style="color:#800000;"&gt;"\";User ID=Admin;Password=;Extended Properties=\"Excel 8.0;HDR=YES\";"&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;OleDbConnection _to = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; OleDbConnection(connect3);&lt;br /&gt;&lt;br /&gt;DataSet ds = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; DataSet();&lt;br /&gt;&lt;br /&gt;_to.Open();&lt;br /&gt;&lt;br /&gt;DataTable schemaTable = _to.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; &lt;span style="color:#0000ff;"&gt;object&lt;span style="color:#000000;"&gt;[] { &lt;span style="color:#0000ff;"&gt;null&lt;span style="color:#000000;"&gt;, &lt;span style="color:#0000ff;"&gt;null&lt;span style="color:#000000;"&gt;, &lt;span style="color:#0000ff;"&gt;null&lt;span style="color:#000000;"&gt;, &lt;span style="color:#800000;"&gt;"TABLE"&lt;span style="color:#000000;"&gt; });&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;foreach&lt;span style="color:#000000;"&gt; (DataRow dr &lt;span style="color:#0000ff;"&gt;in&lt;span style="color:#000000;"&gt; schemaTable.Rows)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;OleDbDataAdapter daTo = &lt;span style="color:#0000ff;"&gt;new&lt;span style="color:#000000;"&gt; OleDbDataAdapter(dr[&lt;span style="color:#800000;"&gt;"TABLE_NAME"&lt;span style="color:#000000;"&gt;].ToString(), _to);&lt;br /&gt;&lt;br /&gt;daTo.SelectCommand.CommandType = CommandType.TableDirect;&lt;br /&gt;&lt;br /&gt;daTo.AcceptChangesDuringFill = &lt;span style="color:#0000ff;"&gt;false&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;span style="color:#000000;"&gt; (dr[&lt;span style="color:#800000;"&gt;"TABLE_NAME"&lt;span style="color:#000000;"&gt;].ToString().IndexOf(&lt;span style="color:#800000;"&gt;"$"&lt;span style="color:#000000;"&gt;) == dr[&lt;span style="color:#800000;"&gt;"TABLE_NAME"&lt;span style="color:#000000;"&gt;].ToString().Length - 1)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;daTo.Fill(ds, dr[&lt;span style="color:#800000;"&gt;"TABLE_NAME"&lt;span style="color:#000000;"&gt;].ToString());&lt;br /&gt;&lt;br /&gt;ds.Tables[dr[&lt;span style="color:#800000;"&gt;"TABLE_NAME"&lt;span style="color:#000000;"&gt;].ToString()].TableName = dr[&lt;span style="color:#800000;"&gt;"TABLE_NAME"&lt;span style="color:#000000;"&gt;].ToString().Replace(&lt;span style="color:#800000;"&gt;"$"&lt;span style="color:#000000;"&gt;, &lt;span style="color:#800000;"&gt;""&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;_to.Close();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;return&lt;span style="color:#000000;"&gt; ds;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Also, I have used this handy little utility to generate the HTML (from the code) by doing the following.&lt;br /&gt;&lt;br /&gt;1) Install RTF to HTML utility found &lt;a href="http://www.ireksoftware.com/RTFtoHTML/dload.html"&gt;here&lt;/a&gt; (freeware).&lt;br /&gt;2) Open the code in VS2005.&lt;br /&gt;3) Run the RTFtoHTML utility. Convert to HTML and post in your blog.&lt;br /&gt;&lt;br /&gt;I'd be interested to know if someone has a better way of doing this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-7803889981986424520?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/7803889981986424520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=7803889981986424520' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/7803889981986424520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/7803889981986424520'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2006/12/xml-compare-and-excel-routines.html' title='Xml Compare and Excel Routines'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-8709499502149371469</id><published>2006-12-11T21:35:00.000+11:00</published><updated>2006-12-11T21:41:45.833+11:00</updated><title type='text'>The Ingredients of Good Manager/Developer relationships</title><content type='html'>&lt;p&gt;Take a look at this fantastic &lt;a href="http://www.softwarebyrob.com/archive/2006/12/06/Open_Letter_to_Software_Managers_of_the_World_.aspx"&gt;letter&lt;/a&gt;. In my travels, I've encountered a number of&lt;br /&gt;managers who have broken these rules more often than not. The managers that are&lt;br /&gt;excellent are the ones I still keep in touch with. They live by the "ingredients" I outline below.&lt;br /&gt;&lt;br /&gt;A manager's role is to foster the following characteristics within the working environment, thereby building "cohesive leadership and participation" between team members. The first step for a manager to achieve this is by solidifying the manager/developer relationship. A team member's role is to show commitment as an active participant within the team.&lt;br /&gt;&lt;br /&gt;The following is my brief list of essential ingredients for healthy developer/manager&lt;br /&gt;relationships:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;have open two-way communication &lt;/li&gt;&lt;li&gt;have/give trust &lt;/li&gt;&lt;li&gt;show integrity and have mutual respect &lt;/li&gt;&lt;li&gt;have constant reality checks and remove unrealistic expectations &lt;/li&gt;&lt;li&gt;encourage participation in healthy discussions/debates - "the best idea wins" &lt;/li&gt;&lt;li&gt;praise in public/adjust behaviours in private &lt;/li&gt;&lt;li&gt;show sincerity and empathy &lt;/li&gt;&lt;li&gt;be approachable and considerate of other people's contributions&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Although these points seem surprisingly simple -- they can only be put into effective practice&lt;br /&gt;by people who live these values in their everyday lives. In order to make your team&lt;br /&gt;follow you and want to follow you (as well as replicate your behaviour) -&lt;br /&gt;a manager must live out these values and lead by example.&lt;br /&gt;&lt;br /&gt;Also, a manager who believes that he/she is better than everyone else (or even just has an ego/disposition to suggest this) is worse than a team member who believes the same - a manager should be smart enough to know better. Most people can tell a good manager from a bad one.&lt;br /&gt;&lt;br /&gt;A manager's responsiblity is to help remove obstacles from the people around them (by managing downwards to team members, sideways to colleagues, and upwards to upper management). &lt;/p&gt;&lt;p&gt;Contrary to what some people may say, employee turnover isn't always&lt;br /&gt;due to restructuring, "grass is greener syndrome", or a fact of life. Employee turnover&lt;br /&gt;can be a telltale sign of poor management/IT planning. Poor management/IT planning is&lt;br /&gt;a definite result of ignoring the ingredients of good developer/manager relationships.&lt;br /&gt;&lt;br /&gt;If you have read this far - take a look at the &lt;a href="http://www.softwarebyrob.com/archive/2006/12/06/Open_Letter_to_Software_Managers_of_the_World_.aspx"&gt;letter&lt;/a&gt; now. It is definitely a good read.&lt;br /&gt;&lt;br /&gt;My thanks to the good managers out there.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-8709499502149371469?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/8709499502149371469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=8709499502149371469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/8709499502149371469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/8709499502149371469'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2006/12/ingredients-of-good-managerdeveloper.html' title='The Ingredients of Good Manager/Developer relationships'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-3845623913748491301</id><published>2006-12-09T13:30:00.003+11:00</published><updated>2008-03-18T14:51:57.080+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql rowcount analysis table view'/><title type='text'>One of my favourite SQL Routines</title><content type='html'>Looking through a few of the sql routines I wrote within the past year, I dug this one up because I want to write a version which works with Oracle. The following bit of code will go through all view/tables within the current database. It will report in one table the following combination:&lt;br /&gt;&lt;br /&gt;TableName&lt;br /&gt;ColumnName&lt;br /&gt;TotalRowCount&lt;br /&gt;DistinctCount&lt;br /&gt;NullCount&lt;br /&gt;&lt;br /&gt;The only limitation this script has is the limitation on dynamic sql (8000 characters). I get around this a little bit by using temporary procedures. I have avoided using cursors to keep it simple and efficient.&lt;br /&gt;&lt;br /&gt;&lt;div style="BORDER-RIGHT: #596 1px solid; PADDING-RIGHT: 15px; BORDER-TOP: #596 1px solid; DISPLAY: block; PADDING-LEFT: 15px; PADDING-BOTTOM: 5px; MARGIN: 0.75em 0px; FONT: x-small Verdana, Arial, Sans-serif; OVERFLOW: scroll; BORDER-LEFT: #596 1px solid; WIDTH: 100%; PADDING-TOP: 5px; BORDER-BOTTOM: #596 1px solid; POSITION: relative; HEIGHT: 500px;color:white;background-color:white;" &gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="font-size:10;"&gt;/*&lt;br /&gt;&lt;br /&gt;   ANALYZE TABLES/VIEWS in current database by rowcount, distinct count&lt;br /&gt;&lt;br /&gt;   and null count.&lt;br /&gt;&lt;br /&gt;   August 8, 2006 Initial Version&lt;br /&gt;&lt;br /&gt;   COPYRIGHT © 2006 George Zabanah&lt;br /&gt;&lt;br /&gt;   Please feel free to use this code and distribute,&lt;br /&gt;&lt;br /&gt;   but leave this header at the top.&lt;br /&gt;&lt;br /&gt;   No warranty of any kind is implied by using this code.&lt;br /&gt;&lt;br /&gt;   Use at your own risk.&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;-- Table to hold column information&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;CREATE TABLE &lt;span style="color:#000000;"&gt;#ColumnData (TableName &lt;span style="color:#0000ff;"&gt;sysname&lt;span style="color:#000000;"&gt;,&lt;br /&gt;&lt;br /&gt;ColumnName &lt;span style="color:#0000ff;"&gt;sysname&lt;span style="color:#000000;"&gt;,&lt;br /&gt;&lt;br /&gt;TOTALROWS bigint,&lt;br /&gt;&lt;br /&gt;DistinctCount bigint,&lt;br /&gt;&lt;br /&gt;NullCount bigint)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;-- Temp procedure for a particular table, column combination&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;CREATE PROCEDURE &lt;span style="color:#000000;"&gt;#C (@TableName &lt;span style="color:#0000ff;"&gt;sysname&lt;span style="color:#000000;"&gt;, @ColumnName &lt;span style="color:#0000ff;"&gt;sysname&lt;span style="color:#000000;"&gt;, @CastVarchar &lt;span style="color:#0000ff;"&gt;bit &lt;span style="color:#000000;"&gt;= 0)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;AS&lt;br /&gt;&lt;br /&gt;declare &lt;span style="color:#000000;"&gt;@mysql &lt;span style="color:#0000ff;"&gt;varchar&lt;span style="color:#000000;"&gt;(4000)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;set &lt;span style="color:#000000;"&gt;@mysql = &lt;span style="color:#800000;"&gt;'insert #ColumnData select ''' &lt;span style="color:#000000;"&gt;+ @TableName + &lt;span style="color:#800000;"&gt;''' TABLENAME, ''' &lt;span style="color:#000000;"&gt;+&lt;br /&gt;&lt;br /&gt;@COLUMNNAME + &lt;span style="color:#800000;"&gt;''' COLUMNNAME, COUNT(*) TOTALROWS, ' &lt;span style="color:#000000;"&gt;+&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#800000;"&gt;'COUNT(DISTINCT(' &lt;span style="color:#000000;"&gt;+ (&lt;span style="color:#0000ff;"&gt;CASE WHEN &lt;span style="color:#000000;"&gt;@CastVarchar = 1 &lt;span style="color:#0000ff;"&gt;then &lt;span style="color:#800000;"&gt;'CAST(' &lt;span style="color:#0000ff;"&gt;else &lt;span style="color:#800000;"&gt;'' &lt;span style="color:#0000ff;"&gt;end&lt;span style="color:#000000;"&gt;) +&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#800000;"&gt;'[' &lt;span style="color:#000000;"&gt;+ @COLUMNNAME + &lt;span style="color:#800000;"&gt;']' &lt;span style="color:#000000;"&gt;+&lt;br /&gt;&lt;br /&gt;(&lt;span style="color:#0000ff;"&gt;CASE WHEN &lt;span style="color:#000000;"&gt;@CastVarchar = 1 &lt;span style="color:#0000ff;"&gt;then &lt;span style="color:#800000;"&gt;' as varchar(8000))' &lt;span style="color:#0000ff;"&gt;else &lt;span style="color:#800000;"&gt;'' &lt;span style="color:#0000ff;"&gt;end&lt;span style="color:#000000;"&gt;) +&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#800000;"&gt;')) DISTINCTCOUNT, SUM(CASE WHEN [' &lt;span style="color:#000000;"&gt;+&lt;br /&gt;&lt;br /&gt;@COLUMNNAME + &lt;span style="color:#800000;"&gt;'] is NULL THEN 1 ELSE 0 END) NULLCOUNT from [' &lt;span style="color:#000000;"&gt;+ @TableName + &lt;span style="color:#800000;"&gt;']'&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;RAISERROR&lt;span style="color:#000000;"&gt;(&lt;span style="color:#800000;"&gt;'%s.%s'&lt;span style="color:#000000;"&gt;,10,1,@TableName,@ColumnName) &lt;span style="color:#0000ff;"&gt;WITH NOWAIT&lt;br /&gt;&lt;br /&gt;exec&lt;span style="color:#000000;"&gt;(@mysql)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;-- Temp procedure for a particular table&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;CREATE PROCEDURE &lt;span style="color:#000000;"&gt;#T (@TableName &lt;span style="color:#0000ff;"&gt;sysname&lt;span style="color:#000000;"&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;AS&lt;br /&gt;&lt;br /&gt;declare &lt;span style="color:#000000;"&gt;@mysql &lt;span style="color:#0000ff;"&gt;varchar&lt;span style="color:#000000;"&gt;(4000)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;set &lt;span style="color:#000000;"&gt;@mysql = &lt;span style="color:#800000;"&gt;'declare @t varchar(8000) set @t = ''' &lt;span style="color:#000000;"&gt;+ @TableName + &lt;span style="color:#800000;"&gt;''''&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;select &lt;span style="color:#000000;"&gt;@mysql = @mysql &lt;span style="color:#0000ff;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT + &lt;span style="color:#800000;"&gt;' exec #C @t,''' &lt;span style="color:#000000;"&gt;+ COLUMN_NAME + &lt;span style="color:#800000;"&gt;'''' &lt;span style="color:#000000;"&gt;+&lt;br /&gt;&lt;br /&gt;(&lt;span style="color:#0000ff;"&gt;CASE WHEN &lt;span style="color:#000000;"&gt;DATA_TYPE &lt;span style="color:#0000ff;"&gt;like &lt;span style="color:#800000;"&gt;'%Text' &lt;span style="color:#0000ff;"&gt;then &lt;span style="color:#800000;"&gt;',1' &lt;span style="color:#0000ff;"&gt;else &lt;span style="color:#800000;"&gt;'' &lt;span style="color:#0000ff;"&gt;end&lt;span style="color:#000000;"&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;from &lt;span style="color:#000000;"&gt;information_schema.columns &lt;span style="color:#0000ff;"&gt;where &lt;span style="color:#000000;"&gt;table_name = @TableName&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;RAISERROR&lt;span style="color:#000000;"&gt;(&lt;span style="color:#800000;"&gt;'-- TABLE: %s --'&lt;span style="color:#000000;"&gt;,10,1,@TableName) &lt;span style="color:#0000ff;"&gt;WITH NOWAIT&lt;br /&gt;&lt;br /&gt;exec&lt;span style="color:#000000;"&gt;(&lt;span style="color:#800000;"&gt;'SET NOCOUNT ON ' &lt;span style="color:#000000;"&gt;+ @mysql + &lt;span style="color:#800000;"&gt;' SET NOCOUNT OFF'&lt;span style="color:#000000;"&gt;)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;Declare &lt;span style="color:#000000;"&gt;@mysql &lt;span style="color:#0000ff;"&gt;varchar&lt;span style="color:#000000;"&gt;(4000)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;-- TABLES&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;set &lt;span style="color:#000000;"&gt;@mysql = &lt;span style="color:#800000;"&gt;''&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;select &lt;span style="color:#000000;"&gt;@mysql = @mysql + &lt;span style="color:#800000;"&gt;' exec #T ''' &lt;span style="color:#000000;"&gt;+ table_name + &lt;span style="color:#800000;"&gt;''''&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;from &lt;span style="color:#000000;"&gt;information_schema.tables &lt;span style="color:#0000ff;"&gt;where &lt;span style="color:#000000;"&gt;table_type = &lt;span style="color:#800000;"&gt;'BASE TABLE'&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;exec&lt;span style="color:#000000;"&gt;(@mysql)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#008000;"&gt;-- VIEWS&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;set &lt;span style="color:#000000;"&gt;@mysql = &lt;span style="color:#800000;"&gt;''&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;select &lt;span style="color:#000000;"&gt;@mysql = @mysql + &lt;span style="color:#800000;"&gt;' exec #T ''' &lt;span style="color:#000000;"&gt;+ table_name + &lt;span style="color:#800000;"&gt;''''&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;from &lt;span style="color:#000000;"&gt;information_schema.tables &lt;span style="color:#0000ff;"&gt;where &lt;span style="color:#000000;"&gt;table_type = &lt;span style="color:#800000;"&gt;'VIEW'&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;exec&lt;span style="color:#000000;"&gt;(@mysql)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;select &lt;span style="color:#000000;"&gt;* &lt;span style="color:#0000ff;"&gt;from &lt;span style="color:#000000;"&gt;#ColumnData&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;drop table &lt;span style="color:#000000;"&gt;#ColumnData&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;drop procedure &lt;span style="color:#000000;"&gt;#T&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;drop procedure &lt;span style="color:#000000;"&gt;#C&lt;span style="font-family:MS Shell Dlg 2;"&gt;&lt;span style="font-size:8;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;A few noteworthy points:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;the #T temporary procedure iterates through each table/view and the #C temporary procedure iterates through the columns of each table/view.&lt;/li&gt;&lt;li&gt;I use the simple set-based variable assignment in SQL to concatenate one big dynamic SQL statement for each table/view.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Like I said before, this script is one of my favourites.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-3845623913748491301?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/3845623913748491301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=3845623913748491301' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/3845623913748491301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/3845623913748491301'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2006/12/one-of-my-favorite-sql-routines.html' title='One of my favourite SQL Routines'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-2220675753763703607</id><published>2006-12-09T10:53:00.000+11:00</published><updated>2006-12-09T11:43:22.292+11:00</updated><title type='text'>More on Test Driven Development</title><content type='html'>My last post really didnt finish on what TDD means to me.  True, I mentioned automated testing which is a useful part of TDD.  But bcwhite (thanks for the comment) mentioned the distinction of writing your tests up front vs automating your tests.  I do write some of my tests up front ... but you can't always write all of them.  I find myself adding more tests as requirements change (or as I think of them). &lt;br /&gt;&lt;br /&gt;TDD means writing your code while being mindful of the need to test it.  You write your code to expose properties or return values that can help you test.  This way you can simulate Input in/Output out and check whether an Exception occurred yes/no, etc. &lt;br /&gt;&lt;br /&gt;Also, for your "composite" functions which have connections to units that you don't want to test, (i.e. a component which communicates with a singleton object that you don't need/don't want to test, or a component which uses threading or sockets) you factor your code in such a way that you can test your "units" in isolation of everything else.  If you can't easily separate out your unit from everything else, you expose a boolean property called "TestMode" and only set this during automated testing.  For each line of code in your unit that you don't want to test during unit testing, you check this boolean first i.e.&lt;br /&gt;&lt;br /&gt;If (not TestMode)&lt;br /&gt;PassObjectToSingletonQueue&lt;br /&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;If(not TestMode)&lt;br /&gt;PassDataToOpenSocket&lt;br /&gt;&lt;br /&gt;The candidate function I mention above is a component which does have inputs/outputs and exceptions thrown but also communicates with a singleton object that passes data to and from an open socket connection.  In this case, I want to test the inputs and outputs and exceptions (&lt;em&gt;without &lt;/em&gt;communicating with the singleton object).&lt;br /&gt;&lt;br /&gt;This makes it much easier to have as much of your code unit tested as possible.  Anything beyond a unit no longer becomes unit testing.  Thinking this way makes it easier for you to test your code and helps guard your code against the likelihood that changes in requirements will yield undesirable results.  In the case where your some or all of your unit tests fail, you know then and there that you have some work to do.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-2220675753763703607?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/2220675753763703607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=2220675753763703607' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2220675753763703607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2220675753763703607'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2006/12/more-on-test-driven-development.html' title='More on Test Driven Development'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7799903173670515239.post-2994626910154964635</id><published>2006-12-08T23:02:00.000+11:00</published><updated>2006-12-08T23:29:07.059+11:00</updated><title type='text'>Test Driven Development</title><content type='html'>My first blog ... time to dive in.  Here goes.&lt;br /&gt;&lt;br /&gt;Automated Unit testing has saved me many times over.  For the time you spend, versus the time you save it is a solid investment.  Whether you use nunit or Visual Studio Team Framework - it is up to you.  But it is well worth the time up front.  How many times do you think - oh the requirements won't change (or if they change it won't be that difficult to keep track of or fix my code).  For example ... take the case when you are comparing lines upon lines of xml output.   Or even worse, let's say you have to use fairly complex (1000+ characters) regular expressions to match multi-delimiter delimited data and use that to generate xml. A few lines of code ... and you save heaps of time ...   I have written a very simple function (called XmlCompare) that uses XPathNodeIterator to perform the following Xml Walkthrough of Expected and Actual:&lt;br /&gt;&lt;br /&gt;1) Expected Node Name vs. Actual Node Name&lt;br /&gt;2) Expected Node Value vs. Actual Node Value&lt;br /&gt;3) Expected Self-Closing Empty Node vs. Actual Empty Node&lt;br /&gt;4) Expected Empty Node vs. Actual Self-Closing Empty Node&lt;br /&gt;&lt;br /&gt;It's worked exceptionally well.  In addition, I've written a function to split my very long (necessarily so) and complex regular expressions so that I can tell if the regular expression is matching the data properly.&lt;br /&gt;&lt;br /&gt;Combine this with a function that uses OleDbConnection object using Jet4.0 to read test data from Excel into a dataset and you have a beautiful thing.  By iterating through the rows in the dataset (I have a spreadsheet for each function I want to test and each spreadsheet has quite a few variations of test data), I can test each of the functions I have with multiple variations (literally at the click of a button).&lt;br /&gt;&lt;br /&gt;Developers are such optimistic creatures ... with test driven development, developers can have a reason for optimism.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7799903173670515239-2994626910154964635?l=netthread.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://netthread.blogspot.com/feeds/2994626910154964635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7799903173670515239&amp;postID=2994626910154964635' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2994626910154964635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7799903173670515239/posts/default/2994626910154964635'/><link rel='alternate' type='text/html' href='http://netthread.blogspot.com/2006/12/test-driven-development.html' title='Test Driven Development'/><author><name>George Zabanah</name><uri>http://www.blogger.com/profile/06553562610174003682</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
