Finding active DTS packages
9November 27, 2013 by Kenneth Fisher
DTS is dead, long live SSIS. Way back when SQL 2005 was announced then released DTS was pronounced DOA. SSIS was the wave of the future. Everyone was so thrilled that posts like SSIS’ 15 faults and Why I hate SSIS: Part N+1 were all over the place, and I was right there with them. My first impression was that SSIS was designed by not one committee but several, and they hate each other.
Now to the present. I’m used to SSIS now, I even quite like it. I think it is a very powerful ETL tool with lots of applications and I use it frequently. I even think in general it was well written. However, I still haven’t changed my mind about the committees and I still think SSIS was poorly designed in some ways. I don’t think I’m all that unusual either. I don’t see many blogs complaining about SSIS anymore, but I still see plenty of DTS packages. In fact I have developers in my office that are actively resisting moving to SSIS and continue to create new DTS packages.
This is a problem. A big problem. As of SQL 2012 DTS is no longer supported. At all. Not even using the add on components that were available for SQL 2005, 2008 and 2008R2.
This of course means that in order to move to SQL 2012 all of the DTS packages have to be converted to something else, presumably SSIS. Just use the conversion tool right? Well, as anyone who has used it can tell you the conversion tool can be somewhat iffy. That means converting some of them by hand and double checking the rest. Somewhat labor intensive but doable.
Unless you have a server with 1300 DTS packages on it. And yes, my office does in fact have a server with over 1300 DTS packages. I’m going to say that one more time, 1300 DTS packages on one server! Imagine trying to do that conversion. To say it would be a nightmare is an understatement.
So how can we can reduce that number a bit? There is no reason to convert the packages that are no longer in use. I mean they can’t be using 1300 different DTS packages right? So how do we tell what packages are being used? Well, we could check the various jobs, ask the developers, ask any power users and keep our fingers crossed. I’ve gone this route before. Depending on the size of the operation, age of the packages, how often the packages are used, etc. I’ve gotten around 50-75% of the packages actually in use. Not good enough. I want something a bit more certain.
It turns out that any time you open a DTS package either to edit it or to run it SQL uses the undocumented stored procedure ‘sp_get_dtspackage’ to load it. And that means we can create a trace to catch uses of it. For SQL 2008 or 2008 R2 you can also use extended events but I’m not going to demonstrate that here since tracing will work for all versions needed and extended events will only work for 2008 and 2008 R2.
Here is a sample trace script I generated from profiler. It’s fairly light weight because I’m only pulling the RPC Completed and Stmt Completed events and the TextData, Spid and EndTime columns. Really no more is needed for this purpose.
-- Create a Queue declare @rc int declare @TraceID int declare @maxfilesize bigint set @maxfilesize = 5 exec @rc = sp_trace_create @TraceID output, 0, N'C:\TEMP\Running_DTS', @maxfilesize, NULL if (@rc != 0) goto error -- Set the events declare @on bit set @on = 1 exec sp_trace_setevent @TraceID, 10, 15, @on exec sp_trace_setevent @TraceID, 10, 1, @on exec sp_trace_setevent @TraceID, 10, 12, @on exec sp_trace_setevent @TraceID, 12, 15, @on exec sp_trace_setevent @TraceID, 12, 1, @on exec sp_trace_setevent @TraceID, 12, 12, @on -- Set the Filters declare @intfilter int declare @bigintfilter bigint exec sp_trace_setfilter @TraceID, 1, 0, 6, N'%sp_get_dtspackage%' exec sp_trace_setfilter @TraceID, 1, 0, 1, NULL -- Set the trace status to start exec sp_trace_setstatus @TraceID, 1 -- display trace id for future references select TraceID=@TraceID goto finish error: select ErrorCode=@rc finish: go
Here I open and close a DTS package called Test_Move. Next I stop and close the trace.
declare @TraceID int SET @TraceID = 2 EXEC sp_trace_setstatus @TraceID,0 EXEC sp_trace_setstatus @TraceID,2
And read from the trace file.
SELECT * FROM fn_trace_gettable ('C:\TEMP\Running_DTS.trc',1)
Then here is an example of the command you get.
exec msdb..sp_get_dtspackage N'Test_Move', '{7343C93E-0D24-444B-B491-4F153F0A0BA4}', '{B750E449-0C7F-4B33-8306-E682AC5C0705}'
At this point it is easy enough to substring out the name of the DTS package. Run this over the course of a couple weeks to a month and you can be fairly sure to get most if not all of the active DTS packages. You need to be somewhat careful as you are still likely to miss the infrequently run packages. Those that run monthly, quarterly, yearly, or at need. Personally I would take the list from the trace along with a list of those packages that aren’t in the first list as a starting point. From there search active jobs, ask developers etc to generate a final conversion list. Then of course make sure that you have a backup of msdb and a place you can bring it up at need to get any missed DTS packages in the future.
[…] Finding active DTS packages […]
[…] Finding active DTS packages Script to find DTS Connections (No not SSIS) […]
Just made my day! I am doing a similar analysis with a server with around 60 packages. Thanks a lot.
Glad it helped! If you take a look I also have at least one SMO to list out all DTS package connections (only works on SQL 2005 though I’m afraid)
Worked Great ! Got the runtimes from the trace as described. I am doing a similar analysis for both DTS and SSIS packages on 1000+ packages. Similar to “sp_dts_getpackage” for DTS packages,could you please let me know what is the SP used for SSIS ?
I don’t believe SSIS is handled the same way (if there is an SP I don’t know it). Here is a similar question with a suggestion in the comments though: https://dba.stackexchange.com/questions/112440/how-to-trace-an-ssis-package-using-extended-events
The below link suggests that the same sp is used for handling SSIS packages also in 2005. Only trying to find out why the SSIS are not captured in the trace for this sp and only DTS package executions are captured.
https://books.google.co.in/books?id=at9KSiW0FzMC&pg=PA393&lpg=PA393&dq=equivalent+of+SP_DTS_GETPACKAGE+in+SQL+Server+2005&source=bl&ots=pFkq45Qybe&sig=TLET1xO2RORhunxgg0dDPZe5Gok&hl=en&sa=X&ved=0ahUKEwipjM7Axt7VAhVJRY8KHfzXAEkQ6AEIKDAB#v=onepage&q=equivalent%20of%20SP_DTS_GETPACKAGE%20in%20SQL%20Server%202005&f=false
I’d honestly be surprised if SSIS & DTS were both opened by the same SP. As far as I know they are stored differently. The way I found this one was taking a machine that wasn’t doing anything, running a general trace and then running a DTS package. You might be able to do something similar for SSIS.
Thank you very much for both scripts this and about connections. I need to move about 200 packages and you save weeks of work