Solved

Create DTS package with variables

Posted on 2004-08-17
12
257 Views
Last Modified: 2013-11-30
I would like to create a DTS package to export data from SQL database to a text file. The name of the text file will be the value of a text box the users enter on the a web page. When the users click submit button, it will take the value in the text box and run the stored procedure that executes the DTS package. The dealine for my project is coming very soon, please help. Thanks
0
Comment
Question by:CochiseCounty
  • 3
  • 2
  • 2
  • +1
12 Comments
 
LVL 7

Expert Comment

by:Lori99
ID: 11823870
You can do this by creating a global variable in your DTS package.  Open the package, go to Package Properties and you will see a Global Variables tab.  Give the variable a name, datatype and default value.  Add a Dynamic Properties task to your DTS package.  Right click on the task and go to Properties.  Click Add.  Expand Connections.. Text File.. OLE DB Properties.  Click on Data Source and then the Property Name.  Click Set.  For Source, choose Global Variable and then select the Global Variable name you set up.  Close all the windows.  

To use the Global Variable when you call the package, you must use the following format for the /A switch.

global variable name:data type identifier=value to use

For example:

dtsrun /NYourPackageName /AYourGlobalVariableName:8=c:\test\testfile.csv

The 8 is the data type identifier for a string.  The other data type identifiers are defined in the SQL Server Books Online under "dtsrun utility".
0
 

Author Comment

by:CochiseCounty
ID: 11824519
Hi Lori99, I am completely new in this subject....Would you please show me step by step how to add Dynamic Property to DTS package? I am using SQL 7.0. Thanks
0
 
LVL 7

Expert Comment

by:Lori99
ID: 11824735
Unfortunately, I don't believe the Dynamic Properties task exists in SQL 7.0 DTS.  I should have asked you before making the assumption you were on SQL 2000.  I don't have a SQL 7.0 installation available to figure out what you need to do and have only done this sort of thing on SQL 2000.  I imagine you would still set up the Global Variable with the file name and pass it to your package, but you will probably need to write some VB Script in the package to use the Global Variable to name your file.  Perhaps someone with experience in SQL 7.0 will be able to provide more information.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 10

Accepted Solution

by:
Jay Toops earned 125 total points
ID: 11824835
IF in fact you WANT to do this I would do the following

1) insert the name of the file into a queue table.
2) invoke the dts package.
3) once the dts package runs delete the entry from the queue table that was just produced.

this is a cumbersome way to do this.


I cant imagine you WANTING to do it though the
I assume you want to send this file to your user? ..

if so I would simply write the data back to the user along the HTTP stream
and change the content type of the stream to "application/ms-download" causing
the browser to pop up a "save as" dialog box.
which the user can then save.

Jay
0
 
LVL 34

Assisted Solution

by:arbert
arbert earned 125 total points
ID: 11825073
Personal opinion, if you're doing simple CSV dumps or extracts, I would look at using OSQL or BCP to do it and simply passing your filename as part of the dynamic SQL.  Especially if you're still running 7.0
0
 

Author Comment

by:CochiseCounty
ID: 11825238
I really don't know what I am doing. Let me tell you about my project to see if you can give me some clues...

From the search page, users will enter id and search criteria,
then I have to write those search criteria to the database,
the next step is that I have to export those search criteria to a text file called outbox,
this text file will be used by another program (not created by me) to run a search (from a database (not sql) from a diffrent server),
after searching, the result will be post to another text file called Inbox,
then I have to import this Inbox text file to the SQL database and then display it on the web site.

The web application is on web server called server1 (internet) and the text files must be on server2 (sqlserver, not web server)

I don't have any problem with submit, retreive data from SQL to the web site, the thing I am confusing is the export/import from/to text file. I am thinking of using the id that users enter for the file name, that is the only way for me to tell which Inbox file goes with which Outbox file.


Please tell me which way is the simplest way to work on this project. Thanks



0
 
LVL 10

Expert Comment

by:Jay Toops
ID: 12056341
if you don't need to have the file in your sql server database just
read the file from the disk
using the file system object
and on your web page put a <PRE> tag
write all the lines of your file to the screen
then at the end close the </PRE>

Jay
0
 
LVL 34

Expert Comment

by:arbert
ID: 12058536
Weird, I didn't get notification on this question way back when.  Ya, I agree you probably want to work with the user's name to make it unique.

I think I would also look at using XMLservices to do some of this and just use XML files....
0
 
LVL 10

Expert Comment

by:Jay Toops
ID: 12078234
HI.. could you award points for this?
Id really appreciate it..

Jay
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question