I am examining a third party SQL Server 2008 database. In this database, there are 2 columns CREATED_DATETIME and UPDATED_DATETIME, which are present in majority of the tables, but probably not all.
I want to find the minimum and maximum value of these 2 columns across all tables in the database which have these 2 columns. That will give me a fair idea that the data in the database is from which period to which period.
How can I write such a query?
Run this script in SSMS (
CTrl+T
=text results,F5
=execute query):It will generate another script. Execute generated script.
Example (generated script for
master
database and all tables withlow
column name >WHERE c.COLUMN_NAME IN (N'low')
):Something like the following should work
Run the script mentioned in the link below. You will have to slightly alter as per your requirements.
SCRIPT to Search every Table and Field