dbTalk Databases Forums  

Dynamic Location of Output file

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Dynamic Location of Output file in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Vic Spainhower
 
Posts: n/a

Default Dynamic Location of Output file - 12-10-2004 , 04:05 PM






Hello,

I have a dts package that creates a csv file in a multi-user environment.
How can I dynamically specify the output location so that it goes into each
users "My Documents" folder?

Thanks,

Vic



Reply With Quote
  #2  
Old   
Vic Spainhower
 
Posts: n/a

Default Re: Dynamic Location of Output file - 12-10-2004 , 07:36 PM






Here is the script that I'm trying to get to work. It operates ok if I do
not change the Output file name & location of the destination so something
is wrong with how I am specifying the destination file name. Can someone
tell me what is wrong with the following script? The input GlobalVariable is
working ok but the Output variable is not be assigned to the destination
file name.

Thank You

Vic


Function Main()
Dim oPkg, oDataPump, sSQLStatement, sFileName

' Build new SQL Statement
sSQLStatement = "SELECT * FROM dbo.vuCoverLetter WHERE JobID = '" & _
DTSGlobalVariables("JobID").Value & "'"

' Get reference to the DataPump Task
Set oPkg = DTSGlobalVariables.Parent
Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

' Assign SQL Statement to Source of DataPump
oDataPump.SourceSQLStatement = sSQLStatement

' Following statements assign the output file name and location

sFilename = DTSGlobalVariables("OUTPUT").Value
oDataPump.DestinationObjectName = sFileName

' Clean Up
Set oDataPump = Nothing
Set oPkg = Nothing

Main = DTSTaskExecResult_Success

End Function



Reply With Quote
  #3  
Old   
Ed
 
Posts: n/a

Default Re: Dynamic Location of Output file - 12-11-2004 , 03:09 AM



Have you ever tried the FileSystemObject yet?
That is a very common way to move data around

Ed

"Vic Spainhower" wrote:

Quote:
Here is the script that I'm trying to get to work. It operates ok if I do
not change the Output file name & location of the destination so something
is wrong with how I am specifying the destination file name. Can someone
tell me what is wrong with the following script? The input GlobalVariable is
working ok but the Output variable is not be assigned to the destination
file name.

Thank You

Vic


Function Main()
Dim oPkg, oDataPump, sSQLStatement, sFileName

' Build new SQL Statement
sSQLStatement = "SELECT * FROM dbo.vuCoverLetter WHERE JobID = '" & _
DTSGlobalVariables("JobID").Value & "'"

' Get reference to the DataPump Task
Set oPkg = DTSGlobalVariables.Parent
Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

' Assign SQL Statement to Source of DataPump
oDataPump.SourceSQLStatement = sSQLStatement

' Following statements assign the output file name and location

sFilename = DTSGlobalVariables("OUTPUT").Value
oDataPump.DestinationObjectName = sFileName

' Clean Up
Set oDataPump = Nothing
Set oPkg = Nothing

Main = DTSTaskExecResult_Success

End Function




Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: Dynamic Location of Output file - 12-11-2004 , 06:11 AM



In message <#knpZHy3EHA.2600 (AT) TK2MSFTNGP09 (DOT) phx.gbl>, Vic Spainhower
<vicNoSpam (AT) perfected (DOT) com> writes
Quote:
Here is the script that I'm trying to get to work. It operates ok if I do
not change the Output file name & location of the destination so something
is wrong with how I am specifying the destination file name. Can someone
tell me what is wrong with the following script? The input GlobalVariable is
working ok but the Output variable is not be assigned to the destination
file name.

Thank You

Vic
The file name should be set on the destination connection in this case,
the DataSource property.

How can I change the filename for a text file connection?
(http://www.sqldts.com/default.aspx?200)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #5  
Old   
Vic Spainhower
 
Posts: n/a

Default Re: Dynamic Location of Output file - 12-11-2004 , 08:17 AM



Darren,

Thank you that did the trick ...


Vic


"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
In message <#knpZHy3EHA.2600 (AT) TK2MSFTNGP09 (DOT) phx.gbl>, Vic Spainhower
vicNoSpam (AT) perfected (DOT) com> writes
Here is the script that I'm trying to get to work. It operates ok if I do
not change the Output file name & location of the destination so something
is wrong with how I am specifying the destination file name. Can someone
tell me what is wrong with the following script? The input GlobalVariable
is
working ok but the Output variable is not be assigned to the destination
file name.

Thank You

Vic

The file name should be set on the destination connection in this case,
the DataSource property.

How can I change the filename for a text file connection?
(http://www.sqldts.com/default.aspx?200)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org




Reply With Quote
  #6  
Old   
Vic Spainhower
 
Posts: n/a

Default Re: Dynamic Location of Output file - 12-11-2004 , 08:20 AM



Ed,

Yes, I've used FSO and maybe it would be more appropriate, I don't know. But
I decided to use dts just so that I could learn more about it.

Vic


"Ed" <Ed (AT) discussions (DOT) microsoft.com> wrote

Quote:
Have you ever tried the FileSystemObject yet?
That is a very common way to move data around

Ed

"Vic Spainhower" wrote:

Here is the script that I'm trying to get to work. It operates ok if I do
not change the Output file name & location of the destination so
something
is wrong with how I am specifying the destination file name. Can someone
tell me what is wrong with the following script? The input GlobalVariable
is
working ok but the Output variable is not be assigned to the destination
file name.

Thank You

Vic


Function Main()
Dim oPkg, oDataPump, sSQLStatement, sFileName

' Build new SQL Statement
sSQLStatement = "SELECT * FROM dbo.vuCoverLetter WHERE JobID = '" & _
DTSGlobalVariables("JobID").Value & "'"

' Get reference to the DataPump Task
Set oPkg = DTSGlobalVariables.Parent
Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

' Assign SQL Statement to Source of DataPump
oDataPump.SourceSQLStatement = sSQLStatement

' Following statements assign the output file name and location

sFilename = DTSGlobalVariables("OUTPUT").Value
oDataPump.DestinationObjectName = sFileName

' Clean Up
Set oDataPump = Nothing
Set oPkg = Nothing

Main = DTSTaskExecResult_Success

End Function






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.