在软件安装过程中如何将.mdf文件附加到SQL Server [英] How to Attach .mdf file to SQL Server during installation of software

查看:65
本文介绍了在软件安装过程中如何将.mdf文件附加到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#和SQL Server中构建了一个应用程序.我设置了已经可以使用的此应用程序.但是问题是对于SQL Server数据库,我正在将Server工具安装到每台计算机上并手动附加数据库.我想在不手动附加到sql server的情况下完成SETUP.请帮帮我.
非常感谢.

I have an application build in C# and SQL server. I made the setup of this application which is already working. But problem is that for SQL Server Database i am installing Server tool to every computer and attaching the database manually.I want to complete SETUP without manually attach to sql server.Please, help me.
thanks so much.

推荐答案

对不起,我无法弄清楚....我已经打开了Sqlcmd,但命令行似乎对我不起作用...:(
Sorry I could not figure this out....I have opened Sqlcmd but still the command line doesn''t seem to work for me... :(


您可以尝试使用sqlcmd工具-您可以在
中找到它 程序文件\ Microsoft SQL Server \ 90 \ Tools \ Binn"
命令行应如下所示:
You can try using the sqlcmd tool - you can find it in
"Program Files\Microsoft SQL Server\90\Tools\Binn"
The command line should look like this:
sqlcmd -S server_instance -U user_name -P password -Q"sp_attach_db ''mydb'',''C:\mydb.mdf'',''C:\mydblog.ldf''" 


这篇关于在软件安装过程中如何将.mdf文件附加到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆