Getting all the table names from Database

I was creating some POC on migrating the data from Sql Server to MongoDB that time i faced this problem how to get all table names from a particular database in sql server 2008 and i came up with this query


After executing this query you will get all tables names that are there in your current database.The current database name you need to set in your connection string attribute in Web.config file like below:

<add name=”connectionInfo” connectionString=”Persist Security Info=False;Initial Catalog=[Database Name];Data Source=[Server Name];User ID=sa;Password=SQL2008r2;Connect Timeout=1000;”/>

Thank you!


  1. Though this seems to be a simple thing, but when we are in a hectic work searching for this type things in Google may not give you the exact result, Good one Shanmukh.. 🙂

    1. Thanks sai.follow up with my blog to get more updates.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: