C# 无法还原名为“”、ID为“”的数据库,因为该数据库已存在于服务器上,并且是只读的
我正在SQL Server 2008r2上使用SSAS。我有一个备份文件test.abf,并使用Microsoft.AnalysisServices.Server命名空间中的以下代码还原数据库备份C# 无法还原名为“”、ID为“”的数据库,因为该数据库已存在于服务器上,并且是只读的,c#,sql-server-2008,ssas,olap,database-restore,C#,Sql Server 2008,Ssas,Olap,Database Restore,我正在SQL Server 2008r2上使用SSAS。我有一个备份文件test.abf,并使用Microsoft.AnalysisServices.Server命名空间中的以下代码还原数据库备份 using (var server = new Server()) { server.Connect(connectionString); server.Restore(new RestoreInfo { File = backupLocatio
using (var server = new Server())
{
server.Connect(connectionString);
server.Restore(new RestoreInfo
{
File = backupLocation,
AllowOverwrite = true,
DatabaseName = dbName,
Security = RestoreSecurity.IgnoreSecurity,
});
}
其中backupLocation是指向test.abf的网络共享,dbName是test。SSAS用户可以完全控制共享和NTFS
我得到以下例外情况:
处理\localhost\junk\test.abf失败'。异常消息“备份和还原错误:无法还原名为、ID为的数据库,因为该数据库已存在于服务器上,并且是只读的
使用SQLServerManagementStudio在同一共享位置上恢复数据库效果良好。没有具有名称或ID的数据库。我已经检查过了,所以很明显错误消息充其量只是误导性的,所以我有点纠结于下一步该怎么做
有什么建议吗
编辑
命令开始:
<Restore xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<File>\\localhost\junk\test.abf</File>
<DatabaseName>test</DatabaseName>
<AllowOverwrite>true</AllowOverwrite>
<Security>IgnoreSecurity</Security>
</Restore>
<PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
<LocaleIdentifier>1030</LocaleIdentifier>
</PropertyList>
审核备份/还原事件:
<Restore xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<File>\\localhost\junk\test.abf</File>
<DatabaseName>test</DatabaseName>
<AllowOverwrite>true</AllowOverwrite>
<Security>IgnoreSecurity</Security>
</Restore>
命令结束:
<Restore xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<File>\\localhost\junk\test.abf</File>
<DatabaseName>test</DatabaseName>
<AllowOverwrite>true</AllowOverwrite>
<Security>IgnoreSecurity</Security>
</Restore>
此外,运行还原请求的用户具有管理员权限
附加信息
以下是从手动还原开始的命令,以供参考和进一步说明:
<Restore xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<File>\\localhost\junk\test.abf</File>
<DatabaseName>test</DatabaseName>
<AllowOverwrite>true</AllowOverwrite>
<Security>IgnoreSecurity</Security>
</Restore>
<PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
<Timeout>0</Timeout>
<SspropInitAppName>Microsoft SQL Server Management Studio</SspropInitAppName>
<LocaleIdentifier>1030</LocaleIdentifier>
<ClientProcessID>3124</ClientProcessID>
</PropertyList>
嗯。因此,运行Restore命令的用户在SSAS上毕竟没有管理员权限,只在sqlserver上有管理员权限,这显然是不必要的。因此,如果以后有人收到这条奇怪的消息,只需像您没有执行此操作的适当权限一样阅读它,而不是阅读其他消息。请包括备份位置的完整路径以及它在运行时显示的数据库名。我将使用SQL Server Profiler跟踪发生的情况。您可以在所有程序/Microsoft SQL Server 2008 R2/Performance Tools的“开始”菜单中找到它。创建访问Analysis Services服务器的新跟踪。您可以保留默认设置。启动探查器跟踪后,请重试还原操作,并在错误发生后停止跟踪。在其他条目中,您将看到一个命令Begin和一个命令End事件,其中包含启动恢复的XMLA。希望您也能找到关于这两者之间错误的更多细节。
<Restore xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<File>\\localhost\junk\test.abf</File>
<DatabaseName>test</DatabaseName>
<AllowOverwrite>true</AllowOverwrite>
<Security>IgnoreSecurity</Security>
</Restore>
<PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
<Timeout>0</Timeout>
<SspropInitAppName>Microsoft SQL Server Management Studio</SspropInitAppName>
<LocaleIdentifier>1030</LocaleIdentifier>
<ClientProcessID>3124</ClientProcessID>
</PropertyList>