Something I really hate is typing something repetitive. To prepare for our Disaster Recovery plan, I wrote this script.
It is a bit strange in that it requires 2 run iterations to generate the desired result.
I use a naming standard for backup files of the form:
and a naming standard for database files of the form:
DBName_Dx.Mdf for Primary filegroup file
DBName_Ix.Ndf for Index filegroup file
DBName_L1.Ldf for Log file
I also use a directory structure the same on every volume of the form:
Well you get the picture. You can modify this to suit yourself.
To use, run it. Take results and run it. The last set of results are your restore scripts.
T-SQL to Export Table Structure to a script
When you want to export a table structure to T-SQL, everyone always points you to Enterprise Manager, or a script that calls BCP.Sometimes, a developer either doesn't have access to those tools, or just doesn't want to use them (like me) out of spite.I made this T-SQL because it was educational, and noone else seems […]