Jeff McWherter from Gravity Works showed me how to easily store a SQL Server Database as Text:
- In SQL Server Management Studio right click on a database
- However over Tasks
- Select Generate Scripts
- Click 'Set Scripting Options' to skip the first two steps.
- Click the 'Advanced' button
- For the last option in general change 'Types of data to script' from schema only to 'Schema and data'
- Click OK to close the Advanced dialog
- Select a location to save the script to
- Click Next to go to summary.
- Click Next for SQL Server Management Studio to generate the script.
- Click Finish and you've got your text!
- When executing this script
- Ensure the Filename in the CREATE DATABASE Statement is correct when executing this script. (Or you can comment out everything after CREATE DATABASE $YOURDBNAME$ until the first GO to have SQL Server use defaults)
- Since this works at the SQL Server level, you will get errors when the script attempts to create users that don't exist on the target server and then errors when it authorizes that user.
P.S. See my post SQL Server Management Studio Generating Change Scripts if you want to use SQL Server Management Studio to graphically modify the database but then script the change.