Saturday, 18 January 2014

SQL Server - Query to Get List of Tables in Database in SQL Server 2008

Here I will explain SQL server query to get list of all tables in database or get list of all the tables in SQL server 2008 database.
Description:

In previous articles I explained can function return multiple values in sql,  Query to get database size in SQL ServerException handling in SQL Server with try catchSQL Query to get first & last day of month,difference b/w view and stored procedure in sql and many articles relating to SQL server. Now I will explain how to get all the tables in SQL server 2008 database.
To get all the tables in SQL server 2008 database we need to write the query like as shown below


USE SampleDB
SELECT * FROM information_schema.tables

                  OR   

USE SampleDB
SELECT * FROM SYS.tables

Once we run above query we will get output like as shown below

Demo


No comments:

Post a Comment