Home  >  Article  >  Database  >  能否用程序代码将SQLServer数据库附加到远程服务器?

能否用程序代码将SQLServer数据库附加到远程服务器?

WBOY
WBOYOriginal
2016-06-07 15:40:281038browse

数据库 要在 远程 服务器 的磁盘上。如果 数据库 不在,则先要想办法上传上去(这与SQL语句关系不大,实在需要也可以用xp_cmdshell实现)。 数据库 在,那就是: EXEC sp_attach_db @dbname = N'pubs', @filename1 = N'c:\Program Files\Microsoft SQL Serve

数据库要在远程服务器的磁盘上。如果数据库不在,则先要想办法上传上去(这与SQL语句关系不大,实在需要也可以用xp_cmdshell实现)。数据库在,那就是:

EXEC sp_attach_db @dbname = N'pubs',
   @filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
   @filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn