Solved

SQL Select Databases information

Posted on 2012-04-12
3
181 Views
Last Modified: 2012-06-27
Is there a select or view that I could get that gets me the following for all NON system databases?

Such as if I had 2 catalogs....busSys and busUsers, I would get JUST the following for those two databases?

databasename     tablename     fieldname     fieldtype     isnull
0
Comment
Question by:lrbrister
  • 2
3 Comments
 
LVL 39

Expert Comment

by:lcohan
ID: 37839993
In SQL you can use

select * from sys.tables
select * from sys.columns

to get info about tables/columns in each user database
0
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 37840018
For instance code below will list all tables,columns, data type and precision/scale from current db where is executed :

select distinct
      c.id,
      o.name as 'Tname',
      c.name as 'Cname',
      t.name as DataType, c.length, c.xprec, c.xscale, c.isnullable--into #cp_tabless
from sysobjects o, syscolumns c, systypes t
where o.id = c.id and
          c.xtype = t.xtype and
            t.name <> 'sysname' and o.name not like 'sys%' and
        o.type = 'U'  
order by 'cname','tname'
0
 

Author Closing Comment

by:lrbrister
ID: 37857109
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question