T-SQL for finding the unused tables which are consuming maximum disk space.

Hi,
Need help in writing a T-SQL that can return me the unused or least used tables in a database and are consuming a lot of disk space.
Thanks  

Refer
http://gallery.technet.microsoft.com/SQL-List-All-Tables-Space-baf0bbf9
create table #TableSize (
Name varchar(255),
[rows] int,
reserved varchar(255),
data varchar(255),
index_size varchar(255),
unused varchar(255))
create table #ConvertedSizes (
Name varchar(255),
[rows] int,
reservedKb int,
dataKb int,
reservedIndexSize int,
reservedUnused int)
EXEC sp_MSforeachtable @command1="insert into #TableSize
EXEC sp_spaceused '?'"
insert into #ConvertedSizes (Name, [rows], reservedKb, dataKb, reservedIndexSize, reservedUnused)
select name, [rows],
SUBSTRING(reserved, 0, LEN(reserved)-2),
SUBSTRING(data, 0, LEN(data)-2),
SUBSTRING(index_size, 0, LEN(index_size)-2),
SUBSTRING(unused, 0, LEN(unused)-2)
from #TableSize
select * from #ConvertedSizes
order by reservedKb desc
drop table #TableSize
drop table #ConvertedSizes
--Prashanth

Similar Messages

  • Is there a way to find the temporary table that are created or read during?

    Hi All,
    I'm working on performance optimization where I have to find the temporary tablespaces that are created or read during runtime? Is there any way to find it?
    Can you please also tell me how the temporary tables are created? And after each run time whether the data is getting deleted or the whole table is getting deleted?
    Whether these tables are created only during runtime? What are the naming conventions for all the temporary tables that are created?
    Is the table creation has anything to do with Delta or Full load?
    Regards,
    Kartik

    Stephen Tyler Bloom wrote:
    When they come out with the next garageband, they should add that feature .
    be sure to let Apple know:
    http://www.bulletsandbones.com/GB/GBFAQ.html#sendfeedback
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • How to find the unused tables in a schema

    Hi All,
    I have a schema in my database in which some of my web portals runs. I have n number of tables in the schema but I beleive some of the tables which are not using for a long. How do I find those or list those tables which are not using for long?
    Please help,
    -Thanks & Cheers
    Antony

    Although your question is directed to Aman, I want to let you know that auditing "will" affect the performance of the database. And auditing will catch select statements too even using "successful and nonsuccessful" selects
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to find the new tables and columns in a schema

    hi..good morning to all...
    I have a schema ABC which owns some objects.
    Now some days before I have made another schema XYZ which was a replica of ABC schema.
    between these days some new tables, new columns in the existing tables(with or without default value), comments on the columns are being added in the new schema i.e XYZ schema.
    Now I have to find the extra things which are present in the new schema. I need to find the new tables, new columns in hte existing tables, their default values and descriptions of those.
    Can u plss help me how can I find it?
    I am guessing that I have to write a SQL query with a minus clause but I am not able to write it and also dont know where should I execute it.
    plss help. thanks in advance.

    And moreover, when I am executing the query to get the desired result, then it is throwing "illegal use of long datatype" error and pointing to the b.data_default area of my query..
    select a.table_name, a.column_name, b.data_default, a.comments from all_col_comments a, dba_tab_columns b
    where a.TABLE_NAME=b.TABLE_NAME
    and a.OWNER=b.OWNER
    and a.OWNER=XYZ
    minus
    select c.table_name, c.column_name, d.data_default, c.comments from all_col_comments c, dba_tab_columns d
    where c.TABLE_NAME=d.TABLE_NAME
    and c.OWNER=d.OWNER
    and c.OWNER='ABC'
    order by 1, 2;
    plss help...

  • SQL for finding chunk or no keyboard values

    Hi all ,
    I have table where users are allowed to enter data from excel sheet but while viewing it in application due to non key board values are like ¶,     ã, £
    the validation getting failed and values are not loaded kindly help me in finding those non key board values , as data has been already loaded i need to find the data with non key board values .
    i have written the query for one values but i need to find it for all the other values which are not part of key board
    select * from note where text like '%'|| chr(1) ||'%';

    879380 wrote:
    Hi all ,
    I have table where users are allowed to enter data from excel sheet but while viewing it in application due to non key board values are like ¶,     ã, £
    the validation getting failed and values are not loaded kindly help me in finding those non key board values , as data has been already loaded i need to find the data with non key board values .
    SELECT  REGEXP_REPLACE
              (column_name,
               '[qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM ,./?;:''"{}1234567890=!@#$%^&*()_+\|`~-]+'
              ) non_keyborad_symbol_exists
      FROM table_name ;
    Cheers!

  • How to process each records in the derived table which i created using cte table using sql server

    I want to process each row from the CTE table I created, how can I traverse from first row to second row and so on....
    how to process each records in the derived table which i created using  cte table using sql server

    Ideally you would be doing a set based processing rather than traversing row by row as thats more efficient. To answer it specific to your scenario we may need more info. Can you explain with some sample data your exact requirement?
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Can we implement the custom sql query in CR for joining the two tables

    Hi All,
    Is there anyway to implement the custom sql query in CR for joining the two tables?
    My requirement here is I need to write sql logics for joining the two tables...
    Thanks,
    Gana

    In the Database Expert, expand the Create New Connection folder and browse the subfolders to locate your data source.
    Log on to your data source if necessary.
    Under your data source, double-click the Add Command node.
    In the Add Command to Report dialog box, enter an appropriate query/command for the data source you have opened.
    For example:
    SELECT
        Customer.`Customer ID`,
        Customer.`Customer Name`,
        Customer.`Last Year's Sales`,
        Customer.`Region`,
        Customer.`Country`,
        Orders.`Order Amount`,
        Orders.`Customer ID`,
        Orders.`Order Date`
    FROM
        Customer Customer INNER JOIN Orders Orders ON
            Customer.`Customer ID` = Orders.`Customer ID`
    WHERE
        (Customer.`Country` = 'USA' OR
        Customer.`Country` = 'Canada') AND
        Customer.`Last Year's Sales` < 10000.
    ORDER BY
        Customer.`Country` ASC,
        Customer.`Region` ASC
    Note: The use of double or single quotes (and other SQL syntax) is determined by the database driver used by your report. You must, however, manually add the quotes and other elements of the syntax as you create the command.
    Optionally, you can create a parameter for your command by clicking Create and entering information in the Command Parameter dialog box.
    For more information about creating parameters, see To create a parameter for a command object.
    Click OK.
    You are returned to the Report Designer. In the Field Explorer, under Database Fields, a Command table appears listing the database fields you specified.
    Note:
    To construct the virtual table from your Command, the command must be executed once. If the command has parameters, you will be prompted to enter values for each one.
    By default, your command is called Command. You can change its alias by selecting it and pressing F2.

  • How to find the unused files for deletion?

    After mapping 600 xml files, how does one find the unused files for deletion from the folder? (eaiser and cheaper translations)
     

    iWeb will open any file with the extension .sites2 - it doesn't have to be named "Domain".
    See this page for how to open separate Domain files when using Lion/Mountain Lion...
    http://www.iwebformusicians.com/iWeb/mountain-lion.html
    The above page will also let you know how to find the library folder now that its hidden.

  • How to find the data table sin CRM 4.0

    Dear Guru's
    I want to know where can i get all the data tables in crm 4.0 for example if i want to know the data table for the Reason in activity Management.with the help of data table only the ABAP people can work.....na
    Points willbe given
    With Best Regadrs
    Sreeram Raghu

    Hi Raghu,
    There are many techniques in which you could find the database tables, few of them are given below:
    - Place your cursor in the field for ex: reason in activity and press F1
    - In F1 screen(performance assistant), Click on Technical Information (fourth button from left), you can find here the database table name.
    Another Option:
    - Go to transaction SE11
    - In Database Table Field type few letters, for example to find all the activity table type * act * and then press F4, all the tables related to activity will be displayed
    Wish this was useful to you
    regards
    Srikantan

  • Need help for finding oracle payables tables

    Hi,
    I need help for finding tables relating fields INVOICE_ID, NOTIFICATION_ID and APPROVAL_STATUS or WFAPPROVAL_STATUS. I have searched a lot but has been unable to find any table containing all the above mentioned fields. I found the table WF_NOTIFICATIONS for INVOICE_ID, however have been unable to find the latest tables with INVOICE_ID and APPROVAL_STATUS as fields.
    All the tables having this combination are either very old tables which are not used anymore or doesnt give the required data. Please let me know where am i going wrong. Once i get the required tables, i need to join the tables to get the required data with the imp fields. Also, the values of WFAPPROVAL_STATUS are not very clear to me. I need values for it as APPROVED, REJECTED AND INITIATED.

    Hi Swetha,
    You will have to manually make the table adjustments in all the systems using SE14 trans since the changes done using SE14 cannot be collected in any TR.
    How to adjust tables :
    Enter the table name in SE14. For ex for any Z master data(Say ZABCD), master data table name would be /BIC/PZABCD, text table would be /BIC/TZABCD. Similarly any DSO(say ZXYZ) table name would be /BIC/AZXYZ00 etc.
    Just enter the table name in SE14 trans --> Edit --> Select the radio button "Save Data" --> Click on Activate & adjust database table.
    NOTE : Be very careful in using SE14 trans since there is possibility that the backend table could be deleted.
    How to collect the changes in TR:
    You can collect only the changes made to the IO --> When you activate, it will ask you for the TR --> Enter the correct package name & create a new TR. If it doesn't prompt you for TR, just goto Extras --> Write transport request from the IO properties Menu screen. Once these IO changes are moved successfully, then the above proceduce can be followed using SE14 trans.
    Hope it helps!
    Regards,
    Pavan

  • DB Tool List Table: How to access tables which are in different SQL database ?

    Hi, All,
    I'm working on a database application (SQL server) and is evaluating the NI DB Tool kit for this project.
    One of the requirement is that I need to access tables which are in two different database
    (say Table A in DB 1 and Table B in DB 2).
    Our IT guys has linked Table A in DB1 to DB 2 and I verfied this when I use the SQL server managment studio.
    When DB 2 tables are populated, Table A from DB1 is also there. I can also do the same thing using MS Access.
    Table A in DB1 is avalaible to me enven though I only connect to DB 2.
    Here comes the problem.
    When I use DB Tool List Table.vi to access DB2, it does NOT list Table A in DB1. It only list the tables in
    the database (DB2) which I make connection to (using DB Tool Open Connection.vi with a file DSN)
    So my work around right now is to open two seperate connection to DB1 and DB2. However, this approach
    obviously creates a problem when I have to access seperate database constantly in my application.
    What would be a solution to this ? I've search the forum but only see one post that's somewhat related to
    my question. (And it was posted on 2004) Perhaps I need to alter the code in the orignial VI (DB Tool List Table.vi)??
    My IT guy told me he has not encountered this scenario since he writes codes in other enviroment such as
    VB and others, and he's always been successful by linking tables to different database. 
    I hope my question is sound and clear since I really don't know much about database terminology.
    Any comment/suggestion is much appreciated !!!
    Thanks
    Chad
    Solved!
    Go to Solution.

    To josborne:
    To answer your question:
    - Are the two databases contained on the same SQL Server instance? 
    Or are the databases on separate instances?  I assume they are on
    separate servers, otherwise this wouldn't really be an issue.  But its
    good to know because it will affect how you build your SQL statements.
    Yes they are on separate instances. 
    - Ask your IT people specifically how they "linked Table A in DB1 to
    DB 2".  I assume they used "linked servers". 
    Maybe I used the wrong terminology "linked." They created a "View of Table A (DB1)" in DB2 using the management studio.
    Here is a screen shot of that. As you can see, dbo.VISUAL_WORK_ORDER is seen under LABVIEW database in the management studio.
    I also see the same table when I make connection to database using MS Access.
    Could you elaborate on "configure your SQL statement correctly" =) ? The purpose of using LabView's took kit is so that I can do
    minimum SQL statements. Are you talking about modifying LabView's native VI (DB Tool List Table.vi) ?
    Thanks for the information. SQL is just something new to me.

  • How to find the database table behind the xtags  varibles?

    if in xtags we find that some varibles are not having the right data coming from xml -> database tables so how can we find out the names of database table behind it .
    <!-- <xtags:variable id="msds" context="<%=specs%>" select="//header/msds"/>
    <a href="/MSDS/<%=msds%> target="#">MSDS</a>
    -->
    now how to find the database table and the column name of database table from which the value of id msds is coming
    Here they have stored the name of pdf file . from this code pdf file is displayed

    Hi,
    Thanks for your response. It is PM related.  When I run a T Code - IK18,  the field Total Counter Reading field appears. I am looking for that particular fields actual table name and field name.  I think I have found it in IMGR table. Now I want to get IMRG-READG in my report, but there is no common fields in neither MKPF or MSEG table. So what can I do to connect IMRG table with either of them ?

  • Query to find the Base tables of views

    Hi,
    Can you pl let me know the query to find the base tables on which the view is based.I looked into views like ci_view_definitions but i could not find them.
    Thanks for your help
    thanx,
    Suji.

    select vw.name viewname, nvl( tabdef.name, vwdef.name) "based on"
    from   ci_view_definitions vw
    ,      i$sdd_vwtab
    ,      ci_view_definitions vwdef
    ,      ci_table_definitions tabdef
    where  view_ref = vw.id
    and    table_ref = tabdef.id (+)
    and    table_ref = vwdef.id (+)

  • How to find the DB tables used by the workbook/worksheet

    Hi,
    I wonder if there is a way that we can query the EUL tables (e.g. eul5_documents, etc) to find out the database tables that are used by a specific workbook.
    Please advise and thank you very much,
    Yke

    There is no "direct" way to do this. If a report has been run at least once, though, you may be able to find out what you want (but it will require a bit of work).
    From the EUL5_QPP_STATS table, you can find the workbook (qs_doc_name) and worksheet (qs_doc_details). You can then use the qs_object_use_key value to find the objects, which will give the tables. You could try:
    select obj_ext_owner || '.' || sobj_ext_table
      from eul5_objs
    where instr ((select qs_object_use_key
                    from eul5_qpp_stats
                   where qs_doc_name = <workbook>
                     and qs_doc_details = <worksheet>
                     and qs_created_date =
                        (select max(qs_created_date)
                           from eul5_qpp_stats
                          where qs_doc_name = <workbook>
                            and qs_doc_details = <worksheet>)),
                 obj_id) > 0;This should give you the tables used for the last execution of the workbook.

  • Delete PSA Request - unable to find the PSA table to see latest request ...

    Hi, I wanted to delete request thru an ABAP program in a process chain. I'm not planning to use the Process Chain variant because it will a conditional delete and I want the latest request to be deleted.
    I'm unable to locate the PSA table where I can find the reuqest. Any help is appreaciated.

    Hey,
    You can get the PSA technical name from the data source.
    Double click on data source --> from menu bar --> goto -> Technical Attributes
    Here you can find the PSA table name.
    or you can fine the PSA Table name from the below table.
    RSTSODS - Operational Data Store for the trans
    here the entry in the filed -ODSNAME_TECH while provide you the tehcnical name of the PSA table.
    Regards
    KP

Maybe you are looking for

  • Book revenue on this month but the cost of goods sold need to get from last month

    Hi experts, I have a question about cost and revenue. We have a standing service repair order and a contract to customer. Because the revenue is calculated by flight cycle so maybe when we get the flight cycle information for this month should be the

  • How to write a module pool (M) program for the DEMO_DYNPRO_TABSTRIP_server

    Hi, How does someone write a module pool program (type m ) like the one which is given as an example for tabstrip control (paging through the app.server which is a report program). Please check the code given in the abap tutorial by sap below. REPORT

  • Adobe Reader used with Bidmail program

    Hello- I am currently having a problem using the "hand tool" with a program called "Bidmail." Bidmail is a social networking site for contractors to share pdf. files online. My problem is, when I log into bidmail.com, I open up a pdf. file to view an

  • Query for last 5 Purchase Price for items

    Dear All I was trying to write a query in which i want to display Items with last 5 purchase price itemcode     UOM      Last Purchase Price        II Last Pur Price       III Last Pur Price        IV Last Pur Price         V Last Pur Price but not g

  • Harry, Why won't Portal Developers Support Oracle Support???

    I just got off the phone with Oracle support and the response is that they can't provide assistance on my TAR because the portal developers won't give them the info. Why? All I have been asking for are the columns/tables in PORTAL30 and/or PORTAL30_S