Query for list of tables

Hi Gurus,
I have a requirement, i have one server on which i have got 20 DB and now i want to list those 20 DB and the count of total tables on each DB and the last login date on each DB. How can i do that? i was trying the below one but in vain.
EXEC sp_databases;
can you please provide your inputs for this.
Thanks,
RM

Then I am speechless.
In Oracle, for the table counts:
select owner, count(*) from dba_tables group by owner;For last login date you need to enable auditing to track something like that.
For SQL Server databases you should go here :
http://social.msdn.microsoft.com/Forums/en/category/sqlserver
Good luck!

Similar Messages

  • Need a query to list all table names

    I have more than 500 tables in my database.
    'insert_date' & 'update_date' columns are found in more than 100 tables with data type as date.
    I need a query to list all table names and 'insert_date' , 'update_date' column's content.
    Please Help
    Lee1212
    Message was edited by:
    LEE1212

    I have more than 500 tables in my database.
    'insert_date' & update_date column is found in more
    than 100 tables with data type as date.
    I need a query to list all table names and
    'insert_date' column's content.What do you mean by "column's content". A table can have many rows. Do you want to display all the distinct value for these columns?
    Below is the query to get the tables which has columns insert_Date and update_date
    select table_name
    from user_tab_columns
    where column_name ='INSERT_DATE'
    or column_name ='UPDATE_DATE'
    /You can write a PL/SQL block to retrive the distinct values of INSERT_DATE for these tables
    declare
    TYPE ref_cur IS REF CURSOR;
    insert_date_cur ref_cur;
    lv_insert_date DATE;
    cursor tables_list IS
    select table_name
    from user_tab_columns
    where column_name ='INSERT_DATE';
    begin
    for cur_tables in tables_list
    loop
      OPEN insert_date_cur for 'SELECT DISTINCT insert_date from '||cur_tables.table_name;
      DBMS_OUTPUT.PUT_LINE(cur_tables.table_name);
      DBMS_OUTPUT.PUT_LINE('--------------------------------');
      LOOP
      FETCH insert_date_cur into lv_insert_date;
      EXIT WHEN insert_date_cur%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE(lv_insert_date);
      END LOOP;
    CLOSE insert_date_cur;
    end loop;
    end;I haven't tested this code. There might be some errors. Just posted something to start with for you.

  • Query for listing several values in same field

    Hi,
    is there a function for listing more than one value in the same field, only with comma seperation?
    For example, I want to group by cardcode from ORDR and list all docnum's like this:
    Cardcode    Docnum's
    21355          98765, 95498, 95164
    21564          95484, 54684, 95654, 98465
    21865          95484, 12486
    Kind regards
    Kjetil Sandvik

    HI,
    Thank for your replies.
    We need to update all old orders for sure, but my idea was to use this query:
    Select CardCode, COUNT(Address2) From ORDR Where Docstatus <> 'C' GROUP BY address2, cardcode order by cardcode, address2
    The results will give me two lines for each customer and count the addresses, so then I know that the count of one of the lines must me changed. Let's say there is 20 orders with new address and 20 orders with old address, my intention was to manually change the 20 orders that is old. Instead of checking all 40, It would help alot to list all order numbers in a column beside in the query.
    BR
    Kjetil

  • Query for list of specifications

    Hi Experts,
    We need to execute query which should contain list of specifications with and without material assignments.Selection criteria is based on generation variant.
    Please let us know from which tables we can get the above list.
    Thanks for your help!!
    Regards,
    Sivasankar
    Message was edited by: Sivasankar P
    Message was edited by: Sivasankar P

    Hi Chris,
    This issue is not related to consultant and it is related to end user. We have query which is already defined to pick up specifications with material.Now they have requested us to get the query even there is no material assigned to specifications.
    So we have planned to remove material from query, so if we remove ESTMJ from query whether it will have impact on some other tables.(like ESTDJ,ESTRH,ESDTH,etc..)
    Thanks for your help!!
    Query:
    *delete report if there is no material
    SORT I_ESTRH BY RECNROOT.
       SORT I_ESTMJ BY RECNROOT.
       IF I_ZESTRHESTDJESTDH[] IS NOT INITIAL OR
          I_ZESTRHESTDJESTDH1[] IS NOT INITIAL.
         LOOP AT I_ESTRH INTO WA_ESTRH.
           MOVE SY-TABIX TO V_INDEX.
           READ TABLE I_ESTMJ INTO WA_ESTMJ WITH KEY RECNROOT = WA_ESTRH-RECNROOT
                                                                   BINARY SEARCH.
           IF SY-SUBRC NE 0.
             READ TABLE I_ZESTRHESTDJESTDH WITH KEY SUBID_ESTRH = WA_ESTRH-SUBID
                                                                  BINARY SEARCH.
             IF SY-SUBRC NE 0.
               READ TABLE I_ZESTRHESTDJESTDH WITH KEY SUBID = WA_ESTRH-SUBID
                                                              BINARY SEARCH.
               IF SY-SUBRC NE 0.
                 READ TABLE I_ZESTRHESTDJESTDH1 WITH KEY SUBID = WA_ESTRH-SUBID
                                                                 BINARY SEARCH.
                 IF SY-SUBRC NE 0.
                   READ TABLE I_ZESTRHESTDJESTDH1 WITH KEY SUBID_ESTRH = WA_ESTRH-SUBID
                                                                         BINARY SEARCH.
                   IF SY-SUBRC NE 0.
                     DELETE I_ESTRH INDEX V_INDEX.
                   ENDIF.
                 ENDIF.
               ENDIF.
             ENDIF.
           ENDIF.
         ENDLOOP.
       ENDIF.
    Regards,
    Sivasankar

  • Error while running query for a specific table

    Hi All,
    I need your help please.
    I've configured everything correctly in my SCCM environment. And i used to connect the CAS database from a separate box(same domain) which has SSMS console installed in it. Now the problem is, whenever i try to run a query in CAS database locally, it runs
    successfully. But when i connect the CAS database remotely and run the same query with the same login i used in CAS, it says the below error. This is happening from past 2 days only. :'(
    Query ran :
    select top 100 * from v_GS_WORKSTATION_STATUS
    Error :
    Msg 18456, Level 14, State 1, Line 1
    Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
    OLE DB provider "SQLNCLI11" for linked server "abc.domain.com" returned message "Invalid connection string attribute".
    I checked the SQL connection authentication information it says authenticated by kerberos using below query :
    SELECT 
        s.session_id
      , c.connect_time
      , s.login_time
      , s.login_name
      , c.protocol_type
      , c.auth_scheme
      , s.HOST_NAME
      , s.program_name
    FROM sys.dm_exec_sessions s
      JOIN sys.dm_exec_connections c
        ON s.session_id = c.session_id
    where s.host_name='servername'
    Result:
    136 2015-01-30 17:50:29.277 2015-01-30 17:50:29.280 domain\user TSQL KERBEROS servername Microsoft SQL Server Management Studio
    But, another wierd information is i can successfully run the below query in remote.
    select * from vSMS_R_System
    I think that specific table is not working in remote. Pleaseeeeeeee helppp me......
    Regards,
    Jay

    Hi JaySmiley,
    According to your description, you get the logon issue when connecting to CAS database remotely and execute query. Right?
    In this scenario, this error can happen when the SPN account is registered without setting 'trusted for delegation' property. Account must be trusted for delegation in order for Kerberos delegation to succeed. Here's a blog talking about your scenario, please
    refer to the link below:
    http://blogs.technet.com/b/umairkhan/archive/2013/10/19/the-distributed-views-do-not-get-created-in-configmgr-2012-sp1-because-of-the-login-issue.aspx
    If you have any question, please feel free to ask.
    Simon Hou
    TechNet Community Support

  • Select query for 6 different tables with vbeln as same selction criteria

    Hi,
    I have a query..
    I am using 6 differnet tables with vbeln being the same primary key on the basis of which i have to match the data.
    I have assign vbeln with different name but in the select query it gives me the error that vbeln2 is not the correct field.
    Can anyone please suggest how can i use the different field name and read the data from the table.

    hi,
    Use alias name for fields / tables in select query, problem will solve
    Regards,
    Praveen Savanth.N

  • Query for Linking Two Tables without Reference

    Hi Folks,
    Good Day!
    I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
    When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
    Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
    OTER and OCRD don't have connections. How can it be?
    I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
    Thank you much!
    Regards,
    Fringe

    Hi Fringe,
    Okay, I already understood your case here. I presume your configuration as follows:
    OTER (Territory)
    territryID - descript
    1 - Philippine
    2 - Indonesia
    3 - Germany
    OPRC (Cost Centre)
    PrcCode - PrcName
    25 - Philippine
    33 - Indonesia
    47 - Germany
    Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
    SELECT PrcCode FROM OPRC WHERE PrcName=(
    SELECT TOP 1 descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0])
    However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
    OTER (Territory)
    territryID - descript
    1 - PHI
    2 - INA
    3 - DEU
    OPRC (Cost Centre)
    PrcCode - PrcName
    PHI - Philippine
    INA - Indonesia
    DEU - Germany
    When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
    SELECT descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0]
    You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
    Best Regards,
    Hendry Wijaya

  • Query for the huge table is not working.

    Hi,
    I am having a link between oracle server and Microsoft sql server let' say 'SQLWEB' this link is perfectly working fine when I query table having few hundred thousand records but It’s not working for one of the table which is having a more then 3 million record at sql server. any one of you is having any Idea why this peculiar behavior is there any limitations for this heterogeneous link is there any workaround for the same. Below you can see the first query returns the count from table but second query is getting disconnected as that’s a very huge table having millions of record.
    shams at oracleserver> select count(*) from investors@sqlweb ;
    COUNT(*)
    15096
    shams at oracleserver> select count(*) from transactions@sqlweb;
    select count(*) from transactions@sqlweb
    ERROR at line 1:
    ORA-02068: following severe error from SQLWEB
    ORA-28511: lost RPC connection to heterogeneous remote agent using SID=%s
    ORA-28509: unable to establish a connection to non-Oracle system
    Regards
    Shamsheer
    Message was edited by:
    Shamsheer

    In general you want to minimize the traffic going over the dblink. This is best handled with view on the sql server try. You might try creating a view on sql server like:
    create view all_investors as
    select * from investors
    Then from sql plus:
    select count from all_investors@sqlweb.

  • Query for list of supported auth mechanisms

    Is there a way to query a BO server for a list of supported authentication mechanisms such as secEnterprise or trusted secret or secWinAD, etc?

    I haven't tested but this should work:
    InfoObject oIfoObject = (IInfoObject) oInfoStore.query("select si_id from ci_systemobjects where si_name='Auth Plugins'").get(0);
    IInfoObjects authPlugins = oInfoStore.query("select * from ci_systemobjects where si_parentid=" + oInfoObject.getID());
    for(int i=0; i<authPlugins.size(); i++)
           IInfoObject authPlugin = (IInfoObject) authPlugins.get(i);
           // above returns a specific plugin object: secLDAP, secWinAD, secSAPR3, secEnterprise all what your installation supports
    //  cast the InfoObject to IsecWinAD if si_kind=' secWinAD' or si_name is secWinAD
    if(authPlugin.getTitle().equalsIgnoreCase("secWinAD"))
                  IsecWinAD winad = (IsecWinAD) authPlugin;
                  int availability =  winad.getAvailaility(); //0 - if plugin is not configured\ready to use, 1 if ready to use and configured.
                  String enabled =winad.properties().getProperty("SI_TRUSTED_AUTH_ENABLED").getValue().toString(); // returns true if trusted aut is enabled for this plugin, false otherwise.
    I don't think you can read any property to retrieve the trusted key. The above code will give the auth plugins that are available in your install, which ones are ready and configured ( I have checked only the AD ones above) and if trusted auth is enabled. Check query builder properties if you are trying to get additional info for the auth plugins.

  • BAPI to SOAP scenario - query for response as table

    This is for BAPI to SOAP scenario. We need response as TABLE(multiple values,like arraylist/resultset in java) , not as single valued items.
    .net method is ->Y_Vct(string CoCode,string Role, ref A_BTable)  -    
       Request:
               CoCode -Optional, if empty string is passed all companies will be fetched by the function
               Role - Optional, if empty string is passed all the roles will be fetched by the function
        Response:
               A_B- returns set of records(Multiple) based on the parameters passed
    BAPI is - Y_Vct
    How to get response from table of multiple values .
    like 10 records as response for 1 request.
    thanks.

    Hi Jha,
    Which version of PI you are using? If you are uisng 7.1 then you can return the multiple values.
    Regards,
    ---Satish

  • Neea a sql query for inverting the table

    Hi,
    I am facing the problem in forming a SQL statement in oracle 10g
    Table structure:
    user field1 field2 field3 field4 field5 field6 .......
    one 11 12 13 14 15 16
    two 21 22 23 24 25 26
    three 31 32 33 34 35 36
    i want a SQL query where the out put is
    field1 11 21 31
    field2 12 22 32
    field3 13 23 33
    field4 14 24 34
    Regards,
    Balu CH

    check this Forums page
    <http://forums.oracle.com/forums/search.jspa?threadID=&q=Rows+to+Columns&objID=f75&dateRange=last90days&userID=&numResults=15>
    will help u.
    Rgds
    Sudar

  • Dynamic select query for a dynamic table

    Hi Guys,
    i have a requirement where i have print the rows of a sql table which is passes dynamically. Let me walk you through the details of my requirement
    i.e for example i have a procedure ABC which will print the rows of the table by taking the table name as parameter.
    i have the below procedure, but its not printing the rows of the table
    CREATE OR REPLACE PROCEDURE abc(tname varchar2) AS
    BEGIN
    execute immediate 'select * from '||tname;
    end;
    Your help is highly appreciated.
    Regards,
    Nagesh Manda.

    So you want SQL*Plus to display the output? That's generally a bad idea, since the client application has to be explicitly set up to display output in the first place. If you have more than a small amount of data, you can also very easily exceed the buffer size.
    What is the business purpose of this request? Whatever you're trying to accomplish, there's very likely a better option.
    If you go down this path, you're going to need to use the DBMS_SQL package rather than native dynamic SQL. You could probably adapt some of the routines Tom Kyte uses to generate flat files.
    Justin

  • App-V Reporting: SQL query for Excel Pivot Table to display App Usage (H/M/S)

    I recently posted this in the Gallery.  If anyone has any modifications or enhancements please feel free to contribute!  One thing that I'd like to be able to add to it is the ability to only display information for applications/packages that are
    still published, so if anyone can figure out a crafty way to do it...  Thanks!
    http://gallery.technet.microsoft.com/App-V-Reporting-SQL-query-6695d3c3

    I recently posted this in the Gallery.  If anyone has any modifications or enhancements please feel free to contribute!  One thing that I'd like to be able to add to it is the ability to only display information for applications/packages that are
    still published, so if anyone can figure out a crafty way to do it...  Thanks!
    http://gallery.technet.microsoft.com/App-V-Reporting-SQL-query-6695d3c3

  • Ridc query for list of WebSites

    I am just starting with RIDC and with UCM, developing a web app to allow access to UCM via IDC. I need to get back data for presenting lists to my users, like: list of websites maintained by UCM, list of sections within particular websites, etc. I am baffled and would appreciate tips as to service to use (GET_SEARCH_RESULTS ??) and parameters which need to go into the DataBinder to use with the service. At this point I can do simple queries to find content, but not much more.

    Hi.
    To filter Site Studio Sites in UCM you have tu execute GET_SEARCH_RESULTS filtering by: xWebsiteObjectType <matches> `Project`.
    You'll obtain the list of Site Studio Sites :).
    PD: It's a WebCenter Content Post not WebCente Portal ;).

  • Query builder; list of tables

    Hello,
    We use BOXIr2. I would like to use query builder to look up some things. But I don't have information about the (system) tables I can query on. I know one of them:  CI_INFOOBJECTS.
    Is there any documentation about these tables?
    Lia

    Thanks this was very helpful. I don't think I would have found this myself.
    Still, I can't find any helpful queries using query builder. I need an overview of all scheduled jobs which are recurrend. So I know which jobs are scheduled on a regular basis.
    Lia
    Edited by: L. Geelen on Jul 15, 2010 11:12 AM

Maybe you are looking for

  • How to connect a E1200 wireless router to a machine tool network for wireless communications

    Hello all, I am new to the forum, hope someone can help me out. I am wanting to connect my E1200 wireless router to a machine tool in our factory that has programmable controllers and is connected to the machine components via ethernet connections. T

  • Forms taking very long time to Open

    Hello Everyone, can i know the reasons why forms are opening very late. Its taking very very long time to open. Regards Rajesh

  • ATV As a Time Capsule

    Is there a way I can use the hard drive on my Apple TV as the Time Machine drive for backing up my MacBook Pro? I talked with a sales rep, and she though there was a way, but I can't find it in any manual. Do I need to partition the drive or just cre

  • Are PS CS5 shortcut keys different from those used in PS CS4?

    Hi, I was just wondering how much different the shortcut keys used with the new  PhotoShop CS5 will be from those used with CS4?

  • Pricing for LUMF at header level

    HI all, I am creating a BOM using LUMF but when entered in sales order it is asking for a pricing condition for both Sub item and Header Item . I have checked with the Item Category TAP it is not relevant for pricing . Is there any other setting whic