473,749 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DTS from excel file (excel filename is different everyday)

17 New Member
Good Day to all,

Hope you could help me w/ my project.
Im creating a DTS Package. The source data will be coming from an excel file going to my SQL table. The DTS package is scheduled to execute daily, but the source data will be coming from different excel filename.
Example, today the DTS will get data from Data092506.xls. Then tomorrow, the data will be coming from Data092606.xls.
How can I do this? The DTS I've already done has a fixed source data file.
Please help.
Thank you so much.
God Bless.
Sep 25 '06 #1
9 14161
spykhov
5 New Member
Interesting question!
I have the similar problem - how to run SQL Server package (I'm in 2005 version) with the source file as a variable to be set up at runtime.
I've spent 3 days to find the solution, but there is no any progress.
Sep 25 '06 #2
LimaCharlie
17 New Member
Hi,

I also joined another forum and asked the same question.
Here's the answer of one of the members there...

"You will need to create a variable in your DTS package for the file name, and then construct the filename dynamically."

But I can't seem to figure out on how to do this. I asked for more specifics and waiting now for the reply.
Sep 26 '06 #3
spykhov
5 New Member
In my SSIS package I created a variable with the name "PathFile" of string type with path and file name and in the ConnectionStrin g of the SourceConnectio nFlatFile properties I overighted the full path and name by @[PathFile] link to the variable.
It doesn't work - packeg do not accept ConnectionStrin g as variable.
Sep 26 '06 #4
spykhov
5 New Member
Good news!

I resolved my problem! I've found out the solution in the next article
http://www.databasejou rnal.com/features/mssql/article.php/3509601

The code I used for:

Declare @Filename varchar(1000)
Declare @cmd varchar(1000)
Select @Filename = 'O:\Plan2005\Da taWarehouse\Exc el Queries\'
Select @Filename = @Filename + 'report2.txt'
select @cmd = 'dtexec /Reporting E /SQL Package1 /SET \Package.Connec tions[SourceConnectio nFlatFile].Properties[ConnectionStrin g];"' + @Filename + '"'
exec master..xp_cmds hell @cmd

Changing @FileName variable in run time will change the source file.

Good luck everybody!
Sep 26 '06 #5
LimaCharlie
17 New Member
Hi spykhov,
Is this solution applicable to MS SQL Server 2000 as well? I'm still using the 2000 version.
Oct 3 '06 #6
LimaCharlie
17 New Member
Hi,
I can't seem to get it yet. I am presented w/ so many information from all the websites and help files that I am reading, and I end up more confused. :-(
I'm a newbie in SQL and I need instructions for dummies. =)

I already created a global variable. How can I referenced the value of that global variable to my task?

Here's what I did.
1.) I drag a "Execute SQL Task" to the DTS Designer.
2.) I created a global variable that would hold the FIleName of the excel file I will call upon DTS Package Execution.
3.) I drag "MS Excel 2000" to the DTS Designer and selected a sample excel file.
4.) I drag the "SQL Server" connection to the DTS Designer and selected the database I'm working with.
5.) I connected the 2 connection by using the "Transform Data Task".

Question: How can I reference the global variable so that it would be the excel ource file upon DTS.

Please help.
Oct 3 '06 #7
LimaCharlie
17 New Member
Hi,

I got it already!
Here's what I did:
1.) I created a global variable
2.) I add an ActiveX Script Task wherein I assign a value to the global variable
3.) I add a Dynamic Property Task wherein I assign the datasource to the global variable
4.) Then I placed a workflow.

Now, I have another question:
How can I import data from 24 excel files everyday. Excel filenames are like these:

100206_AAA
100206_BBB
100206_CCC
up to
100206_XXX

wherein 100206 is a date which I already knew how to alter for everyday DTS package execution. The last 3 characters are the branch code, in which we have 24 branches (ex. 100206_AAA, 100206_BBB,...1 00206_XXX).
How can I make a loop, so I can run the DTS package 24 times. Each run will get data from each excel files.

Here's how my ActiveX Script looks like:

'************** *************** *************** *************** ***********
' Visual Basic ActiveX Script
'************** *************** *************** *************** ***********

Option Explicit

Function Main()
Dim vDay, vMonth, vYear, vDate

vDay=RIGHT(RTRI M("0" & DAY(DATE()-2)),2)
vMonth=RIGHT(RT RIM("0" & MONTH(DATE()-2)),2)
vYear=RIGHT(YEA R(DATE()-2),2)
vDate=vMonth & vDay & vYear

DTSGlobalVariab les("gVarPath") .Value=vDate & "_AAA.xls"

Main = DTSTaskExecResu lt_Success
End Function
Thank you so much... :)
God Bless.
Oct 3 '06 #8
modjoe23
1 New Member
Hi,

If you found a solution to your problem...pleas e post!

Thanks.

Hi,

I got it already!
Here's what I did:
1.) I created a global variable
2.) I add an ActiveX Script Task wherein I assign a value to the global variable
3.) I add a Dynamic Property Task wherein I assign the datasource to the global variable
4.) Then I placed a workflow.

Now, I have another question:
How can I import data from 24 excel files everyday. Excel filenames are like these:

100206_AAA
100206_BBB
100206_CCC
up to
100206_XXX

wherein 100206 is a date which I already knew how to alter for everyday DTS package execution. The last 3 characters are the branch code, in which we have 24 branches (ex. 100206_AAA, 100206_BBB,...1 00206_XXX).
How can I make a loop, so I can run the DTS package 24 times. Each run will get data from each excel files.

Here's how my ActiveX Script looks like:


Thank you so much... :)
God Bless.
Jan 23 '07 #9
Bartek Juszczak
1 New Member
And why not create BAT file with where you can copy/rename input files and then execute it by Execute Process Task?

By that you can get always the same name of input...

Bartek
Jan 16 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

13
35559
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
0
2821
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and then save the data into a client machine (Intranet) as excel page using the excel component (using Excel = Microsoft.Office.Interop.Excel;) in the code. Please help me. I have wasted so many days on this.
4
2501
by: Lewis Edward Moten III | last post by:
I have a file that users can download through a web page protected by forms authentication: Download.aspx?ID=45 and within that file ... FileInfo fileToDownload = new FileInfo(fileName);
2
3123
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this, dataset.writexml works great (got the code from http://forums.devx.com/archive/index.php/t-57273.html ) The only question I have is, when Excel opens up, it isn't the view I would prefer. It opens as a read-only workbook, I would prefer as an
0
3944
by: =?Utf-8?B?Tml5YXpp?= | last post by:
Hi all, Does anyone know how to embed the Excel file in VB.NET 2005 Resources? Here is what I am doing at the moment: 1) In my VB.NET 2005 project code I load the excel with it path into string as: ------------------------------------------------------------------------------------------------ Dim fileNameXL As String = "_MYEXCEL_REPORTS.XLS" Dim pathNameXL As String = "\EXCEL_TEMP\"
0
5736
Boxcar74
by: Boxcar74 | last post by:
Hi Everybody!!! I have an Issue. I have an Excel file that queries an Access db. I’m trying to have it so I don’t have to keep updating it manually everyday and save it to a network drive with the file name coming from a cell reference and the current date. What I’ve done have the Excel file open via a Batch file and on “Workbook_Open” I run a few macro to refresh the data then remake and save it to the network drive. My...
7
2090
by: Raymond Chiu | last post by:
Dear all, I have written the following code in the button click event but find that excel session object always remain in the server as seen from taskmanager. Do you know why? ------------------------------------------------------------------------------ Dim objExcel As New Microsoft.Office.Interop.Excel.Application Dim objSheet As Microsoft.Office.Interop.Excel.Worksheet objExcel.Workbooks.Open(Page.MapPath("reports\Cost.xls"))
7
12071
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
6
26327
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this one table. My problem is I have two buttons I want to use this code for for the two buttons would put the data in different tables. I have tried copying and changing a few things and nothing will work for me. The code is set up in a module and then I...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.