Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 DTS packages

Author  Topic 

rohans
Posting Yak Master

194 Posts

Posted - 2004-06-21 : 11:09:07
How may I execute a DTS package from within T-SQL.

All help appreciated.

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-21 : 11:14:24
See dtsrun in bol.
Also
http://www.nigelrivett.net/sp_oacreateLoadDTSpackage.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-06-21 : 17:00:19
I see the t-sql but it is not very clear. I will be trying it however.

Thank you

All help appreciated.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-21 : 17:07:18
From T-SQL,

EXEC master.dbo.xp_cmdshell 'dtsrun -...

dtsrun is a command line utility, so either run it from the command line or from xp_cmdshell.

Tara
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-06-22 : 12:58:23
My command is as follows
EXEC master.dbo.xp_cmdshell 'dtsrun /Fc:\dba\sql\filename.csv /Nc:\dba\sql\dts\import2.dts';

I tried it but got this error

Error: -2147220220 (80040504); Provider Error: 0 (0)
Error string: The specified file is not a Package Storage File.
Error source: Microsoft Data Transformation Services (DTS) Package
Help file: sqldts80.hlp
Help context: 704


All help appreciated.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-22 : 13:01:13
/F switch is if your DTS package has been saved as a file. Try:

EXEC master.dbo.xp_cmdshell 'dtsrun /Fc:\dba\sql\dts\import2.dts /E'


Tara
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-06-24 : 11:23:54
Thank Tara. I got it working, but how can I supply the file name for the text file I am importing. that is what I really want to do, from the command line or in T-SQL.

All help appreciated.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-24 : 11:38:09
dtsrun allows you to set global parameters which can then be used in a dynamic properties task to set the filename.

Why not use bulk insert instead - it's much simpler and faster.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-24 : 11:38:30
dtsrun allows you to set global parameters which can then be used in a dynamic properties task to set the filename.

Why not use bulk insert instead - it's much simpler and faster.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-06-24 : 12:19:50
Is it possible to ignore the first columns using the bulk insert? I currently have the column headings in there.

All help appreciated.
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-06-24 : 12:21:45
Ok I found it, must have skipped it, the parm is FIRSTROW


All help appreciated.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-24 : 12:21:58
Yes you can with the FIRSTROW option (there's also a LASTROW option). Just look up BULK INSERT in BOL for all the details.

Tara
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-24 : 12:22:42
You beat me to it.

Tara
Go to Top of Page
   

- Advertisement -