Solved

Create DTS package with variables

Posted on 2004-08-17
12
246 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 10

Accepted Solution

by:
Jay Toops earned 125 total points
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 34

Assisted Solution

by:arbert
arbert earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
HI.. could you award points for this?
Id really appreciate it..

Jay
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now