SQL provides query to execute on the object of itself.
List all the Database
SELECT * FROM sys.databases
SELECT * FROM master.dbo.sysdatabases
List all the tables in the Database
SELECT * FROM sysobjects WHERE type = 'U'
SELECT * FROM information_schema.tables
SELECT * FROM sys.tables
List all the Procedure in the Database
SELECT * FROM sys.procedures
SELECT * FROM sysobjects WHERE type = 'P'
List all the Function in the Database
SELECT * FROM sysobjects where type='fn'
Above syntax work correct in different version of sql server. Hope it will be useful.
No comments:
Post a Comment