Daily Archives: July 20, 2012

List out all the table names & it’s info of selected Database using SQL Server


–Select YourDatabase

USE AdventureWorks

Go

–Query to list out all the Tables in the selected DB

SELECT * FROM sys.Tables

 

In Above result, all rows are not ordered on any basis. You can given more specific query to sort out / ordered by any column. For example, now we considered the column “Name” to display the result in ordered.

 

–Same Result which is Alphabetically ordered by the Column “Name”

SELECT * FROM sys.Tables ORDER BY [name]

 

You can observe in the above result. All rows are ordered by the column “Name”. See it’s very right??? Like this simple & twisting, we can see a lot unless you get a situation.

 

Happy Coding….