<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-20897630</atom:id><lastBuildDate>Thu, 24 Oct 2024 16:03:46 +0000</lastBuildDate><category>SQL DTS ActiveX</category><category>SQL Server</category><category>DTS</category><category>DTS ActiveX SQL Server Oracle</category><title>Datura - Coding with Rudy</title><description>Where Rudy jots down code tid-bits he has found useful.</description><link>http://codedatura.blogspot.com/</link><managingEditor>noreply@blogger.com (Rudy)</managingEditor><generator>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-3811810358094771237</guid><pubDate>Wed, 20 Jan 2010 22:38:00 +0000</pubDate><atom:updated>2010-01-20T14:46:40.732-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL DTS ActiveX</category><title>Move a file with ActiveX in DTS</title><description>Once you process a file, you will usually archive it. Often, you may run into cases where the file already exists in the archive directory. Unfortunately, the Move command does not have an overwrite option. You will need to use the Copy command with the Overwrite option.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Function&lt;/span&gt; Main()&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; oFSO&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; vSourceFile&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; vDestinationFile&lt;br /&gt;&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; oFSO = CreateObject(&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;Scripting.FileSystemObject&quot;&lt;/span&gt;)&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; objFSO = CreateObject(&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;Scripting.FileSystemObject&quot;&lt;/span&gt;)&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Const&lt;/span&gt; OverwriteExisting = &lt;span style=&quot;color:#000099;&quot;&gt;True&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Const&lt;/span&gt; DeleteReadOnly = &lt;span style=&quot;color:#000099;&quot;&gt;True&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     vSourceFile = &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;\\MySourceDirectory\*.csv&quot;&lt;/span&gt;&lt;br /&gt;     vDestinationFile = &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;\\MyDestinationDirectory\&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span style=&quot;color:#33ff33;&quot;&gt;&#39; Move the files Use OverwriteExisting in case the file is there &lt;/span&gt;&lt;br /&gt;     objFSO.CopyFile vSourceFile, vDestinationFile, OverwriteExisting&lt;br /&gt;&lt;br /&gt;     &lt;span style=&quot;color:#33cc00;&quot;&gt;&#39; Delete the files in the source directory&lt;/span&gt;&lt;br /&gt;     objFSO.DeleteFile(vSourceFile ) , DeleteReadOnly&lt;br /&gt;&lt;br /&gt;     &lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; oFSO = Nothing&lt;br /&gt;&lt;br /&gt;     Main = DTSTaskExecResult_Success &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End Function&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;Now, all of the files in the source directory are now in the archive.</description><link>http://codedatura.blogspot.com/2010/01/move-file-with-activex-in-dts.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-2971334428171399109</guid><pubDate>Wed, 20 Jan 2010 22:24:00 +0000</pubDate><atom:updated>2010-01-20T14:33:32.429-08:00</atom:updated><title>Grab the filename for a file in a Folder</title><description>&lt;p&gt;You will probably come across a file that is formatted like this&lt;/p&gt;&lt;p&gt;filename_20100101235938.csv&lt;/p&gt;&lt;p&gt;where we are dealing with the full timestamp in the name. As long as the file is the only file in the directory, we can use the script below:&lt;/p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Function&lt;/span&gt; Main()&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; objFSO =&lt;br /&gt;CreateObject(&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;Scripting.FileSystemObject&quot;&lt;/span&gt;)&lt;br /&gt;objStartFolder = &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;&lt;/span&gt;&lt;a href=&quot;file://drivename/FolderName/&quot;&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;\\DriveName\FolderName\&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; objFolder = objFSO.GetFolder(objStartFolder)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; colFiles = objFolder.Files&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;For Each&lt;/span&gt; objFile &lt;span style=&quot;color:#000099;&quot;&gt;in&lt;/span&gt; colFiles&lt;br /&gt;     DTSGlobalVariables (&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;gv_FileName&quot;&lt;/span&gt;).Value =&lt;br /&gt;objStartFolder &amp;amp; objFile.Name&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Next&lt;/span&gt;&lt;br /&gt;Main = DTSTaskExecResult_Success&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End Function&lt;/span&gt;&lt;/span&gt; &lt;/blockquote&gt;&lt;p&gt;&lt;/span&gt;You now have the full path and filename in the global variable. Now, if there are multiple files in the directory, you will have the last file name in the global variable. &lt;/p&gt;</description><link>http://codedatura.blogspot.com/2010/01/grab-filename-for-file-in-folder.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-747749098225196585</guid><pubDate>Fri, 04 Dec 2009 23:01:00 +0000</pubDate><atom:updated>2010-01-20T14:37:12.504-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL DTS ActiveX</category><title>Loop through files in a folder Use ActiveX</title><description>&lt;p&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;There are times when you need to process all files in a folder. SSIS gives us the While loop that can parse all files in a folder. However DTS requires a work around with ActiveX and the trusty FileSystemObject. Here is some code that parses through all the files in a folder and pops up a message box with the file name.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#33cc00;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&#39;**********************************************************************&lt;br /&gt;&#39; Visual Basic ActiveX Script&lt;br /&gt;&#39;**********************************************************************&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Function&lt;/span&gt; Main()&lt;br /&gt;&lt;br /&gt;      &lt;span style=&quot;color:#33cc00;&quot;&gt;&#39;Set the target folder name&lt;/span&gt;&lt;br /&gt;      folder = &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;\\MyDrive\Myfolder\&quot;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;      &lt;span style=&quot;color:#000099;&quot;&gt;set&lt;/span&gt; fso = CreateObject(&lt;span style=&quot;color:#cc0000;&quot;&gt;&quot;Scripting.fileSystemObject&quot;&lt;/span&gt;)&lt;br /&gt;      &lt;span style=&quot;color:#000099;&quot;&gt;set&lt;/span&gt; fold = fso.getFolder(folder)&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color:#33ff33;&quot;&gt;&#39; Loop through the files in the folder&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;      &lt;span style=&quot;color:#000099;&quot;&gt;for each&lt;/span&gt; file &lt;span style=&quot;color:#000099;&quot;&gt;in&lt;/span&gt; fold.files&lt;br /&gt;&lt;br /&gt;            &lt;span style=&quot;color:#33cc00;&quot;&gt;&#39; Pop up a Message Box with the file name&lt;/span&gt;&lt;br /&gt;            MsgBox( file.name)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color:#33ff33;&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;            &#39; You can also set global variables with this option&lt;br /&gt;            &#39;set DTSGlobalVariables(&quot;gv_FileName&quot;).Value = file.name&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;      &lt;span style=&quot;color:#000099;&quot;&gt;next&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style=&quot;color:#000099;&quot;&gt;set&lt;/span&gt; fold = nothing&lt;br /&gt;      &lt;span style=&quot;color:#000099;&quot;&gt;set&lt;/span&gt; fso = nothing&lt;br /&gt;&lt;br /&gt;      Main = DTSTaskExecResult_Success&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End Function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Thats it! This script is also handy for files that don&#39;t have a predefined name, such as filenames that contain a timestamp (ie Filename_YYYYMMDDHHMMSS.csv)&lt;/span&gt;&lt;/p&gt;</description><link>http://codedatura.blogspot.com/2009/12/loop-through-files-in-folder-use.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-7581109539238937772</guid><pubDate>Fri, 10 Jul 2009 20:24:00 +0000</pubDate><atom:updated>2009-07-10T13:38:20.772-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DTS ActiveX SQL Server Oracle</category><title>Using parameters in Oracle Queries via DTS</title><description>&lt;p&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;My latest adventure had me working with Oracle and SQL Server databases. The task required setting global variables in SQL DTS, then using those global variables in the Data Pump. However, it seems that the Oracle ODBC connection did not like me using the standard parameter formatting:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#333399;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; COL1, COL2, COL3 &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; ORACLEDB.TABLE &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;where &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;COL4 = &lt;/span&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;As we all know, when you throw in a &lt;span style=&quot;color:#3333ff;&quot;&gt;?&lt;/span&gt; into a query, you pick the parameter at design time. But, no matter what I did, the task would not accept the parameter. It wouldn&#39;t even let me pick a parameter from the list, so I knew that I had to go about it a different way. As always, the trusty ActiveX task fit the bill. Here is a script to dynamically change the Query in a Data Pump:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; Main()&lt;br /&gt; &lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; oPkg, oDataPump, sSQLStatement&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#33cc00;&quot;&gt; &#39; Build new SQL Statement&lt;/span&gt;&lt;br /&gt; sSQLStatement = &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;SELECT COL1, COL2, COL3&quot;&lt;/span&gt; &amp;amp;_&lt;br /&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot; FROM ORACLEDB.TABLE where COL4 = &#39;&quot;&lt;/span&gt; &amp;amp; DTSGlobalVariables(&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;gv_Variable&quot;&lt;/span&gt;).Value &amp;amp; &lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;&#39;&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#33cc00;&quot;&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt; &#39; Get reference to the DataPump Task&lt;br /&gt; &#39; This is for the first datapump. Change as needed&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt; Set &lt;/span&gt;oPkg = DTSGlobalVariables.Parent&lt;br /&gt; &lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; oDataPump = oPkg.Tasks(&lt;span style=&quot;color:#ff0000;&quot;&gt;&quot;DTSTask_DTSDataPumpTask_1&quot;&lt;/span&gt;).CustomTask&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#33cc00;&quot;&gt; &#39; Assign SQL Statement to Source of DataPump&lt;/span&gt;&lt;br /&gt; oDataPump.SourceSQLStatement = sSQLStatement&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#33cc00;&quot;&gt; &#39; Clean Up&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; oDataPump = &lt;span style=&quot;color:#000099;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color:#000099;&quot;&gt;Set&lt;/span&gt; oPkg = &lt;span style=&quot;color:#000099;&quot;&gt;Nothing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Main = DTSTaskExecResult_Success&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End Function&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;br /&gt;Now, the query text will include all of the previous text and the parameter.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;</description><link>http://codedatura.blogspot.com/2009/07/using-parameters-in-oracle-queries-via.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-9001786346788280819</guid><pubDate>Thu, 21 May 2009 19:33:00 +0000</pubDate><atom:updated>2009-05-21T12:40:56.243-07:00</atom:updated><title>CTEs and SQL Server</title><description>&lt;p&gt;Thanks to the guys at TechRepublic.com I have used CTEs to delete duplicates with ease in SQL Server 2005 and higher. &lt;a href=&quot;http://blogs.techrepublic.com.com/datacenter/?p=420&quot;&gt;Here is the link&lt;/a&gt;. Here meat of the article a sample:&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;;WITH SalesCTE(Product, SaleDate, SalePrice, Ranking)&lt;br /&gt;AS&lt;br /&gt;(&lt;br /&gt;SELECT&lt;br /&gt; Product, SaleDate, SalePrice,&lt;br /&gt;Ranking = DENSE_RANK() OVER(PARTITION BY Product, SaleDate, SalePrice ORDER BY NEWID() ASC)&lt;br /&gt;FROM SalesHistory&lt;br /&gt;)&lt;br /&gt;DELETE FROM SalesCTE&lt;br /&gt;WHERE Ranking &gt; 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Very easy and handy!&lt;/p&gt;</description><link>http://codedatura.blogspot.com/2009/05/ctes-and-sql-server.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-3778704871023054764</guid><pubDate>Mon, 29 Dec 2008 21:10:00 +0000</pubDate><atom:updated>2008-12-29T13:17:13.708-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DTS</category><category domain="http://www.blogger.com/atom/ns#">SQL DTS ActiveX</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>Using ActiveX to check the age of a file</title><description>&lt;span style=&quot;font-family:verdana;&quot;&gt;Sometimes you need to check the age of a file before proceeding. You really don&#39;t want to work with old data, so this is how you can do this in the middle of an ActiveX task.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;Option Explicit&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;Function Main()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;    Dim&lt;/span&gt; oFSO, oConn, sFileName, oFile&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Get the filename from my Text File connection called &quot;Text File (Source)&quot;&lt;br /&gt;  &#39; There are other ways to do this, of course.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    Set oConn = DTSGlobalVariables.Parent.Connections(&lt;span style=&quot;color: rgb(153, 153, 153);&quot;&gt;&quot;Text File (Source)&quot;&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    sFilename = oConn.DataSource&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Set&lt;/span&gt; oConn = Nothing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Set&lt;/span&gt; oFSO = CreateObject(&lt;span style=&quot;color: rgb(153, 153, 153);&quot;&gt;&quot;Scripting.FileSystemObject&quot;&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Check File Exists first&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;If Not&lt;/span&gt; oFSO.FileExists(sFilename) Then&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Return Error&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        Main = DTSTaskExecResult_Failure&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Get file object&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Set&lt;/span&gt; oFile = oFSO.GetFile(sFilename)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Check age of file is less than 24 hours&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;If&lt;/span&gt; DateDiff(&lt;span style=&quot;color: rgb(153, 153, 153);&quot;&gt;&quot;h&quot;&lt;/span&gt;, oFile.DateLastModified, Now) &gt;= 24 Then&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Return Error&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            Main = DTSTaskExecResult_Failure&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            &lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39; Return Success&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            Main = DTSTaskExecResult_Success    &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;End If        &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;    End If&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Set&lt;/span&gt; oFile = Nothing&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Set&lt;/span&gt; oFSO = Nothing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;End Function&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;color: rgb(51, 51, 255);font-family:courier new;&quot; &gt;&lt;/span&gt;&lt;/span&gt;</description><link>http://codedatura.blogspot.com/2008/12/using-activex-to-check-age-of-file.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-367157065302727339</guid><pubDate>Mon, 18 Feb 2008 21:53:00 +0000</pubDate><atom:updated>2008-02-18T14:05:26.356-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">DTS</category><category domain="http://www.blogger.com/atom/ns#">SQL DTS ActiveX</category><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>Using ActiveX to Dynamically set a filename</title><description>&lt;p style=&quot;font-family: verdana;&quot; class=&quot;MsoNormal&quot;&gt;From time to time, you will need to dynamically set a filename in the middle of your DTS packages. The following code shows you how easy it is to build a filename dynamically:&lt;/p&gt;  &lt;p style=&quot;font-family: verdana;&quot; class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39;*************************&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39;    Sets the file name to the format: MyFile_YYYYMMDD.csv&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&#39;*************************&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Function&lt;/span&gt; Main()&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Dim&lt;/span&gt; oPkg, oBulkExport&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;&#39;Set the Path where the file is located&lt;/span&gt;&lt;br /&gt;    strPath = &quot;c:\MyPath\&quot;   &lt;br /&gt;   &lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;Next build the different parts of the file name,&lt;br /&gt;    &#39;including the prefix and &lt;/span&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;file extension using&lt;br /&gt;    &#39;the Now function, which returns the current date and&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;the Month(),Day(), and Year() function which&lt;br /&gt;    &#39;return the respective&lt;/span&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt; datepart.&lt;/span&gt;&lt;br /&gt;    strPrefix = &quot;&lt;span style=&quot;color: rgb(153, 153, 153);&quot;&gt;MyFile_&lt;/span&gt;&quot;&lt;br /&gt;    strMonth = Month(Now)&lt;br /&gt;    strDay = Day(Now)&lt;br /&gt;    strYear = Year(Now)&lt;br /&gt;    strFileExt = &quot;&lt;span style=&quot;color: rgb(153, 153, 153);&quot;&gt;.csv&lt;/span&gt;&quot;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;If you only require 2 digit years, trim the first 2 digits&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;strYear = Right(strYear, 2)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;If the day or month is a single digit, the&lt;br /&gt;    &#39;Now function will only return that single digit&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;We will append a leading zero to the Month&lt;br /&gt;    &#39;and/or Date string if needed&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;If&lt;/span&gt; Len(strMonth) = 1 &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Then&lt;/span&gt; strMonth = &quot;0&quot; &amp;amp; strMonth&lt;br /&gt;    &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;If&lt;/span&gt; Len(strDay) = 1 &lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;Then&lt;/span&gt; strDay = &quot;0&quot; &amp;amp; strDay&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;Concatenate all parts of the file name with&lt;br /&gt;    &#39;the file path in front.&lt;/span&gt;&lt;br /&gt;    outString = strPath &amp;amp; strPrefix &amp;amp; strYear &amp;amp; strMonth &amp;amp; strDay &amp;amp; strFileExt&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;Once the path and file name are determined,&lt;br /&gt;    &#39;set the global variable. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;    &#39;You will still need to set the file name&lt;br /&gt;    using a Dynamic Properties Task.&lt;/span&gt;&lt;br /&gt;    DTSGlobalVariables(&quot;&lt;span style=&quot;color: rgb(153, 153, 153);&quot;&gt;gv_FileName&lt;/span&gt;&quot;).Value = outString&lt;br /&gt;&lt;br /&gt;    Main = DTSTaskExecResult_Success&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;End&lt;/span&gt; Function&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;  &lt;p style=&quot;font-family: verdana;&quot; class=&quot;MsoNormal&quot;&gt;As stated in the code, you will still need a Dynamic Properties Task to actually set the file name, as you are only setting a global variable in the code.&lt;/p&gt;</description><link>http://codedatura.blogspot.com/2008/02/using-activex-to-dynamically-set.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-8844173633803621335</guid><pubDate>Thu, 05 Jul 2007 15:40:00 +0000</pubDate><atom:updated>2007-07-05T08:53:10.847-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL Server</category><title>ANSI warnings, NOCOUNT and Temp Tables</title><description>&lt;span style=&quot;font-family:verdana;&quot;&gt;So, I&#39;m always needing these code bits. And yet, I forget the exact syntax and I have to look all over the place for the exact code. Well, here it is. First, NOCOUNT. If you don&#39;t want SQL Server to return the Row Count after you execute a query, here is the code:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;SET&lt;/span&gt; NOCOUNT &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;ON&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Next, do you get annoying ANSI errors when inserting data? Begone!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;SET &lt;/span&gt;ANSI_WARNINGS&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt; OFF&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&lt;/span&gt;&lt;/span&gt;Lastly, when working with true temp tables, the ones starting with ## or #, the old standard will not work. This is because Temp tables live in the database TempDB, not your current DB. SO, sysobjects won&#39;t have the table info you&#39;re looking for.&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);font-family:courier new;&quot; &gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;color: rgb(51, 255, 51);font-family:courier new;&quot; &gt;-- Won&#39;t Work!&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;IF EXISTS &lt;/span&gt;(&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;SELECT * FROM&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;sysobjects&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;WHERE NAME=&lt;/span&gt;&#39;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;##tmpTable&lt;/span&gt;&#39;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);font-family:courier new;&quot; &gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Truncate table &lt;/span&gt;##tmpTable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;DROP TABLE &lt;/span&gt;##tmpTable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);font-family:courier new;&quot; &gt;END&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;color: rgb(0, 0, 153);font-family:courier new;&quot; &gt;&lt;/span&gt;You need this:&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 255, 51);font-family:courier new;&quot; &gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;color: rgb(51, 255, 51);font-family:courier new;&quot; &gt;--    THis will delete your temp table&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;IF&lt;/span&gt; &lt;span style=&quot;color: rgb(204, 102, 204);&quot;&gt;OBJECT_ID&lt;/span&gt;(&#39;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;tempdb..##tmpTable&lt;/span&gt;&#39;) IS NOT NULL &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;BEGIN  &lt;/span&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;Truncate table &lt;/span&gt;##tmpTable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;    &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;DROP TABLE&lt;/span&gt; ##tmpTable&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);font-family:courier new;&quot; &gt;END&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;color: rgb(0, 0, 153);font-family:courier new;&quot; &gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://codedatura.blogspot.com/2007/07/ansi-warnings-nocount-and-temp-tables.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-397795858269128212</guid><pubDate>Thu, 22 Feb 2007 23:27:00 +0000</pubDate><atom:updated>2007-02-22T15:35:42.095-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL DTS ActiveX</category><title>Change a Date Format Using ActiveX and DTS</title><description>&lt;span style=&quot;font-family:verdana;&quot;&gt;Lets say you are importing data via DTS and the date is in this format:&lt;br /&gt;YYYYMMDD&lt;br /&gt;So, SQL server isn&#39;t going to know what to do with this data. So, you&#39;re going to have to use ActiveX copy instead of the plain old Copy Column Task. Here is the code you would use in your ActiveX task within the Data Pump:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&#39;**************************************&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&#39;  Visual Basic Transformation Script&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&#39;**************************************&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;&#39;  Copy each source column to the destination column&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;Function Main()&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    DTSDestination(&quot;myDate&quot;) = left(DTSSource(&quot;badDate&quot;),4)+&quot;-&quot;&amp;amp;_&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    +mid(DTSSource(&quot;badDate&quot;),5,2)+&quot;-&quot;+right(DTSSource(&quot;badDate&quot;),2)&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    Main = DTSTransformStat_OK&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;End Function&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Substitute myDate for your destination and badDate for the source. This will give you a nice result in the YYYY-MM-DD format.&lt;br /&gt;&lt;br /&gt;You can also expand this technique to include times. You would have to use some two more &lt;span style=&quot;font-family:courier new;&quot;&gt;Mid&lt;/span&gt; to pull the date and hour, and the &lt;span style=&quot;font-family:courier new;&quot;&gt;right &lt;/span&gt;would pull the minutes.&lt;br /&gt;&lt;br /&gt;Happy Coding!&lt;br /&gt;&lt;/span&gt;</description><link>http://codedatura.blogspot.com/2007/02/change-date-format-using-activex-and.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-114736909026755265</guid><pubDate>Thu, 11 May 2006 17:29:00 +0000</pubDate><atom:updated>2006-05-11T10:38:10.283-07:00</atom:updated><title>Adding Foreign Keys after a table has been created</title><description>&lt;span style=&quot;font-family:verdana;&quot;&gt;Well, you knew exactly what you needed when you created a table. Only now when you created a child table, the child table does not update with the information from your main table. Or worse you deleted something from your primary table and it still lives in the child table. You need a foreign key, my friend. This is how you define one after you&#39;ve created your table.&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;ALTER TABLE My_Child_Table ADD CONSTRAINT&lt;/span&gt; &lt;span style=&quot;font-family:courier new;&quot;&gt;FK_User_ID&lt;br /&gt;FOREIGN KEY ( User_ID_In_Child_Table )&lt;br /&gt;&lt;/span&gt; &lt;span style=&quot;font-family:courier new;&quot;&gt;REFERENCES My_Primary_Table ( User_ID_In_Primary_Table ) &lt;/span&gt; &lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;br /&gt;ON DELETE CASCADE&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;ON UPDATE CASCADE&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/span&gt;The last two lines are important. In this example, if the user id in the primary table is modified or deleted, the change will cascade to the child table. This ensures consistency between the two tables.&lt;br /&gt;&lt;br /&gt;As always, this works on SQL Server. Check your documentation for mySql, Oracle, etc.&lt;br /&gt;&lt;/span&gt;</description><link>http://codedatura.blogspot.com/2006/05/adding-foreign-keys-after-table-has.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-114712318385766842</guid><pubDate>Mon, 08 May 2006 21:12:00 +0000</pubDate><atom:updated>2006-05-08T14:19:43.870-07:00</atom:updated><title>Converting Double to String with J#</title><description>&lt;span style=&quot;font-family: verdana;&quot;&gt;So, you made an awesome function that does cool things. Only the return type is a double and you have to display it as a string. No problem, you&#39;ll just have to convert it using this little snippet:&lt;br /&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;String &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;my_String_for_Display = new String();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;my_String_for_Display = Double.toString(my_Function());&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;This should would for C# as well, with minor modifications, but check the MSDN pages. This will also work for a double value instead of a function call, function with parameters, etc.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://codedatura.blogspot.com/2006/05/converting-double-to-string-with-j.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-20897630.post-113710253790587003</guid><pubDate>Thu, 12 Jan 2006 21:43:00 +0000</pubDate><atom:updated>2006-01-12T13:48:57.913-08:00</atom:updated><title>Adding Checks after a table has been created</title><description>&lt;span style=&quot;font-family: verdana;&quot;&gt;Did you create a table, only to find that you need to add a check constraint?&lt;br /&gt;It happened to me, and I hopped on google to find the code. In this example, we&#39;ll use my fictional User table. We want to know if our user is alive or dead. 1 = alive, 0 = dead. Here is the code for SQL server:&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;alter table dbo.Tbl_User_Table add constraint &lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;font-family: courier new;&quot;&gt;CK_User_Alive check (User_Alive  in (0,1))&lt;/span&gt;&lt;/blockquote&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;I don&#39;t know if it will work with MySql, Oracle, etc, so check your documentation. Happy Coding!&lt;/span&gt;&lt;span style=&quot;font-family: verdana;&quot;&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://codedatura.blogspot.com/2006/01/adding-checks-after-table-has-been.html</link><author>noreply@blogger.com (Rudy)</author><thr:total>0</thr:total></item></channel></rss>