Using SMO to persist and recreate database structure
Transfering databases between servers or creating a copy of db w开发者_JAVA百科ithin the server's instance is easy enough. We can use Microsoft.SqlServer.Management.Smo.Transfer class.
But what if I need to read all the structure of db, save it somewhere on the disk and then sometime later use that data to create a database according to the data previously saved.
Should I use Transfer again? Or there's something better and more useful than that?
Could you show me an example. Thank you.
Try DBSourceTools. http://dbsourcetools.com.au
This toolset will allow you to script an entire database to disk, and through a "Target Database", re-create it from the files on disk.
It is primarily used for source control of database, and is therefore ideal for taking a database snapshot, and then re-creating it later.
精彩评论