如何通过T SQL删除磁盘上的分离数据库?

问题描述 投票:0回答:1

如何使用T-SQL从磁盘删除分离的数据库?我想从我的硬盘上删除一个分离的数据库。我该怎么做T-SQL?我想创建一个具有相同名称的数据库,我在Microsoft SQL Server 2014 Management Studio中收到此错误:

Cannot create file 'H:...\Restaurant_Data.mdf' because it already exists. Change the file path or the file name, and retry the operation.
sql-server tsql sql-delete delete-file detach
1个回答
0
投票

至少有三种方式:

  1. 附加数据库并将其删除
  2. 以交互方式登录服务器并从磁盘中删除文件
  3. 使用xp_cmdshell(启用后),但不要忘记禁用它(如果不需要)
© www.soinside.com 2019 - 2024. All rights reserved.