Is there a way to save all queries present in a ssis package/dtsx file?

五迷三道 提交于 2019-12-11 06:41:43

问题


I need to run some analysis on my queries (specifically finding all the tables which a ssis calls). Right now I'm opening up every single ssis package, every single step in it and copy and pasting manually the tables from it. As you can imagine it's very time consuming and mind-numbing.

Is there a way to do export all the queries automatically ?

btw i'm using sql server 2012


回答1:


Retrieve Queries is not a simple process, you can work in two ways to achieve it:

Analyzing the .dtsx package XML content using Regular Expression

SSIS packages (.dtsx) are XML files, you can read these file as text file and use Regular Expressions to retrieve tables (as example you may search all sentences that starts with SELECT, UPDATE, DELETE, DROP, ... keywords)

There are some questions asking to retrieve some information from .dtsx files that you can refer to to get some ideas:

  • Reverse engineering SSIS package using C#
  • Automate Version number Retrieval from .Dtsx files

Using SQL Profiler

You can create and run an SQL Profiler trace on the SQL Server instance and filter on all T-SQL commands executed while executing the ssis package. Some examples can be found in the following posts:

  • How to capture queries, tables and fields using the SQL Server Profiler
  • How to monitor just t-sql commands in SQL Profiler?
  • SSIS OLE DB Source Editor Data Access Mode: “SQL command” vs “Table or view”
  • Is there a way in SQL profiler to filter by INSERT statements?
  • Filter Events in a Trace (SQL Server Profiler)

Also you can use Extended Events (has more options than profiler) to monitor the server and collect SQL commands:

  • Getting Started with Extended Events in SQL Server 2012
  • Capturing queries run by user on SQL Server using extended events



回答2:


You could create a schema for this specific project and then have all the SQL stored within views on that schema... Will help keep things tidy and help with issues like this.



来源:https://stackoverflow.com/questions/54181349/is-there-a-way-to-save-all-queries-present-in-a-ssis-package-dtsx-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!