CFMX and SQL Server Data Transformation Services (Part One of Two) |
|---|
So you have a bunch of data that you need to migrate from one source to another and preserve the integrity of your data, or you need to import delimited data from a third party that is in the form of "LARGE" flat file(s) without bringing your server to a halt. Well... the answer is Data Transformation Services. If you have not worked with Data Transformation Service yet, I recommend taking a look into, or wait, why don't I just show you. So what we are going to do today is use coldFusion to generate some data for our text file and then we are going to use coldFusion & DTS to import that data from the text file into SQL Server.Requirments: » coldFusion MX » SQL Server 2000
|
| coldFusion |
| application.cfm |
| <cfapplication name="cfmxDTSApp"> <!--- If the application
is not "Initialized", Initialize it ---> |
| template.cfm |
| <cfswitch expression="#thistag.executionmode#"> <cfcase
value="start"> <table align="center" width="100%" border="0"
cellspacing="0" cellpadding="0"> <cfcase value="end"> |
| index.cfm |
<cfmodule template="template.cfm"> <!--- Defualt page to be dislayed ---> <!--- Evaluate what page is being called ---> <!--- Display home page ---> <!--- Display dts packages page ---> </cfmodule> |
| dsp_home.cfm |
| <cfscript> // Make an array of dummy browsers to give us some random data. browsers = arrayNew(1); // v 1.0 browsers[1] = 'Internet Explorer 1.0'; browsers[2] = 'Netscape 1.0'; browsers[3] = 'Opera 1.0'; browsers[4] = 'googleRobot 1.0'; browsers[5] = 'msnRobot 1.0'; browsers[6] = 'yahooRobot 1.0'; // v 2.0 browsers[7] = 'Internet Explorer 2.0'; browsers[8] = 'Netscape 2.0'; browsers[9] = 'Opera 2.0'; browsers[10] = 'googleRobot 2.0'; browsers[11] = 'msnRobot 2.0'; browsers[12] = 'yahooRobot 2.0'; // v 3.0 browsers[13] = 'Internet Explorer 3.0'; browsers[14] = 'Netscape 3.0'; browsers[15] = 'Opera 3.0'; browsers[16] = 'googleRobot 3.0'; browsers[17] = 'msnRobot 3.0'; browsers[18] = 'yahooRobot 3.0'; // Get our current directory. cfmxDTSPath = ExpandPath("*.*"); cfmxDTSDirectory = GetDirectoryFromPath(cfmxDTSPath); </cfscript> <!--- If form is submited.... ---> <!--- If the file doesn't exists, create it. ---> <!--- Generate 1000 lines of dummy data. ---> <!--- Append our dummy data to the browserLog.txt. ---> <!--- Just because I hate that annoying refresh alert. ---> <br> |
| dsp_runDTS.cfm |
<cfif isDefined("form.submit")> <!---// the next line is only required if using the Windows Authorization
//--->
</cfif> <br> |
| dsp_stats.cfm |
| <!--- Execute spGetStats ---> <cfquery name="qStats" datasource="#Application.Config.DSN#"> exec spGetStats </cfquery> <cfoutput> |