简体   繁体   English

如何从SQL Server数据库创建SQL Server Express数据库

[英]How to create SQL Server Express DB from SQL Server DB

I have a SQL Server 2008 DB. 我有一个SQL Server 2008数据库。 I want to extract SOME tables (and associated schema, constraints, indexes, etc) and create a SQL Server Express DB. 我想提取一些表(以及关联的架构,约束,索引等)并创建一个SQL Server Express数据库。 It isn't a sync of the target, we stomp on it. 这不是目标的同步,我们为此而之以鼻。

We ONLY need to do this in the file system (not across the wire). 我们仅需要在文件系统中执行此操作(而不是通过网络)。 We are not fond of the synchronization stuff and at this point don't know how to run SSIS. 我们不喜欢同步的东西,目前还不知道如何运行SSIS。 We are a C# shop and a little code is ok. 我们是一家C#商店,只需一点代码就可以了。 Like using the C# bulk import stuff, but that won't create the schema. 就像使用C#批量导入一样,但这不会创建架构。

Suggestions? 有什么建议吗?

My suggestion: 我的建议:

  1. Back up the database 备份数据库
  2. Restore under new name and file 使用新名称和文件还原
  3. Detach restored database from SQL Server 从SQL Server分离还原的数据库

You now have a standalone file that you could use with SQL Server Express. 现在,您有了一个可以与SQL Server Express一起使用的独立文件。

We use a tool from Red-Gate called SQL Compare to generate schema-complete SQL scripts. 我们使用Red-Gate的一个名为SQL Compare的工具来生成架构完整的SQL脚本。 It's about $400, but well worth it. 它大约是400美元,但值得。 You pick the objects you want (users, tables, views, functions - whatever) you want, and it will generate a SQL Script to re-create them in your new database. 您选择所需的对象(用户,表,视图,函数等),它将生成一个SQL脚本以在新数据库中重新创建它们。 Essentially, it's the same as Right-Click -> "Script To... New Window" in SSMS, but all at once, and it has a number of other features your shop might find useful as well. 从本质上讲,它与SSMS中的右键单击->“脚本...新窗口”相同,但一次完成,它还具有许多其他功能,您的商店也可能会发现它们有用。

正如Scott指出的那样(我不知道该如何评论他的帖子),您可以在数据库小于4GB的情况下,将备份和还原,分离并从一个服务器版本附加到另一个服务器版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM