如何把SQL的.MDF和.LDF文件加入到数据库

sunjunfeng4 2005-08-17 11:52:51
我下载了一个软件,它有两个数据文件PersonalManage_Data.MDF;PersonalManage_Log.LDF
安装说明是
数据库安装说明:
数据库安装时,可以先附加到企业管理器,所用者为sa,之后再把sa密码设为空。库名为:PersonalManage。

用户名:admin
密码:admin

我该具体怎样能让数据正常工作
...全文
678 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudeqing 2005-12-04
  • 打赏
  • 举报
回复
进入企业管理器,右键"数据库目录",选择所有任务,再附加数据库,选择你的.mdf文件名,就OK了
饮水需思源 2005-08-17
  • 打赏
  • 举报
回复
应该在SQL的企业管理器中直接“附加数据库”即可
klan 2005-08-17
  • 打赏
  • 举报
回复
在查询分析器里面参考执行就可以了呀,很方便的呀。
Attaches a database to a server.
Syntax

sp_attach_db [@dbname =] 'dbname',
[@filename1 =] 'filename_n' [,...16]

Arguments

[@dbname =] 'dbname'

Is the name of the database to be attached to the server. The name must be unique. dbname is sysname, with a default of NULL.

[@filename1 =] 'filename_n'

Is the physical name, including path, of a database file. filename_n is nvarchar(260), with a default of NULL. There can be up to 16 file names specified. The parameter names start at @filename1 and increment to @filename16. The file name list must include at least the primary file, which contains the system tables that point to other files in the database. The list must also include any files that were moved after the database was detached.

Return Code Values

0 (success) or 1 (failure)

Result Sets

None

Remarks

sp_attach_db should only be executed on databases that were previously detached from the database server using an explicit sp_detach_db operation. If more than 16 files must be specified, use CREATE DATABASE with the FOR ATTACH clause.
If you attach a database to a server other than the server from which the database was detached, and the detached database was enabled for replication, you should run sp_removedbreplication to remove replication from the database.

Permissions

Only by members of the sysadmin fixed server role can execute sp_attach_db.
点点星灯 2005-08-17
  • 打赏
  • 举报
回复
附加数据库:

企业管理器
--右键"数据库"
--所有任务
--附加数据库
--选择你的.mdf文件名
--确定
--如果提示没有.ldf文件,是否创建,选择"是"


查询分析器中的方法:
--有数据文件及日志文件的情况
sp_attach_db '数据库名'
,'数据文件名(*.mdf注意要带目录)' --后面可以是用,分隔的该数据库的多个数据文件
,'日志文件名(*.ldf注意要带目录)'--后面可以是用,分隔的该数据库的多个日志文件

--如果只有数据文件的情况
sp_attach_single_file_db '数据库名'
,'数据文件名(*.mdf注意要带目录)' --后面可以是用,分隔的该数据库的多个数据文件
sunjunfeng4 2005-08-17
  • 打赏
  • 举报
回复
那是什么意思,有没有具体的操作 在SQL企企业管理器中如何导入这个数据库文件
klan 2005-08-17
  • 打赏
  • 举报
回复
参考:
EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'c:\mssql7\data\pubs.mdf',
@filename2 = N'c:\mssql7\data\pubs_log.ldf'
flash_angle 2005-08-17
  • 打赏
  • 举报
回复
是的我們也用“附加数据库”
TomyGuan 2005-08-17
  • 打赏
  • 举报
回复
附加数据库
很方便的

34,593

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧