Friday, December 7, 2007

Get DataBase info from queries

Get all SP names in a database

Simply run the below query under your database.

--Get all SP list of a DB
select name from sysobjects where type='p' order by name asc

Gt all Table of a DB

SELECT [A].* FROM [sysobjects] AS A where [Xtype] = 'U' order by [A].[name]

Gt all column names of a table

SELECT [syscolumns].* FROM [syscolumns], [sysobjects], [systypes] where [syscolumns].[ID] = [sysobjects].[ID] and [syscolumns].[xtype]=[systypes].[xtype] and [syscolumns].[id] = '<Table ID got from above query>' order by colid

No comments: