SQL Server Express 2008 未分离自动附加文件?
SQLEXPRESS 的 MSDN 文档 说:
当应用程序首次从正在运行的 SQL Server Express 实例建立连接时,SQL Server Express 将自动附加一个 .mdf 文件。当用户关闭应用程序时,SQL Server Express 将从实例中分离 .mdf 文件。
这似乎并没有发生。如果我用同名的新文件替换 MDF 文件(当然是在删除日志文件之后),SQL Server Express 将拒绝附加它。
我已经尝试了几乎所有可能的连接字符串参数组合,这让我发疯。有什么建议吗?
The MSDN documentation for SQLEXPRESS says:
When an application first establishes a connection from a running instance of SQL Server Express, SQL Server Express will automatically attach an .mdf file. When the user closes the application, SQL Server Express detaches the .mdf file from the instance.
This does not appear to be happening. If I replace the MDF file with a new one of the same name (after deleting the log file, of course) SQL Server Express will refuse to attach it.
I've tried just about every combination of connection string parameters possible, and it's driving me crazy. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
分离/关闭确实发生了。如果它不会发生,那么您就不可能替换 MDF 文件,因为它正在使用中。您引用的文档并不完全准确。正确的文档位于 SQL Server 2005 Express Edition 用户实例:
如果我大胆猜测,我会说数据库没有分离,而是自动关闭,并且在删除 LDF 后重新写入 MDF 将在尝试打开数据库时(正确地)被视为错误。
作为旁注:
The detach/close does happen. If it wouldn't happen then you could not possibly replace the MDF file, because it would be in use. The documentation you quote is not entirely accurate. The correct documentation is at SQL Server 2005 Express Edition User Instances:
If I'd venture a guess I'd say that the database is not detached but auto-closed, and replcing the MDF after deleting the LDF will be (rightfully) seen as an error when trying to open the database.
As side notes: