Capture and Save SQL Command that Ran in OLEDB Data Source

Hi,
My company is using SSIS to occasionally generate a file that is then being loaded into a transactional system.  At this point, things are not fully automated; the SQL query that is used for the data source is manually altered, SSIS is run, and the
file is uploaded to the other system.  Every time the SSIS package runs, a log entry is created with summary information.
I'm wondering: is it possible to capture the SQL command that runs in the data source, and save it with the log entry as part of the package run?  This would provide an accurate historical record of what filters were applied to the data that was loaded
to the transactional system.
Any thoughts/comments would be appreciated.

Hello Smith,
What I understood from your question that you want to know the query which is running in SSIS Data Source and same you want to insert into a table.
Below query gives you what all queries are currently running on a specified DB:
USE [SAMPLE_DB_NAME]
SELECT  distinct getdate(), command, s.text, start_time, percent_complete, CAST(((DATEDIFF(s, start_time, GetDate())) / 3600) AS int) AS Long, CAST((DATEDIFF(s, start_time, GetDate()) % 3600) / 60 AS int) as LongMin, CAST(((DATEDIFF(s, 
                      start_time, GetDate())) / 3600) AS varchar) + ' hour(s), ' + CAST((DATEDIFF(s, start_time, GetDate()) % 3600) / 60 AS varchar) + 'min, ' + CAST((DATEDIFF(s,
                       start_time, GetDate()) % 60) AS varchar) + ' sec' AS running_time, CAST((estimated_completion_time / 3600000) AS varchar) 
                      + ' hour(s), ' + CAST((estimated_completion_time % 3600000) / 60000 AS varchar) + 'min, ' + CAST((estimated_completion_time % 60000) 
                      / 1000 AS varchar) + ' sec' AS est_time_to_go, dateadd(second, estimated_completion_time / 1000, getdate()) AS est_completion_time, blocking_session_id, r.status, last_wait_type,
r.open_transaction_count, r.session_id, client_net_address, 
 CONVERT(VARCHAR(20), sp.host_name) as hostname, 
 CASE WHEN program_name = '.Net SqlClient Data Provider                      ' THEN 'Reporting Service'
 ELSE CONVERT(VARCHAR(50), program_name) 
 END as program_name,
 sp.login_name as name
FROM         sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s INNER JOIN
                      sys.sysusers u ON r.user_id = u.uid
INNER JOIN sys.dm_exec_connections dec ON dec.session_id = r.session_id INNER JOIN SYS.dm_exec_sessions sp on r.session_id = sp.session_id
WHERE text not like 'SELECT     getdate(), command, s.text, start_time, percent_complete%'
AND text not like '%sys.sp_trace_getdata%'
AND text != 'sp_server_diagnostics'
ORDER BY start_time
You can schedule this query to run in 2-3 second and can capture the T-SQL and insert into a table.
Thanks Shiven:) If Answer is Helpful, Please Vote

Similar Messages

  • HT1296 How can I capture and save an image on my screen for later retrieval

    How can I capture and save an image on my iPad screen for later retrieval, perhaps on my Laptop (Windows 7)?
    Is there a way to copy the image to a storage device?
    Thanks, Don.

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Its easy to take an iPad screenshot. Press & release the Home and the Power buttons quickly at the same time. I have trouble with that so I press & hold the Home button and then very quickly press and release the Power button. Your screenshot is stored in the Camera Roll of the Photos app. Probably the easiest way to get it to your PC is to be using iCloud, or email it to your PC. There are also some wireless sync apps in the iTunes app store that let you send photos from the iPad to a Mac or PC. I use PhotoSync.

  • SQL ENTERPRISE: The edition of Reporting Services that you are using requires that you use local SQL Server relational databases for report data sources and the report server database

    The error below makes absolutely no sense! I'm using Enterprise Core...yet I'm being told I can't use remote data sources:
    w3wp!library!8!03/05/2015-19:08:48:: i INFO: Catalog SQL Server Edition = EnterpriseCore
    w3wp!library!8!03/05/2015-19:08:48:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.OperationNotSupportedException: , Microsoft.ReportingServices.Diagnostics.Utilities.OperationNotSupportedException: The feature: "The edition of Reporting
    Services that you are using requires that you use local SQL Server relational databases for report data sources and the report server database." is not supported in this edition of Reporting Services.;
    Really? This totally contradicts the documentation found here:
    https://msdn.microsoft.com/en-us/library/ms157285(v=sql.110).aspx
    That article says remote connections are completely supported.
    ARGH! Why does this have to be so difficult to setup?!?

    Hi jeffoliver1000,
    According to your description, you are using Enterprise Core edition and you are prompted that you can’t use remote data sources.
    In your scenario, we neither ignore your point nor be doubt with what you say. But actually we have met the case before that even though the SQL Server engine is Enterprise but the reporting services is still standard. So I would recommend you to find the
    actual edition of reporting services you are using. You can find Reporting Services starting SKU in the Reporting Service logs ( default location: C:\Program Files\Microsoft SQL Server\<instance name>\Reporting Services\LogFiles). For more information,
    please refer to the similar thread below:
    https://social.technet.microsoft.com/Forums/en-US/f98c2f3e-1a30-4993-ab41-acbc5014f92e/data-driven-subscription-button-not-displayed?forum=sqlreportingservices
    By the way, have you installed the other SQL Server edition before?
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • OTL I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?

    Hi
    I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
    I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
    Thanks
    Ruby

    Ruby,
    you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP.

  • Is there sort of SQL command that will make a sum

    Is there sort of SQL command that will make a sum of some of the data in one column provided that the data in other columns are the same -- for example, all of the sales from one month added up?

    user532580 wrote:
    Is there sort of SQL command that will make a sum of some of the data in one column provided that the data in other columns are the same -- for example, all of the sales from one month added up?use SUM() function
    post CREATE TABLE & INSERT statements so we have some sample to show actual solution

  • Webcam continuous capture and save to avi later

    Hello,
    I am new to LabVIEW.  If anyone could help with the USB webcam and LabVIEW 2010.  I have all the IMAQ drivers installed.
    What I am try to do is capture video continuously into a buffer memory or an array and be able to extract that buffer video and save it as an AVI video.
    So the main question is buffering video in memory and write as an avi file in later time.
    Sorry if this confusing.  Please let me know, I can be more details to clear thing up.
    Thank you so much for all your help.
    Dan
    Solved!
    Go to Solution.

    Hello Rory,
    Queue is an array with first in first out mechanism which allow you to keep the images in the memory. To create queue, you would need to use Obtain Queue function with string name and image data type as input, the result is that you have a queue to put your image into. During each acquisition loop, you would need to create a new IMAQ image before enqueueing so that each images has it's own memory space.
    Attached is an example that you can try to see as an example, in addition, LabVIEW example finder also have many queue examples.
    Hope that this help you started.
    Regards
    - Meadow -
    LabVIEW 7.0 - 2011, Vision, RT, FPGA
    TestStand 3.0 - 4.5
    Attachments:
    Queue and AVI Example - Single Loop.vi ‏11 KB

  • About capture and save to file

    i can view the movie and save to the file,but i cant use the mediaplayer to play it,who can give a suggestion.thanks
    my code as follow:
    public void tryCapture() {
    di = CaptureDeviceManager.getDevice(
    "vfw:Microsoft WDM Image Capture (Win32):0");
    try {
    if (p != null) {
    return;
    MediaLocator aa = di.getLocator();
    p = Manager.createProcessor(di.getLocator());
    p.configure();
    p.addControllerListener(this);
    catch (Exception e) {
    e.printStackTrace();
    if (p == null) {
    System.exit(0);
    public synchronized void controllerUpdate(ControllerEvent event) {
    if (event instanceof ConfigureCompleteEvent) {
    p.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.
    QUICKTIME));
    p.realize();
    if (event instanceof RealizeCompleteEvent) {
    Panel panel = new Panel();
    panel.setLayout(new BorderLayout());
    Component comp;
    int height = 0, width = 0;
    Control controls[];
    if ( (comp = p.getControlPanelComponent()) != null) {
    panel.add(comp, BorderLayout.SOUTH);
    if ( (comp = p.getVisualComponent()) != null) {
    panel.add(comp, BorderLayout.CENTER);
    else {
    controls = p.getControls();
    for (int i = 0; i < controls.length; i++) {
    if (! (controls[i] instanceof MonitorControl)) {
    continue;
    mc = (MonitorControl) controls;
    comp = mc.getControlComponent();
    if (comp == null) {
    continue;
    panel.add(comp, BorderLayout.CENTER);
    contentPane.add(panel, new XYConstraints(0, 100, 400, 380));
    this.setBounds(300, 120, 420, 520);
    validate();
    mc.setEnabled(true);
    try {
    DataSource ds = p.getDataOutput();
    MediaLocator ml = new MediaLocator("file://e:/test.avi");
    dts = Manager.createDataSink(ds, ml);
    dts.open();
    dts.start();
    catch (Exception ex) {
    ex.printStackTrace();
    p.start();

    i get it ,
    just because i haven't stop the DataSink before close it..
    who can tell me why?
    regards

  • The feature: "The edition of Reporting Services that you are using requires that you use local SQL Server relational databases for report data sources and the report server database." is not supported in this edition of Reporting Services.

    Hello all,
    I have SQL express 2014 advance edition installed ..
    and i am connecting SQl server 2008 r2 instance which is in network 
    while creating datasource in Reportserver which has Express installed ..
    got this error ..
    please help me how to connect to remote server
    Dilip Patil..

    Error message says it all.
    With SQL Express, Data source should be local SQL DB.
    With SQL Enterprise, Standard, BI edition, you can create Data soruce which are hosted on other servers.
    Please refer similar thread:
    https://social.msdn.microsoft.com/Forums/en-US/c0468e3f-bad7-47a7-a695-75c13762280a/the-feature-the-edition-of-reporting-services-that-you-are-using-requires-that-you-use-local-sql?forum=sqlreportingservices
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • Captur and save the jsp

    Hi,
    I want to capture the complete page and save it in a specific location.Can anybody help me in understanding how to achieve this....Thanks In Advance

    revjava wrote:
    Hi,
    I want to capture the complete page and save it in a specific location.Can anybody help me in understanding how to achieve this....Thanks In AdvanceThat's really pretty vague. Do you mean you want to capture the HTML generated by a JSP, which might be as simple as getting the page up in a browser and saving it to a file?

  • Webcam continuous capture and save to avi

    Hello,
    I want to make an acquisition video to an .avi file from my webcam wirh labview and I used the program which is given below, but an error comes up and I could not find a solution (see the attached files).
    Attachments:
    Grab and Save to AVI.vi ‏39 KB
    error.png ‏43 KB

    Replace the session with a valid session?

  • How to capture and save voice from microphone

    I'm beginner to JMF. I want coding for capturing and saving voice from microphone. Plz anybody help me.

    http://javasolution.blogspot.com/2007/04/voice-chat-using-java.html
    http://www.vsj.co.uk/java/display.asp?id=370

  • SQL command to get latest effective date

    Hi!
    How can i want to write a sql command to fetch records as such
    Vendor;    Item;     EffectiveDate;    UnitPrice;    Remarks
    Vend1;      ABC;    31/01/2012;        120;            Dont show
    Vend1;      ABC;    29/02/2012;        150;            Show
    Vend2;      ABC;    01/01/2012;        140;            Show
    Vend1;      XYZ;    15/01/2012;        100;            Show
    Please help me, so far I can only figuire out how to get the latest effective date by vendor and item but was not able to get UnitPrice
    SELECT  "VendPart"."Vendor", "VendPart"."Item", Max("VendPart"."EffectiveDate") AS MaxOfEffectiveDate
    FROM   "POS_LiveRpt"."dbo"."VendPart" "VendPart"
    GROUp BY "VendPart"."Vendor", "VendPart"."Item"
    Edited by: MichellePoh on Feb 23, 2012 9:58 AM

    hi Michelle,
    you can use a subquery in your command to bring back the UnitPrice that is applicable to the max date...see the code below for an idea.
    you'll have to change the "UnitPrice" field below to match yours.
    note that in the subquery the vendpart table has been aliased as vendpart2 for the subquery to work. also note that the code may not work in your database as Alan aluded to the fact that the syntax is specific to the database type...if you get any database errors please refer to your database manual or a forum for your database type that has a subquery. and of course there may be errors from my typing in the query as it's just being done inside this forum thread...but hopefully this will give you an idea how to do this.
    cheers,
    jamie
    SELECT 
    "VendPart"."Vendor",
    "VendPart"."Item",
    Max("VendPart"."EffectiveDate") AS MaxOfEffectiveDate,
    SELECT "VendPart2"."UnitPrice"
    FROM "POS_LiveRpt"."dbo"."VendPart" "VendPart2"
    WHERE "VendPart2"."EffectiveDate" = Max("VendPart"."EffectiveDate")
    AND  "VendPart2"."Vendor" =  "VendPart"."Vendor"
    AND "VendPart2"."Item" = "VendPart"."Item"
    ) AS UnitPrice
    FROM  
    "POS_LiveRpt"."dbo"."VendPart" "VendPart"
    GROUp BY
    "VendPart"."Vendor", "VendPart"."Item"

  • Using OLE DB Source (SQL Command) as input to DQS Data Services

    Hi,
    I am using an OLE DB Source(SQL Command) as the input to my DQS Cleansing task.
    When I preview in design view my SQL Command I see rows returned.
    Yet at runtime no rows are sent to the DQS Cleansing Task.
    Can I use an OLE DB Source(SQL Command) as an input to a DQS Cleansing Task?
    Any ideas why it sends no records?
    Thanks,
    C.
    CG

    NuTech, is this still an issue?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Issue with SQL Query with Presentation Variable as Data Source in BI Publisher

    Hello All
    I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
    select TILE4,max(APPTS), 'Top Count' from
    SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0))  AS TILE4,
    c4 as dept,c6 as month FROM 
    select sum(case  when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
         sum(case  when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
         T802.NAME_LEVEL_6 as c3,
         T802.NAME_LEVEL_1 as c4,
         T6172.CALENDARMONTHNAMEANDYEAR as c5,
         T6172.CALENDARMONTHNUMBERINYEAR as c6,
         T802.DEPT_CODE as c7
    from
         DW_date_DIM T6736 /* z_dim_date */ ,
         DW_MONTH_DIM T6172 /* z_dim_month */ ,
         DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
         DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
    where  ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 =  '@{PV_D}{RSD}' 
    and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
    and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
    and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6)  and substr('@{Month_END}',8,13))
    and (T6736.TYPE in ('Call Center', 'LSM')) )
    group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
    order by c4, c3, c6, c7, c5
    ))where tile4=3 group by tile4
    When I try to view data after creating the data set, I get the following error:
    Failed to load XML
    XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
    Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
    So I know it is the PV that's causing this error.
    How can I work around it?
    There is no way to create equivalent report without using the direct sql..
    Thanks in advance

    I have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
    is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
    a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
    or more descriptive errors.
    //Jonas 

  • Can't save BISM file pointing to excel sheet (data source). ErrMsg: "There were errors found while validating the page: Cannot connect to the server or database."

    Hi,
    Me and a collegue is administrering our new enterprise BI portal in SharePoint 2013 (On Premise) and have a problem with using a specific Excel file including general ledger data as data source through a BISM file.
    This particular BISM file can't be saved without getting the error message "There were errors found while validating the page: Cannot connect to the server or database."
    BISM files against other Excel sheets and sources (for example SSAS tabular databases) works well.
    Can anyone help us pinpointing whats wrong here, this is a really important stakeholder in our organization requesting this reporting?
    Cheers!

    Hi E.SWARD ,
    My self created a Power pivot excel then i want to use this excel to create BI file . Still i am getting the same error . Pls help me to resolve this issue
    Cannot connect to the server or database.
    I am getting the similar error , if i use Tabular analysis server instance .
    Subhash

Maybe you are looking for