Link to home
Start Free TrialLog in
Avatar of JavaBoy060299
JavaBoy060299

asked on

How to execute DTS from stored procedure

Hi,

I need to import a text file (fixed-length) into the table.
I have created a DTS package to automate the process, but now i want to do it programmatically from the web application.

I'm thinking to execute the DTS package from a stored procedure, the stored procedure must have texfile pathname, destination server and or table.
subsequently the stored procedure will be called from my web application.

anyone can help me to accomplish the task?

Thanks in advance,
JavaBoy
SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JavaBoy060299
JavaBoy060299

ASKER

Hi Brett,

I have followed your instruction, how DTSRUN is being called would be like this:
DTSRun /~Z0x4D452BBE34D2D8174E8EE3B33F929BEBCED13260EBBC47FF6B20B36DE2B6507A06042244B6591096F565D0DFB3D0C9B132EC5A6C4C17575320D24C7D63C03EB2BECC1AB5E24393B842B817C76113CFAD23E994BD7AB23C054A291D

sorry, I don't understand about global variables, could you elaborate more?
how to define the global variables etc.


ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Dishan,

could you give me an example on how to pass the value into @GlobalVariableList and use it to call the DTS package ?
for my case i need to pass the text file name (full path) that will be imported into the table.

Thank you.
Avatar of namasi_navaretnam
Like was said above, you use the /~A command line variable to pass parms.
Hi all,

thanks.  I think we are almost there :)
but i was wondering when i call the dtsrun as following:
xp_cmdshell 'dtsrun /S CITLOAN100\NETSDK /U sa /P password /N SAT_Upload /A filename:8=d:\admsustf\sat\16dec.txt'

it always imports default file in the package (2dec.txt) instead of global variable specified in dtsrun ???
how to make use of global variable ?

note: in my DTS package i have specified d:\admsustf\sat\2dec.txt.


Brett: UNLESS, you go into sql server agent properties and allow the proxy account to execute without being a member of the sysadmins group.
do you mean i have to schedule the package first? how to allow the proxy account to execute ... ?



No, In Enterprise manager if you right click on your sql agent and choose properties, you will see the "Job System" tab.  Under this tab there is the "Non Sysadmin job-step" item.  This is the proxy account.  

Again, I don't encourage anyone to enable this because of the security hole....
Brett,
thanks for your note.

all:
anyone can tell me how to make the file name of text file (source) to be dynamic ?
i need to pass the file name as a parameter.
Brett, any comment?


Hi JavaBoy
@GlobleVariableList     varchar(500) --"/A <GlobalVariableName>:<datatypeid>=<GlobalVariableValue>"

this is how should pass values ... to sp "/A <GlobalVariableName>:<datatypeid>=<GlobalVariableValue>"

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This will open the package properties window. go through the Connection Node and Click Set btn.
Thanks everyone.

I hope i have given a fair points for all of you guys.

namasi_navaretnam: sorry no points for you, since your comments similar to others. thanks for the links anyway.
One thing to note, if you are using XP_CMDSHELL 'DTSRUN '  you can not run the server in fiber mode, as far as I know.

Not a big problem, but if you get problems at some stage this may be the cause.