Script that will help validate if there is any data loss after a DB restore

Hi,
I need to write a single script that will perform the following
operations:
1)return me the highy accessed tables across all databases.
2)List the count, Min and Max system date of the highy accessed tables returned from step 1.
The idea is to validate if there is any data loss to the highly transactional tables after a database restore operation has been performed.
Thanks.

Hello,
I would also like you to see nice blog by Aron,you can modify the script a bit to change according to your need
http://sqlblog.com/blogs/aaron_bertrand/archive/2008/05/06/when-was-my-database-table-last-accessed.aspx
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
Hello Shanky,
The post would not be helpful too much for OP's requirement. The post was talking about when was the database last accessed. DMLs are not capturing in the script and also there will be many variant forms that can be applied for DML. Hence, I do not think,
the script would help too much. 
Or Am I missing something? 
Latheesh as i mentioed OP has to modify the script little bit may be add User_seek,user_update,user_scans.Still IMO there is no *perfect* way to actually analyze this.So I pointed out point in my original post.Also unless he has some timestamp he cannot
see min time when it was accessed ,max time can be taken from last user seek,scan,lookup time. Motive was to lethim know what he was trying to achieve cannot be axactly obtained by using sys.dm_index_usage_stats.Below query will give most accessed table
: Source (Query)
SELECT
t.name AS 'Table',
SUM(i.user_seeks + i.user_scans + i.user_lookups)
AS 'Total accesses',
SUM(i.user_seeks) AS 'Seeks',
SUM(i.user_scans) AS 'Scans',
SUM(i.user_lookups) AS 'Lookups'
FROM
sys.dm_db_index_usage_stats i RIGHT OUTER JOIN
sys.tables t ON (t.object_id = i.object_id)
GROUP BY
i.object_id,
t.name
ORDER BY [Total accesses] DESC
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

Similar Messages

  • Is there an AppleScript or Automator Script that will wake a Mac from Sleep?

    Is there an AppleScript or Automator Script that will wake a Mac from Sleep?

    Frank and All,
    The following answer to your question above is complicated, but I hope it explains why my question was formed with so much frustration in it.
    I have an OpenOffice(OO) Macro that was launched with Calendar at 6pm each business night. It ran properly in all Apples operating systems until I Hit Maverick(OSX10.9). From then on, the AppleScript would run from one to 3 days, then would disappear from the Calendar entry. The Calendar alert would still run, but the "OpenFile" section of the alert would disappear. I also was running elgato EyeTV HD during the day, so I would use energy saver to put my MacBook Pro to sleep at 12 Midnight and wake it again at 9am. I picked up a used Mac Mini to do the EyeTV stuff, provide AppleTV the files in H264 format through iTunes' media share, and found it had plenty of power to do the 6pm automated stuff simultaneously as well. Because I still wanted to run the OpenOffice Macro on my MacBook Pro at 6pm, and wanted to use it for a host of other things when I was on the road, I wanted it to sleep most of the time and only wake up automatically to run the 6pm OO Macro. When I called Apple about the issue I was having with Maverick and Calendar loosing the OpenFile command as part of the Alert Message, they told me the no longer supported answering AppleScript Questions but they now would support Automator questions. I pointed out that the OpenFile would also fail after one to three days if I used a Calendar Alert to launch an Automator App. At first, I did not like Automator, but now I see why Apple is pushing us to use it. Automator adds a TIME STAMP ID to the Apps developed in Automator so the first time you launch the App after a change to it, you must reply to a dialog message saying that this is the first time you are running this version of the App. If a Scammer has replaced your app with one that can reek havoc on your computer, the replacement app will not run unless you are there to agree that you know where the modified app came from and click the OK button to continue (BRILLIANT, Enhanced Security idea on Apples part). I also noticed that after Mountain Lion, the Applescript delay timing was all screwed up as well. Well I tried to use LaunchD Task Scheduler to circumvent the Calendar Problem and that worked until I upgraded to Yosemite Last week. Then LaunchD no longer worked and I am only into a few days of using The Calendar Launched Automator App to see if it will continue to run.
    But I think I solved the dilemma I was having with opening an Automator App in a Sleeping Mac. I Googled up the following question, "AppleScript to wake up computer".  I went thru several complex responses until I found this on that is INCREDIBLE EASEY! What came back was a brettterpstra.com  response from Feb 20th,2014. What it said, in a Quick Tip: caffeinated your Terminal Article,  if you wanted to wake a Mac from sleep, use the Terminal command named "Caffeine -u -t 1". I placed it in an Automator Most Used Action called "Run Shell Script -- Caffeine -u -t 1" and it worked!  Now, I can put my Mac to Sleep but at 6pm, the Automator App will launch, run the "Caffeine -u- -t 1" command and proceed to work as if I had awakened the Mac From Sleep mode by pressing a keyboard key and had run the Automator Script with a double click.
    Sorry for the long, drawn-out reply, but maybe this will help others.

  • My MacBook Pro is running very hot after lion install.  Are there any hardware changes that will help? What can I do to get it back to normal?

    My MacBook Pro is running very hot after lion install.  Are there any hardware changes that will help? What can I do to get it back to normal?

    I get the impression that most of the users on older hardware experiences similar temperature issues on Lion for a long time now. Awaiting for confirmation from the original poster.
    In the meantime I'm just cautious with regards to pushing the machine to such extreme temps, since something tells me such behaviour which includes monitor flickering and the likes is nothing but abnormal for any type of use...
    Any clues if 10.7.5 does anything on this? If not I'm afraid i see myself going back to SL for good...

  • My iphone 5 is not syncing with my laptop and windows 8. cant find an itunes app for my laptop. is there something i can get that will help with this

    My iphone 5 is not syncing with my laptop and windows 8. cant find an itunes app for my laptop. is there something i can get that will help with this?

    Lbo51380 wrote:
    cant find an itunes app for my laptop. is there something i can get that will help with this?
    Go here -> http://www.apple.com/itunes/download/

  • Just for my own privacy i would like to set up a password or pin number on my messgae app is there anything out there that will help me do this please comment if there is a possible solution out there

    Just for my own privacy i would like to set up a password or pin number on my messgae app is there anything out there that will help me do this please comment if there is a possible solution out there. I know alot may say what you have to hide but ive got nothing to hide i just want one on there so my privacy is not broken by friends and family if they fancy playing on my phone and having a snoop round my phone.

    If you visit these forums often, you will read about the 2 year old child who accidentally wiped out the parents phone, the kid who set a passcode and didn't remember what it was, etc etc etc
    Passcode your device.   Protect your device.   It really isn't a toy.    The toy is the iPod touch.

  • Is there a tutorial that will help in creating a RS232 driver?

    I am attempting to write a driver / VI that will control an Animatics "SmartMoter" via a RS232 port.  I was able to download sub VI's from www.summerfiles.com. 
    Is there a tutorial that will help in creating a driver for a RS232 port?  I take it that I will need to connect these sub vi's in a correct sequence to be able to communicate through the RS232 port.
    Thanks,
    Bill

    It seems that what you downloaded is a driver. What you need to determine is how to use the functions on the driver to create a high level application. There is a tutorial at http://zone.ni.com/devzone/cda/tut/p/id/2804 that might be useful. The driver you downloaded is lacking in several areas. One of which is documention. Each VI should include a description of what it is and what it does. Each control/indicator should also include a description. I could not find any such information in these VIs. I didn't look at everything because the horrid front panel colors in the SmartMotor.llb was giving me a headache. I did see a VI called SM Tester. This appears to be a high level example that you could use as a model.

  • I need a script that will find the computer a user last logged into.

    I am still learning scripting, I need a script that will allow me to pull in usernames from a csv file. Find what computer they last logged into and output that to an csv file.
    I have looked all over and can't find exactly what I need.
     I found the following script but I need  to add the resuitsize unlimited but can not figure out where to put it we have a large environment. Also I need to be able to grab username from a csv file. Any assistance you can provide is appreciated.
    ##  Find out what computers a user is logged into on your domain by running the script
    ##  and entering in the requested logon id for the user.
    ##  This script requires the free Quest ActiveRoles Management Shell for Active Directory
    ##  snapin  http://www.quest.com/powershell/activeroles-server.aspx
    Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
    $ErrorActionPreference = "SilentlyContinue"
    # Retrieve Username to search for, error checks to make sure the username
    # is not blank and that it exists in Active Directory
    Function Get-Username {
    $Global:Username = Read-Host "Enter username you want to search for"
    if ($Username -eq $null){
    Write-Host "Username cannot be blank, please re-enter username!!!!!"
    Get-Username}
    $UserCheck = Get-QADUser -SamAccountName $Username
    if ($UserCheck -eq $null){
    Write-Host "Invalid username, please verify this is the logon id for the account"
    Get-Username}
    get-username resultsize unlimited
    $computers = Get-QADComputer | where {$_.accountisdisabled -eq $false}
    foreach ($comp in $computers)
    $Computer = $comp.Name
    $ping = new-object System.Net.NetworkInformation.Ping
      $Reply = $null
      $Reply = $ping.send($Computer)
      if($Reply.status -like 'Success'){
    #Get explorer.exe processes
    $proc = gwmi win32_process -computer $Computer -Filter "Name = 'explorer.exe'"
    #Search collection of processes for username
    ForEach ($p in $proc) {
    $temp = ($p.GetOwner()).User
    if ($temp -eq $Username){
    write-host "$Username is logged on $Computer"

    If you are querying by user "resultset size" will be of no use.
    You also have functions that are never used and the body code doe snot look for users.
    Here is what you scrip looks like if printed well.  It is just a jumble of pasted together and unrelated items.
    ## Find out what computers a user is logged into on your domain by running the script
    ## and entering in the requested logon id for the user.
    ## This script requires the free Quest ActiveRoles Management Shell for Active Directory
    ## snapin http://www.quest.com/powershell/activeroles-server.aspx
    Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
    $ErrorActionPreference = "SilentlyContinue"
    # Retrieve Username to search for, error checks to make sure the username
    # is not blank and that it exists in Active Directory
    Function Get-Username {
    $Global:Username = Read-Host "Enter username you want to search for"
    if ($Username -eq $null) {
    Write-Host "Username cannot be blank, please re-enter username!!!!!"
    Get-Username
    $UserCheck = Get-QADUser -SamAccountName $Username
    if ($UserCheck -eq $null) {
    Write-Host "Invalid username, please verify this is the logon id for the account"
    Get-Username
    get-username resultsize unlimited
    $computers = Get-QADComputer | where { $_.accountisdisabled -eq $false }
    foreach ($comp in $computers) {
    $Computer = $comp.Name
    $ping = new-object System.Net.NetworkInformation.Ping
    $Reply = $null
    $Reply = $ping.send($Computer)
    if ($Reply.status -like 'Success') {
    #Get explorer.exe processes
    $proc = gwmi win32_process -computer $Computer -Filter "Name = 'explorer.exe'"
    #Search collection of processes for username
    ForEach ($p in $proc) {
    $temp = ($p.GetOwner()).User
    if ($temp -eq $Username) {
    write-host "$Username is logged on $Computer"
    I suggest finding the original code then use the learning link at the top of this page to help you understand how it works in Powershell.
    ¯\_(ツ)_/¯

  • IDCS6(MAC) 10.9.4 - a script that will make an anchored object and paste in clipboard contents

    I'm trying to create a script that will create an anchored object that will paste in clipboard contents.
    So far I have:
    var frameRef = app.selection[0];
        var parentObj = frameRef.insertionPoints.item(0);
        var anchorFrame = parentObj.rectangles.add();
    And this works fine, creating an inline object, that can further be defined (with anchor point settings etc).
    However, it is when I go to use app.paste() or app.pasteInto() that all hell breaks loose.
    The line of code I added was:
    anchorFrame.content = app.pasteInto();
    and the error I get is:
    What am I doing incorrectly?
    Colin

    @Colin – For the paste command you like to use, you have to:
    1. First select an object, in your case the added rectangle object
    2. Then use the pasteInto() method from the app object
    3. There is no content property for a rectangle object
    Watch out what is selected after you added the rectangle.
    What you have is a selection of the text frame when you start your code in line one.
    Adding a rectangle will not change that selection.
    The following code will do the job.
    However, if you use pasteInto() the pasted objects could be only partly visible inside the frame.
    Depends on the size and position of the added rectangle relative to the original copied page items.
    Make sure that you give the rectangle a proper size after or while you are adding it:
    var frameRef = app.selection[0];
    var parentObj = frameRef.insertionPoints.item(0);
    //Will add a rectangle sized 40 x 40 mm
    var anchorFrame = parentObj.rectangles.add({geometricBounds:[0,0,"40mm","40mm"]});
    app.select(null); //Optional
    app.select(anchorFrame);
    app.pasteInto();
    Uwe

  • "A script that will delete perfstat snapshots older than 90 days with SPPURGE..."

    Hello to all my fine Oracle related friends...We are all one large extended Family...
    I want to create a script that will execute SPPURGE on Perfstat for snapshots that are older than 90 days.
    Now, I have Grid 12c Cloud Control up and running for all the Databases that we have...
    Should I use Grid 12c to execute the SPPURGE and just pass the parameters in like that?
    Or should I go "Old School" and make a Shell Script and schedule it in the crontab?
    What would you guys do?
    I want implement this for 41 "Standard Edition" Databases....some are "Data Guard".....
    Thanks,
    Xevv.

    Xevv Bellringer wrote:
    Hi Ed,
    I tried executing this manually and it's not deleting the snapshots at all.
    begin
    statspack.purge(trunc(sysdate-90),true);
    end;
    I even let it for an entire day and then altered the code like this...But when I execute it, it doesn't deleted the data..
    begin
    statspack.purge(trunc(sysdate-1),true);
    end;
    When I do a select sysdate -1 from dual; it gives the correct date?
    Could there be a "NLS Setting" some where causing this?
    How do you determine that it is not deleteding data?  (please show evidence)
    How, and how often, are you collecting a statspack snapshot?  (please show evidence)

  • I have an ipod touch 2nd generation, i'm trying to get apps that will work and i cant find any. Its says i need an update because it has ios 3.1.3 , but on itunes it says there is no update ? what apps can i get??

    i have an ipod touch 2nd generation, i'm trying to get apps that will work and i cant find any. Its says i need an update because it has ios 3.1.3 , but on itunes it says there is no update ? what apps can i get??

    Sounds like you actually have a 1st generation as those cannot update beyond iOS 3.1.3.
    Model Identifier Utility
    rachelfromnorthumberland wrote:
    what apps can i get??
    Finding iOS Apps Compatible with Older Devices

  • Is there a system table or V$ view that will show a user's last logon date?

    Is there a system table or V$ view that will show a user's last logon date?
    I'm using Oracle 9.2.0.7

    sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 31 12:44:42 2010
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Enter user-name: / as sysdba
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> desc user$
    Name                            Null?    Type
    USER#                            NOT NULL NUMBER
    NAME                            NOT NULL VARCHAR2(30)
    TYPE#                            NOT NULL NUMBER
    PASSWORD                             VARCHAR2(30)
    DATATS#                       NOT NULL NUMBER
    TEMPTS#                       NOT NULL NUMBER
    CTIME                            NOT NULL DATE
    PTIME                                  DATE
    EXPTIME                             DATE
    LTIME                                  DATE
    RESOURCE$                       NOT NULL NUMBER
    AUDIT$                              VARCHAR2(38)
    DEFROLE                       NOT NULL NUMBER
    DEFGRP#                             NUMBER
    DEFGRP_SEQ#                             NUMBER
    ASTATUS                       NOT NULL NUMBER
    LCOUNT                        NOT NULL NUMBER
    DEFSCHCLASS                             VARCHAR2(30)
    EXT_USERNAME                             VARCHAR2(4000)
    SPARE1                              NUMBER
    SPARE2                              NUMBER
    SPARE3                              NUMBER
    SPARE4                              VARCHAR2(1000)
    SPARE5                              VARCHAR2(1000)
    SPARE6                              DATE

  • I have a dvd that will not eject, is there a way of manually getting it out?

    I have a dvd that will not eject, is there a way of manually getting it out?

    Reboot while holding the mouse key (or trackpad) down. Also see this thread.

  • I have an iMac 27" which is 4  years old and probably overdue for a clean-up. Is there any good reliable software out there that would help? Has anyone had any experience of 'Mackeeper'?

    I have an iMac 27" which is 4  years old and probably overdue for a clean-up. Is there any good reliable software out there that would help?
    Has anyone had any experience of 'Mackeeper'?

    Check how many applications are starting when you log in, I found that if there was a lot of activity at login Finder did not display the icons on the desktop correctly, again like you it did not occur at every login, just occasionally.
    For Safari have you tried resetting Safari, if that does not help you could disable plugins and extensions one at a time. You may find one of those is causing the problem.

  • Simple script that will export the coordinates (layer bounds - top left x,y)

    Hi,
    I'm looking for a simple script that will export the coordinates (layer bounds - top left x,y) of the layers to an seperate xml/txt file.

    Your screen capture looks like it's from Photoshop.
    In InDesign sub layers are page items, the containing layer has no dimension. So you could get all the page item's x, y, width, height. But you might have to consider groups and then the layering could be very complex. The stacking order could also get complex. Page items have an index, but it's relative to its parent container.

  • Will there be any data deleted if i upgrade my software version?

    will there be any data deleted if i upgrade my software version?

    what are you updating?  But the short answer is no.  whether an iOS device or a Mac you should't "lose" anything.  the only problems you might run into are compatibility issues with software not being able to run on newer system software....ie.  upgrading to OSX LION means no more PPC apps anymore.  

Maybe you are looking for