T-SQL Script to find the backup job details

Hi,
I have a requirement to get the below details:
1) Database Name
2) Backup Job Name
3) Database Type (Full/Differential/Log)
4) Recovery Model
5) Time of the SQL Backup Job.
Please help me in getting all these things in single query as I have to collate information from many queries to get the information. We have 100+ servers and need to update this information.
Thanks in advance!
Regards,
Sharath

DECLARE @db_name VARCHAR(100)
SELECT @db_name = DB_NAME()
SELECT TOP ( 30 )
s.server_name,
s.database_name,
CASE s.[type]
WHEN 'D' THEN 'Full'
WHEN 'I' THEN 'Differential'
WHEN 'L' THEN 'Transaction Log'
END as BackupType,
s.recovery_model,
s.backup_finish_date,
s.backup_start_date,
DATEDIFF(mi,s.backup_start_date , s.backup_finish_date)/60 as Total_Time_in_Hours,
cast(CAST(s.backup_size / 1024 / 1024 / 1024 AS INT) as varchar(14))
+ ' ' + 'GB' as bkSize,
CAST(s.first_lsn AS varchar(50)) AS first_lsn,
CAST(s.last_lsn AS varchar(50)) AS last_lsn,
m.physical_device_name
FROM msdb.dbo.backupset s
inner join msdb.dbo.backupmediafamily m ON s.media_set_id = m.media_set_id
WHERE s.database_name = @db_name
ORDER BY backup_start_date desc,
backup_finish_date

Similar Messages

  • Need to find the dependent object details for an object.

    Hi,
    Is there any query to find the dependent object details for any object. Like if mview is built on a table, then i should be able to find the table name with out checking code of the mview. Thanks in-advance for your support. similar way for view and functions or procedures etc...
    Regards
    DBA.

    Hi all,
    Thanks a lot for your inputs. seems i have not given full details in my post. I need to have a SQL Query to find the dependent object details not DDL.
    if i give a metriealized view name, i should get the base table names directly not DDLs...
    if i give index name i should get its corresponding table name(off course i got this already)...
    if i give a function name, i should get all the tables which are being in the function...etc...
    i am looking for a script which will cover all the aspects.....i hope i have given now enough information for this....
    Regards
    DBA.

  • Give SQL command to find the average annual salary per job in each department

    Give SQL command to find the average annual salary per job in each department pls help

    with
    data as
    (select empno,deptno,job,payday,1000 + trunc(500 * abs(dbms_random.normal)) + decode(deptno,10,500,11,200,12,100,0) salary
       from (select 1000 + trunc(dbms_random.value(10,100)) empno,
                    10 + floor(dbms_random.value(1,10) / 4) deptno,
                    decode(trunc(dbms_random.value(1,10)),1,'A',2,'B',3,'C',4,'D',5,'E',6,'F',7,'G',8,'H',9,'I','?') job
               from dual
             connect by level <= 17
            (select add_months(to_date(to_char(level),'mm'),-12) + 10 payday
               from dual
             connect by level <= 12
    select deptno,job,avg(salary) average_salary
      from data
    group by deptno,job
    order by deptno,job
    DEPTNO
    JOB
    AVERAGE_SALARY
    10
    B
    1812.83333333333333333333333333333333333
    10
    F
    2046.08333333333333333333333333333333333
    10
    G
    1877.45833333333333333333333333333333333
    10
    I
    2081.75
    11
    C
    1456.08333333333333333333333333333333333
    11
    E
    1654.91666666666666666666666666666666667
    11
    G
    1650.5
    11
    I
    1579.33333333333333333333333333333333333
    12
    A
    1580.58333333333333333333333333333333333
    12
    E
    1414.33333333333333333333333333333333333
    12
    H
    1380
    12
    I
    1404.83333333333333333333333333333333333
    Regards
    Etbin

  • Script to find the currently active sql

    hey,
    Can somebody post me a script to find the currently active sql in the database ???

    Hi,
    You can try these below:
    select s.username
           c1,t.sql_text
    from v$session s, v$sqltext t
    where
    s.sql_address = t.address and
    s.sql_hash_value = t.hash_value and
    s.username is not null
    order by s.username,s.prev_sql_addr,s.prev_hash_value,t.piece;
    or
    select sesion.sid,
           sesion.serial#,
           sesion.username,
           sesion.sql_id,
           sesion.sql_child_number,
           optimizer_mode,
           hash_value,
           address,
           sql_text
      from v$sqlarea sqlarea, v$session sesion
    where sesion.sql_hash_value = sqlarea.hash_value
       and sesion.sql_address    = sqlarea.address
       and sesion.username is not nullCheers

  • HELP !!! - sql script to find free space in Oracle7,8,9 DB

    Hi All
    I got a PL/SQL script to find out free space in Oracle7,8,9 db. But because in Oracle 7 there is no maxbytes column in dba_data_files, so this script is not working. I am trying to use cursor and putting sql in a variable so that when program executes, it does not see maxbytes. But it still does not work.
    Please help. !!!
    Script
    set feedback off;
    set serveroutput on;
    set termout off;
    set verify off;
    spool /u01/app/oracle/admin/common/bck/log/ts.log
    declare
    v_tablespace_name varchar2(50);
    v_total_space number(12) := 0;
    v_free_space number(12);
    v_space number(12);
    v_space_used number(12);
    v_pct_free number(6,3);
    v_pct_threshold number(3) := 2;
    v_table_exist number(2) := 0;
    v_sql varchar2(300) := 'select sum(maxbytes) from dba_data_files where TABLESPACE_NAME = tablespace_rec.tablespace_name';
    TYPE t_tableref IS REF CURSOR;
    t_tablecur t_tableref;
    begin
    for tablespace_rec in (select tablespace_name from dba_tablespaces)
    loop     
    -- Get the total space for the current tablespace
    -- if this FILEXT$ view exists then some of the datafiles have autoextend on;
              select count(*) into v_table_exist from dba_tables where table_name = 'FILEXT$';
              dbms_output.put_line('table count: ' || v_table_exist);               
              if v_table_exist = 0 then
                        OPEN t_tablecur for v_sql;
                        fetch t_tablecur into v_total_space;                         
                        CLOSE t_tablecur;     
              --     select sum(maxbytes) into v_total_space from dba_data_files
              --     where TABLESPACE_NAME = tablespace_rec.tablespace_name;               
              --      v_total_space := getMaxBytes(tablespace_rec.tablespace_name);
              end if;
              select sum(bytes) into v_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;          
         if (v_total_space = 0 or v_total_space < v_space) then
              select sum(bytes) into v_total_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
         else
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              v_space_used := v_space - v_free_space;
              v_free_space := v_total_space - v_space_used;          
         end if;
    -- calculate the percent free for the current tablespace
    v_pct_free := (v_free_space / v_total_space) * 100;
         if (v_pct_free < v_pct_threshold) then
         dbms_output.put_line(tablespace_rec.tablespace_name|| ' - Percent Free: ' || v_pct_free      
         ||'%');
         end if;
    end loop;
    end;
    spool off;

    Hi All
    I got a PL/SQL script to find out free space in Oracle7,8,9 db. But because in Oracle 7 there is no maxbytes column in dba_data_files, so this script is not working. I am trying to use cursor and putting sql in a variable so that when program executes, it does not see maxbytes. But it still does not work.
    Please help. !!!
    Script
    set feedback off;
    set serveroutput on;
    set termout off;
    set verify off;
    spool /u01/app/oracle/admin/common/bck/log/ts.log
    declare
    v_tablespace_name varchar2(50);
    v_total_space number(12) := 0;
    v_free_space number(12);
    v_space number(12);
    v_space_used number(12);
    v_pct_free number(6,3);
    v_pct_threshold number(3) := 2;
    v_table_exist number(2) := 0;
    v_sql varchar2(300) := 'select sum(maxbytes) from dba_data_files where TABLESPACE_NAME = tablespace_rec.tablespace_name';
    TYPE t_tableref IS REF CURSOR;
    t_tablecur t_tableref;
    begin
    for tablespace_rec in (select tablespace_name from dba_tablespaces)
    loop     
    -- Get the total space for the current tablespace
    -- if this FILEXT$ view exists then some of the datafiles have autoextend on;
              select count(*) into v_table_exist from dba_tables where table_name = 'FILEXT$';
              dbms_output.put_line('table count: ' || v_table_exist);               
              if v_table_exist = 0 then
                        OPEN t_tablecur for v_sql;
                        fetch t_tablecur into v_total_space;                         
                        CLOSE t_tablecur;     
              --     select sum(maxbytes) into v_total_space from dba_data_files
              --     where TABLESPACE_NAME = tablespace_rec.tablespace_name;               
              --      v_total_space := getMaxBytes(tablespace_rec.tablespace_name);
              end if;
              select sum(bytes) into v_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;          
         if (v_total_space = 0 or v_total_space < v_space) then
              select sum(bytes) into v_total_space from dba_data_files
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
         else
              select sum(bytes) into v_free_space from dba_free_space
              where TABLESPACE_NAME = tablespace_rec.tablespace_name;
              v_space_used := v_space - v_free_space;
              v_free_space := v_total_space - v_space_used;          
         end if;
    -- calculate the percent free for the current tablespace
    v_pct_free := (v_free_space / v_total_space) * 100;
         if (v_pct_free < v_pct_threshold) then
         dbms_output.put_line(tablespace_rec.tablespace_name|| ' - Percent Free: ' || v_pct_free      
         ||'%');
         end if;
    end loop;
    end;
    spool off;

  • Script to find the Concurrent Request ID from its associated SID

    Hi,
    In one of my production system, my server load is going very high. From the top used process ID of server, I found the SID and found out that the program running is "ora_rw20_run@acgerp (which is a concurrent program)
    How do I find out the Request ID using the SID/PID? Can someone please provide me the script to find the Concurrent Request ID from its associated SID?
    Thanks!

    There has been no new changes in the report server or in the database. Suddenly of late, we have been observing this program running and it never ends, consuming major part of the cpu load. Not sure what this program is -> ora_rw20_run. There is no mention about it in metalink or in google.
    I followed MOS Doc 1058210.6 and tried to debug more. But the formatted output doesnt give any info either.
    TKPROF: Release 10.2.0.2.0 - Production on Tue Oct 20 09:44:21 2009
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Trace file: prod_ora_15721.trc
    Sort options: default
    count = number of times OCI procedure was executed
    cpu = cpu time in seconds executing
    elapsed = elapsed time in seconds executing
    disk = number of physical reads of buffers from disk
    query = number of buffers gotten for consistent read
    current = number of buffers gotten in current mode (usually for update)
    rows = number of rows processed by the fetch or execute call
    0 statements EXPLAINed in this session.
    Trace file: prod_ora_15721.trc
    Trace file compatibility: 10.01.00
    Sort options: default
    1 session in tracefile.
    0 user SQL statements in trace file.
    0 internal SQL statements in trace file.
    0 SQL statements in trace file.
    0 unique SQL statements in trace file.
    96507 lines in trace file.
    0 elapsed seconds in trace file.
    When I use the below query, I can find that the session is running a module named "PAXMGSLS" and the action is Concurrent Request.
    But I am not sure how to find out the Concurrent Request ID using this info to dig more (look into the concurrent request log files etc)
    select s.sid,s.serial#,p.spid os_pid,s.status,
    s.osuser,s.username,s.COMMAND,s.MACHINE,s.MODULE, s.SCHEMANAME,
    s.LOCKWAIT,s.action
    from v$session s, v$process p
    WHERE s.paddr = p.addr
    and s.sid = 823
    SID     SERIAL#     OS_PID     STATUS     OSUSER     USERNAME     COMMAND     MACHINE     MODULE     SCHEMANAME     LOCKWAIT     ACTION
    823     47     4559     ACTIVE     applprod     APPS     3     acgerp     PAXMGSLS     APPS          Concurrent Request

  • I backup my iphone on my pc and copy backup file into drive D then i setup new OS on my pc. after that i copy the backup file into itunes backup folder but itunes can't find the backup file to restore my iphone. how can i restore my iphone?

    i backup my iphone on my pc and copy backup file into drive D then i setup new OS on my pc. after that i copy the backup file into itunes backup folder but itunes can't find the backup file to restore my iphone. how can i restore my iphone?

    Don't you just love changes in interfaces?
    I found the answer to my question.
    When you attach a device (iPhone, iPad) to your Mac, in iTunes 12 in appears as a tiny icon in the second "row" of the iTunes display. Click the icon and the familiar iTunes display for the device appears. From there, on the Summary screen, you can see the dates of the backups of the device (iCloud and backup to the computer). You can also use the button to backup to the computer.

  • My back up from last Thursday on my iphone 4s is not showing up in my itunes. I deleted something today & I would like to restore to last week when it was on my phone. How do I find the backup on my pc, how do I move it to itunes to restore phone back to

    My back up from last Thursday on my iphone 4s is now showing up in my itunes. I deleted something today and I need it back desperately. I need to restore my phone back to last Thursday when the information was on my phone. How do I find the backup on my pc and once I find it how do I move it to itunes for me to restore my phone to that day?

    I wished I had known this before I said yes to using icloud. I guess those things will be lost and gone forever, since I do not want to lose my present settings and data. Also do not want to go through the hassle of backing up present, then resetting phone, then restoring oldest back up, then backing up oldest backup to pc, so I can safely backup selected items to my pc; then reset my phone again to restore latest back up. It would take way too much time and no guarantee.
    I backed up my phone to my pc, but have not checked it yet, so don't know if it worked.
    If I decide to quit using icloud (which will probably happen since backing up to external hard drive allows me to open backups) what will happen to my present data and settings? Will they just remain as they were without icloud, as they were before icloud? I'm scared to just delete it; not knowing what will happen. Also why is icloud now my outgoing mail server, when my web email was before I installed icloud and how do I restore my web email as my outgoing mail server. I am using yahoo/at&t for all my mail.
    What will happen to my contacts, notes, messages, voice memos, calendar info, alerts, etc., on my phone if I delete icloud?

  • VB Script to find the last modified file and time in a directory

    Hi,
    I am new to VB script i need a script to find the latest modifed file and last modifed time in a directory(Contains  folders and sub folders inside it). it has to go through all the folders and get the latest file and last modifed time.

    Thanks it worked for me Get-ChildItem C:\Users\sujith.reddy.komma\Desktop\Suj1\* -recurse |?{-not $_.PsIsContainer} |Sort LastWriteTime -desc | select -first 1 now in my script i have hard coded the directory i need to run this script in different
    servers from one location i will put all the different paths in one text file and ineed to pass them to this script can you help me with this?
    Essentially you are incrementally asking us to write each line for you.  I recommend freeing yourself of this misery and leraning PowerShell.  THe answers to all of your questions are learned in the first few hours of study.
    Start here:
    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
    ¯\_(ツ)_/¯

  • Sql query to find the balances for a customer account wise.

    Hi,
    Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
    presently we are using this query, but the output doesnot return the expected result.
    SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
    FROM      ra_cust_trx_line_gl_dist_all gld,
              gl_code_combinations c,
              ar_payment_schedules_all ps,
              RA_CUSTOMER_TRX_ALL rat,
              ra_customers rc
    WHERE      c.CHART_OF_ACCOUNTS_ID = 101
    and gld.code_combination_id = c.code_combination_id
         and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
         and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
    and ps.customer_id=rc.customer_id
         and ps.status='OP'
         and ps.gl_date <= :PDATE
         and ps.org_id=:PORGID
         and ps.class in ('GUAR','INV','DM','DEP')
    and c.SEGMENT4=:Account_id
    and ps.customer_id=:Customer_id
    Thanks in advance.
    Kalyan.

    Can someone help us with this.

  • Can anybody provide the SQL query to find the files uploaded in a particular folder?

    Hi All,
    Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
    GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
    Any help is greatly appreciated.
    With best regards,
    Nevin

    Nevin,
    Be great if we could know the version of Portal. For Rel. 1, here's the query
    select id,masterthingid from wwv_things
    where siteid = &site
    and cornerid = &corner
    &site - Content Area id
    &corner - Folder id
    if you don't know the folder id, use
    select id from wwv_corners where siteid = &site
    and name = &folder
    Hope this helps. I have run into this situation before. Usually, the culprits were
    one of the following:
    1. Junk Characters in description of item (caused due to Copy-Paste)
    2. Special Characters in the File name
    Hi All,
    Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
    GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
    Any help is greatly appreciated.
    With best regards,
    Nevin

  • SQL Query to find the Notify upon Completion employees

    Hi,
    I am looking for a query to find the names of the employees/users who are notified upon the completion of the Concurrent Programs. I know how to find the concurrent program details but not able to find notify upon completion employees details. Please help me.
    Thanks,
    KM

    Thanks Scott for responding. There is no any custom code. Here is the navigation to reach there:
    System Administrator -> Requests -> View -> Specific Requests -> Open any request ->View Details -> Options -> Notify the following people
    I am looking for the query to find these notified people using SQL Query.Query FND_CONCURRENT_REQUESTS table (NOTIFY_ON_PP_ERROR column) -- http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE
    Thanks,
    Hussein

  • HT1414 I am still on Snow Leopard 10.6.8 and do not have iCloud in my System Preferences. I have registered with iCloud online and backed up my iphone5 last night to my iMac. Where can I find the backup on my iMac?

    I am still on Snow Leopard 10.6.8 and do not have iCloud in my System Preferences. I have registered with iCloud online and backed up my iphone5 last night to my iMac. Where can I find the backup on my iMac?
    Below is what comes up when I sign into iCloud - where are all the other applications that I need to backup?
    Appreciate any answers to this query?
    Rachel

    Your question is unclear.  If you're backing up to your iMac, (via iTunes, with cable or WiFi), this has nothing to do with iCloud and the backup is stored on your iMac here:
    : ~/Library/Application Support/MobileSync/Backup/

  • 11G R2 How to stop the backup job totally

    I have a third party application connected to 11G R2 database and is having issue every morning at 2. After applying the patch from the third part application, most of the issues are resolved. Unfortunately, I still get an ORA-12528 error - Failed to connect to database instance. Look like the third party application is having issue with the backup job. I have tried the command "alter tablespace tsname flashback off", but I check the alert log, the backup job is still running. I may have turn on the backup job during the database installation. How do I stop it?
    Thanks for any help!
    - Johnny

    Sorry, I forgot to add "alter database flashback off "command on top of the other one. The third party application is basically a monitoring and scheduler tool. It uses JBOSS and TOMCAT connecting to the database using both jdbc and odcb. It doesn't store a lot of data. Here is the alert email I got this morning:
    Target Name=MEDIAMGR
    Target Type=Database Instance
    Host=mediamgr2-db
    Metric=Status
    Metric Value=0
    Timestamp=Jan 4, 2012 2:01:12 AM PST
    Severity=Critical
    Message=Failed to connect to database instance: ORA-12528: TNS:listener: all appropriate instances are blocking new connections (DBD ERROR: OCIServerAttach).
    Notification Rule Name=Database Availability and Critical States
    Notification Rule Owner=SYSMAN
    Notification Count=1
    as for backup, I have already disabled the archive logs and flashback database. A few minutes ago, I just turn off RMAN autoback. What else can I turn off related to backup?
    Thanks,
    - Johnny

  • How do I backup my iphone to a computer when every time I plug it into the computer, it starts syncing it to itunes or trying to download itunes?  How do I back it up and where do I find the backup?

    How do I backup my iphone to a computer when every time I plug it into the computer, it starts syncing it to itunes or trying to download itunes?  How do I back it up and where do I find the backup?

    The backup does not include any itunes content. NO apps, music,etc
    You can transfer itunes purchases from iphone to computer:  File>Transfer Purchases
    You need to copy everything from your backup copy of your old computer to your new computer.

Maybe you are looking for