One way to familiarize one’s self with a very non-production database is to get a list of tables and record counts for each.

This will list out all the tables in the database currently selected. Feel free to insert the USE command at the top of this script to programmatically define the working database. Remember, this script should never be ran in a live production database.

You can also change the query for the cursor variable “FindAllTables” to find only the tables you wish to include in your query. You can also conditionally execute the dynamic sql variable “@exc”. Remember, you must have select privileges on all the tables you wish to iterate.

At eimagine, developers get to work on all kinds of technologies and have lots of fun together in a friendly and collaborative workplace. SQL Server is just one of many disciplines to learn and master. I hope you find this post useful.


Like this post? Share it!