Script to retrieve a list of databases with the associated recovery model. Useful for checking backups.
This category contains useful information relating to Transact SQL (TSQL).
I have developed a script that can be used to archive offline databases. This script first brings the databases online, then backs them up, detaches them, and then moves the MDF and LDF files.
I have just improved the script in SQL: List of table columns, with data types:
It now includes an indicate for nullable fields, primary and foreign keys, unique and check constraints, and identity columns
Question asked by Pramod on my old Forum.
The example query below creates a product category table and populates it with sample data. I then use a CTE query to return the categories, along with the breadcrumb trail (lineage)
The script in this post can be used to obtain an example of each of the different styles that can be output using the CONVERT Transact-SQL statement when converting date/time to a string. I have output the styles including the century, but the script can easily be modified to output examples without.
If you need to analyse the number of email addresses by email domain, e.g. “@abc.com”, then the script within this post will return the number of records grouped by the domain name of each email address (i.e. to the right of the @ sign)
The script within this post, outputs a list of each DATETIME and SMALLDATETIME field within a database, along with the minimum and maximum values. Useful to identify tables that have a date created or updated column, and you want to find out if they are still being used.