Capture @@ROWCOUNT for all QUERIES using SQL AUDIT

I have a requirement where the customer wants to audit all SELECT queries made to a specific table  and also capture
"No of rows returned" for these queries made to the table. I was able to capture various SELECT queries happening in the database /Table using SQL AUDIT, Wondering if anybody can suggest how to capture no of rows affected along
with it, Since we have numerous stored procedures in the system we wont be able to modify existing stored procedures.

Good day Vish_SQL,
There are several options that you can use, which fit different cases. for example:
1. Using extended events (My prefered solution for most cases like this)
2. Using profiler (older option)
3. Using view (with the same name as the table, and rename the tables related to the issue) instead of the original table, adding to the view a simple function or SP (CLR for example). the function return the
column value, but behind the  screen write information to another table. It is a very rare case that you need this option, and I can't recommend
it.
4. using applications like GREENSQL which give another level between the application and the SQL Server. The users connect to the server but the server do not listen to remote connection but the external app dose.
In this case the app get the query and send it t the server (after security or monitoring if you need)
* it was much simpler if you want to monitor delete, update, or insert for example, since in those cases you could work with AFTER trigger.
** I highly recommend you to monitor the application that connect to the SQL Server rather than the SQL Server. if you can.
Check this:
http://solutioncenter.apexsql.com/auditing-select-statements-on-sql-server/
  Ronen Ariely
 [Personal Site]    [Blog]    [Facebook]

Similar Messages

  • Can we implement the functionality similar to ROW_NUMBER() in generic/common way for all databases using SQL ?

    In my project,i am allowing user to select database of his choice from given options & i need to write queries considering
    all these optional databases. So as per my one of requirement,is there any way to achieve generic functionality similar to ROW_NUMBER() in MSSQL ?

    First run this and check the db version
    SELECT @@VERSION
    EXEC sp_dbcmptlevel 'db name'
    If version is above 2012 and compatibility level is above 80 ROW_NUMBER will work.
    Otherwise you need to use this
    http://sqlserverplanet.com/sql-2000/simulate-row_number-in-sql-2000
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Single Selection Prompt for all queries

    Hi All,
    I have 5 queries in my workbook.
    Each query uses some variable which is not used in the other queries.
    So, i get 5 prompts when i run the query.
    This looks very awkward and also my system almost hangs while showing for each prompt.
    Is there any way of showing all the variables in a single prompt?
    Thanks,
    Arun KK

    Hi,
    I found this answer on a message board:
    http://sap.ittoolbox.com/groups/technical-functional/sap-bw/assigning-same-variable-values-for-queries-in-workbook-711943
    There are two answers to your question, depending on whether or not all of the dates are the same info object (i.e., have the same technical name).
    Case 1:  All info objects have the same technical name.
    Use the "refresh all" option:
    Run "SAPBEX.XLA!SAPBEXrefresh", True 'true = refresh all
    BW will use the input from the first set of refresh screen variables for all others.  IF each query have exactly the same refresh screen, you will not see another refresh variable screen.  If not, then BW will stop between queries to ask for more input, only if required. 
    So, the trick would be to define the first query that refreshes in such a way that its variable screen covers everything needed.
    Case 2:  Not all info objects have the same technical name.
    Use the "Save and reuse variable values" option.  You will find this in the query Properties dialog box on the second tab ("Interaction").  Put a check there for all queries except the first one. 
    Set up the workbook so that the first query refreshes by itself
    Run "SAPBEX.XLA!SAPBEXrefresh", False 'False = refresh one only
    Then, after the first query has refreshed, locate the date(s) the user selected and copy those to the ranges for all other date values.  If your installation is BW 3.x, the code below should do the trick.
    It is slightly ineffecient because it will refresh the first query twice.  But, the second refresh will be fast because the results will still be in cache. And, the code to keep it from refreshing the first query twice is not something you really want to mess with.
    Alternatively, instead of using the SAPBEXrefresh, True at the end, you could put in 13 different SAPBEXrefresh, False statements, identifying the other 13 query worksheets individually.
       Run "SAPBEX.xla!SAPBEXrefresh", False, _
           Sheets("firstQueryToRefresh").Range("a cell in the query")
       'locate dates user selected for "0CALMONTH"
       For i = numFilter + 3 To 4 Step -1
           If Range("GS" & i) = "0CALMONTH" Then
               myType = Range("GC" & i)
               myInterval = Range("GD" & i)
               intfirstMonth ("GE" & i)
               extfirstMonth = Range("GF" & i)
               intlastMonth = Range("GG" & i)
               extlastMonth = Range("GH" & i)
               Exit For
           End If
       Next i
       For i = 4 To numFilters + 3
           If Range("GS" & i) = "YCODOCMNT" Or _
               Range("GS" & i) = "YCOSHPMNT" Or _
               Range("GS" & i) = "0CALMONTH" Or _
               Range("GS" & i) = "YCOACCMT" Then
               Range("GC" & i) = myType
               Range("GD" & i) = myInterval
               Range("GE" & i) = intfirstMonth
               Range("GF" & i) = extfirstMonth
               Range("GG" & i) = intlastMonth
               Range("GH" & i) = extlastMonth
           End If
       Next i
       Sheets("SAPBEXqueries").Visible = xlSheetVeryHidden
       Sheets("firstQueryToRefresh").Select
       Application.ScreenUpdating = True
       Run "SAPBEX.xla!SAPBEXrefresh", False
    End Sub
    maybe this will help a bit.
    regards,
    Raymond Baggen
    Uphantis bv

  • Can't get around this error after adding second dataset...A scope is required for all aggregates used outside of a data region unless the report contains exactly one dataset

    I added a dataset to an existing report and broke an aggregation.  In the old (i.e. single dataset) report, this expression below worked fine.  I wanted to get a distinct count of the vst_ext_id field when my educated field was like "VTE1*"
    = CountDistinct(IIF(Fields!educated.Value like "VTE1*", Fields!vst_ext_id.Value, Nothing))
    After adding a new dataset, this no longer works and I get the error " A scope is required for all aggregates used outside of a data region unless the report contains exactly one dataset".  Having done some research online, I found that I
    needed to specify my dataset explicitly and I thought this new expression might work, but still no success...
    = CountDistinct(IIF(Fields!educated.Value,"DataSet1" like "VTE12*", Fields!vst_ext_id.Value,"DataSet1", Nothing))
    Am I missing something?  Based on online responses, this explicit dataset naming convention seems to help most people, but it isn't working for me. 
    Thanks in advance!
    Brian

    I found the answer.  Apparently, my expression syntax was off.  This expression does the trick...
    = CountDistinct(IIF(Fields!educated.Value like "VTE12*", Fields!vst_ext_id.Value,Nothing),"DataSet1")
    I just happened upon this particular syntax searching online.  I was trying to specify the dataset name after each .value, but I never got that to work.   This is the only time I have found this particular syntax online. 

  • Material creation for All VIEW using BAPI Function modules

    Dear All,
                 I want to create materials for all views using BAPI F.Ms. By using BAPI_MATERIAL_SAVEDATA i have extended materials for for only specified views. now my requirement is to create Material with All views including Classfication view also. For this i found BAPI_OBJCL_CREATEFM.
             Tell me that shall i use both Fm's at time to create material.Will it work? According to my knowledge we need to create Characters first ,then we should  assign this character to this class, then while creation of material we should select this class .
            so pls guide me the procedure to follow for both FM's .
    Note : Pls don't suggest me LSMW OR BDC procedure.
    regards,
    Prashanth Maturu.

    Hi prashanth,
    U can use both the FM. using BAPI_MATERIAL_SAVEDATA u can create all the views and for classification view use BAPI_OBJCL_CREATE. before assigning class to material u hve to make sure that the characteristics are uploaded and is attched to the class using transaction CL03.
    Regards,
    Anil N.

  • 2g data allowance in single line plan is only for 4g LTE or for all data using?

       I got a single line plan and an iPhone 5s a couple days ago.  I am confused the data allowance is for 4g LTE only or for all data using?  Thank you!

        Hello edsun1997
    I would love to answer this for you. You have 2 GB's to use on our network this will start over at the beginning of your cycle. If you use Wifi and turn off our network, Wifi would not go against that 2 GB bucket.
    JoeL_VZW
    Follow us on Twitter @VZWSupport

  • Is it possible to mass change desktop wall paper for all users using WGM?

    is it possible to mass change desktop wall paper for all users using WGM?

    yes, it's easy - change a machine to the desktop you want (the image must be on all the machines, with the same name, of course), find ~/library/preferences/com.apple.desktop.plist Copy that to your server (or just put it on a flash drive) In workgroup manager select preferences - details - "add". Navigate to that plist. (Optional - hit "edit" and cut and past from "often" to "always", then the user cannot change the desktop at all, if you leave it in "often" it will reset next log-on.)

  • Change read mode for all queries

    Hello, this should be an easy question for someone.  I believe there is a way to change the "read mode" for all queries at once.
    Can you tell me how to do that ?
    Thanks very much !!
    Keith

    Hello Bhanu,
    Iam not able to change query in my BW system but when i add authorization of SAP_NEW and SAP_ALL ,then iam able to change ,can i make modification in this table and then
    change or its a authorization problem.If this issue can be resolved with changing this table, kindly tell me how i have to call this table and wt parameters to change,kindly revert at earliest.I have sent u a mail also,kindly plz check.
    Regards,
    Saumya

  • How does select stmt with for all entries uses Indexes

    Hello all,
    I goes through a number of documents but still confused how does select for all entries uses indexes if fields are not in sequences. i got pretty much the same results if i take like two cases on Hr tables HRP1000 and HRP1001(with for all entries based upon hrp1000). Here is the sequence of index fields on hrp1001 (MANDT, OTYPE, OBJID, PLVAR, RSIGN, RELAT, ISTAT, PRIOX, BEGDA, ENDDA, VARYF, SEQNR). in second case objid field is in sequence as in defined Index but i dont see significant increase in field even though the number of records are around 30000. My question is does it make a differrence to use field sequence (same as in table indexes) in comparison to redundant field sequence (not same as defined in table indexes), secondly how we can ge tto know if table index is used in Select for entries query i tried Explain in ST05 but its not clear if it uses any index at all in hrp1001 read.
    here is the sample code i use to get test results.
    test case 1
    REPORT  zdemo_perf_select.
    DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
    DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
    DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
    DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
    DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
    DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
    DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: t1 TYPE timestampl,
          t2 TYPE timestampl,
          t3 TYPE timestampl 
    SELECT * FROM hrp1000 CLIENT SPECIFIED  INTO TABLE it_hrp1000 bypassing buffer
                WHERE mandt EQ sy-mandt AND
                      plvar EQ '01' AND
                      otype EQ 'S'AND
                      istat EQ '1' AND
                      begda <= sy-datum AND
                      endda >= sy-datum AND
                      langu EQ 'EN'.
    GET TIME STAMP FIELD t1.
    SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
                FOR ALL ENTRIES IN it_hrp1000
                 WHERE mandt EQ sy-mandt AND
                        otype EQ 'S' AND
    *                    objid EQ it_hrp1000-objid and
                        plvar EQ '01' AND
                        rsign EQ 'B' AND
                        relat EQ '007' AND
                        istat EQ '1' AND
                        begda LT sy-datum AND
                        endda GT sy-datum and
                        sclas EQ 'C' and
                        objid EQ it_hrp1000-objid.
    *                    %_hints mssqlnt 'INDEX(HRP1001~0)'.
    *delete it_hrp1001 where sclas ne 'C'.
    GET TIME STAMP FIELD t2.
    t3 = t1 - t2.
    WRITE: 'Time taken - ', t3.
    test case 2
    REPORT  zdemo_perf_select.
    DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
    DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
    DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
    DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
    DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
    DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
    DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: t1 TYPE timestampl,
          t2 TYPE timestampl,
          t3 TYPE timestampl 
    SELECT * FROM hrp1000 CLIENT SPECIFIED  INTO TABLE it_hrp1000 bypassing buffer
                WHERE mandt EQ sy-mandt AND
                      plvar EQ '01' AND
                      otype EQ 'S'AND
                      istat EQ '1' AND
                      begda <= sy-datum AND
                      endda >= sy-datum AND
                      langu EQ 'EN'.
    GET TIME STAMP FIELD t1.
    SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
                FOR ALL ENTRIES IN it_hrp1000
                 WHERE mandt EQ sy-mandt AND
                        otype EQ 'S' AND
                        objid EQ it_hrp1000-objid and
                        plvar EQ '01' AND
                        rsign EQ 'B' AND
                        relat EQ '007' AND
                        istat EQ '1' AND
                        begda LT sy-datum AND
                        endda GT sy-datum and
                        sclas EQ 'C'." and
    *                    objid EQ it_hrp1000-objid.
    *                    %_hints mssqlnt 'INDEX(HRP1001~0)'.
    *delete it_hrp1001 where sclas ne 'C'.
    GET TIME STAMP FIELD t2.
    t3 = t1 - t2.
    WRITE: 'Time taken - ', t3.

    Mani wrote:
    Thank you for your answer, its very helpful but i am still nor sure how does parameter rsdb/max_blocking_factor affect records size.
    Hi,
    The blocking affects the size of the statement and the memory structures for returning the result.
    So if your itab has 500 rows and your blocking is 5, the very same statement will be executed 100 times.
    Nothing good or bad about this so far.
    Assume, your average result for an inlist 5 statement is 25 records with an average size of 109 bytes.
    You average result size will be 2725 byte plus overhead which will nearly perfectly fit into two 1500 byte ethernet frames.
    Nothing to do in this case.
    Assume your average result for an inlist 5 statement is 7 records with an average size of 67 bytes.
    You average result size will be ~ 470 byte plus overhead which will only fill 1/3 of a 1500 byte ethernet frame.
    In this case, setting the blocking to 12 ... 15 will give you 66% network transfer performance gain,
    and reduces the number of calls to the DB by 50%, giving additional benefit.
    Now this is an extreme example. The longer the average row length is, the lower will be the average loss in the network.
    You have the same effects in memory structures, but on that layer you are fighting single micro seconds instead of
    hundreds of these, so in real life it is rarely measurable.
    Depending on table-statistics, oracle might decide for short inlists to use a concatanation instead of an inlist.
    This is supposed to be more costy, but I never had a case where I could proove a big difference.
    Values from 5 to 15 for blocking seem to be ok for me. If you have special statements in customer coding,
    it #might# be benefitial to do the mentioned calculations and do some network tracing to see if you can squeeze your
    network efficiency by tuning the blocking.
    If you have jumbo frames enabled, it might be worth to be analyzed as well.
    If you are only on a DB-CI system that is loopback connected to the DB, I doubt there might be a big outcome.
    Hope this helps
    Volker

  • How to find out the script for the table using SQL

    Hi,
    Could any one tell me that how to find out the script for the table using SQL.
    Thanks,
    kamal

    Kamal,
    You can find the SQL query in Advanced tab of Answers
    Thanks,
    Balaa...

  • ICM active -- NO CONNECTION for all AppServers (using TREX host names / IP

    Hi Experts,
    Our Basis team has set up new BWA Box for a Quality. When i went to a transaction "RSDDBIAMON" I am getting below error.
    Q27: ICM active --> NO CONNECTION for all AppServers (using TREX host names / IP addresses). Configure ICM/TCM connection in SAP
    RFC Connection is working. I have tested it in sm59. Can anyone help to understan where will be the problem.
    Regards,

    In TREX Admin, I was able to check ICM error and got IP address.. After this got to know host-name of the server is different from configured in ICM.

  • Turn off status messages for all queries in RSRT

    Hi Gurus,
    I got some help on this issue in a previous question, but I ended up having to fix more queries than I expected.
    Is there a way to turn off the messages for all queries in the system through transaction RSRT?   Right now I'm doing it one query at a time.

    Hi,
    Go to Transaction RSRT, then enter SUPPR_ALL in the tcode box again and hit enter. This brings up the maintain messages screen and it suppress the messages globally
    cheers,
    Swapna.G

  • Sybase ESP java sdk, SQL parser exception for all queries

    Hi,
    I am new to Sybase ESP java sdk. Trying to use sdk projection subscription, but getting for all the queries including blank string:-
    com.sybase.esp.sdk.exception.ProjectErrorException: SQL parsing error
    at com.sybase.esp.sdk.impl.SubscriberImplV3.doSubscribe(Unknown Source)
    at com.sybase.esp.sdk.impl.SubscriberImpl.subscribeSql(Unknown Source)
    My Example code :-
    Credentials creds = new Credentials.Builder(Credentials.Type.USER_PASSWORD).setUser("user").setPassword("pwd").create();
      Project project = s_sdk.getProject(uri, creds);
      project.connect(WAIT_TIME_60000_MS);
      Subscriber subscriber = project.createSubscriber();
      //subscriber.subscribeStream("Trades");
      subscriber.connect();
                    subscriber.subscribeSql("select UserMaxCpu from wSBW912");
    I am new to sdk and not sure what I am doing wrong here, please suggest.
    Thanks,
    Venkatesh

    The problem you're experiencing is due to your JNDI configuration not matching the JavaDB database where you created the tables.
    If you look at the config for DerbyPool in the Admin Console, you'll see that DerbyPool points to:
    jdbc:derby://localhost:1527/sun-appserv-samples
    In the Admin Console click Resources->Connection Pools->DerbyPool, then click Additional Properties (9.1) or look at the page (9.0).
    You can either modify DerbyPool's config to point to:
    jdbc:derby://localhost:1527/BookDB
    Or you can create the tables in sun-appserv-samples. The create-tables ant task included with the Java EE 5 Tutorial will create the tables in the correct database.
    -ian

  • How to get One Selection Screen for all queries?

    Hi Experts,
    I have three queries having selection screens. All the selection screen have the same variables, but the reports are different.
    I have created a workbook having these three queries. Each time when the workbook opens, the three selection screen pops up one after the another. Same values are entered in all the selection screens.
    Now the user wants only one selection screen for all the three reports. Is it possible? I tried but I do not see any way.
    I think there should be some way of getting it done.
    Waiting for your inputs,
    With kind regards,
    Shreeem

    Hi
    If a workbook contains multiple queries that use the same variable, you are prompted to enter the variable values again for each query. To avoid this, set the Display Duplicate Variables Only Once flag.
    Goto Workbook Settings>Under Variables Tab>select Display Duplicate Variables only Once
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/54/a493f7256b43698191a2623e5a0532/frameset.htm
    Hope this helps,
    Aparna Duvvuri

  • Count number of rows for TWO QUERIES USING MINUS OPERATOR

    I have the following piece of sql, i would like to know how could i programatically using plsql count the number of rows returned by the following statement. I know that %ROWCOUNT returns the rowcount for the last execute INSERT, UPDATE, DELETE and SELECT INTO statement. Any help is much appreciated thanks.
    select *
    from admt1m4.usr@tcprod u
    where u.authoriztion = 'Omf99FullUsage'
    and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug where ug.left in
    (select obid from admt1m4.usrgrp@tcprod g 
    where g.participant not in ('super user grp', 't1_WbsPSAnalystGrp')))
    and u.activeuser = '+'
    MINUS
    select *
    from admt1m4.usr@TCPROD u
    where u.authoriztion = 'Omf99FullUsage'
    and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug
    where ug.usrgrpname in ('super user grp', 't1_WbsPSAnalystGrp'))
    and u.activeuser = '+'

    Hi,
    Have you tried
    SELECT COUNT (1) cnt
      FROM (SELECT *
              FROM admt1m4.usr@tcprod u
             WHERE u.authoriztion = 'Omf99FullUsage'
               AND u.obid IN (
                      SELECT RIGHT
                        FROM admt1m4.usrtogrp@tcprod ug
                       WHERE ug.LEFT IN (
                                SELECT obid
                                  FROM admt1m4.usrgrp@tcprod g
                                 WHERE g.participant NOT IN
                                          ('super user grp', 't1_WbsPSAnalystGrp')))
               AND u.activeuser = '+'
            MINUS
            SELECT *
              FROM admt1m4.usr@tcprod u
             WHERE u.authoriztion = 'Omf99FullUsage'
               AND u.obid IN (
                      SELECT RIGHT
                        FROM admt1m4.usrtogrp@tcprod ug
                       WHERE ug.usrgrpname IN
                                         ('super user grp', 't1_WbsPSAnalystGrp'))
               AND u.activeuser = '+')or your requirement is something else...
    *009*

Maybe you are looking for

  • Wifi connectioin help

    I am deployed to SWA and my 2012 MBP can't identiy my router as one of the network devices.  However, my Ipad and Iphone 4 can as of this morning.  Now my Ipone is not recognizing the WIFI...any help for a fix would be apreciated. 

  • Palm Pre2 email connection

    Hi, I have a Palm Pre2.  It accesses the internet every 10 minutes.  I think this is to check for new email and/or updates.  It is costing me £1.50 a day.  How do I turn it off?  I have a wi-fi connection at home.  I have set the phone up to connect

  • Running a Crystal Report in CF5

    Hello I have been asked to write an app to query a Sybase server and then run some reports, based on user input. I though about writing the reports in Crystal (I have Crystal Reports Professional 10) and then using Coldfusion (we use version 5 here :

  • Updating an App in Single Application Mode for Surface (Windows 8.1 RT)

    I have a Windows Store App running on a Surface (Windows 8.1 RT) in Kiosk Mode (Single Application Mode). I've put a new release out on the store for this Windows Store App. Is it possible for a Surface, running this app in kiosk mode, to automatical

  • Send message to parent html upon applet close

    Hi, I have an jsp page with applet included in the page. However, the applet opens as a separate frame. The applet has the functionality of capturing a photo from a camera connected to the computer and then displaying the captured photo back to the j