开发者

SMO scripting entire database like Studio Management does with Generate Scripts

I am trying to set up a C# tool that scripts an entire database from the tables down to the stored procedures. I want to get all the schema and data. I am having a hard time finding much on the net on how to do this properly. I would think this would be common practice as an alternative if you don't wish to actually back the dabase up using Backup or Transfer, but I can't find much on the开发者_JAVA技巧 subject. Can anyone direct me to something on how to do this or tell me what needs to be done? I have found how to script Tables and stored procedures, but I want to get EVERYTHING in the database so that I can revert back to where it was if changes to the database breaks other things.

One of the reasons I am going about it this way is because i know that if you do a backup:

a.) it can get corrupt b.) you can only do a back up on the server hosting the SQL server. You cannot back it up on your local machine if you are running the application remotely from the SQL Server. This is of course assuming that I cannot always rely on a UNC path or ftp script of any kind.


Have a look at http://scriptdb.codeplex.com. This is a tool that scripts out a Database's ddl.

For Scrripting out the data you could try an approach like described here: http://sqlblog.com/blogs/ben_miller/archive/2007/10/18/scripting-tables-views-and-data-using-smo-part-3.aspx or try to use bcp, wich would be the better alternative for bigger databases.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜