There are system stored procedures which give you info but it is easier to use get info directly from the system tables for some things. It is worthwhile getting one of the relationship diagrams of the system tables in SQL Server and learning a bit about them.
One of the ones I reference quite frequently is sysobjects which gives you names. sysobjects is in every database.
Run the following query to get the object types that are stored so you can see how to get a similar list for Views etc.
SELECT DISTINCT type FROM sysobjects
To get a list of tables with the names sorted:
SELECT name FROM sysobjects
WHERE type = 'U'
ORDER BY name
Unless you have absolutely no other option, you are generally better off using stored procedures.
If Microsoft decide (as they are quite likely) to change the internal workings of SQL Server, there's a good chance that querying the system tables will not produce the same results.
Using a system stored procedure however, will most likely be updated to reflect any changes in the underlying workings.
It just makes it that little bit easier when porting your database (and database-based apps) to a new version of SQL.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.