/ QUICK TIPS , SQL

Error in MSSMS: Attempt to retrieve data for object failed. Invalid Urn filter...

When you work with MS SQL Server in Docker container, you may come across problem with Microsoft SQL Server Management Studio. See what’s going on.

How Invalid Urn Filter error looks like

What you see when error occurs is Microsoft SQL Server Management Studio message box saying:

Attempt to retrieve data for object failed for Server ‘PC-NAME’. (Microsoft.SqlServer.Smo)

Additional information: Invalid Urn filter on server level: filter must be empty, or server attribute must be equal with the true server name. (Microsoft.SqlServer.Smo)

MSSMS screenshot with invalid urn filter Message box

When you press Copy message text you will have the same message extended with For help, click: http://go.microsoft.com/fwlink?ProdName=… but in my case this url doesn’t work.

When you press Show technical details you will see Advanced information:

===================================

Attempt to retrieve data for object failed for Server 'PC-NAME'.  (Microsoft.SqlServer.Smo)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=14.0.17230.0+((SSMS_Rel_17_4).180313-0650)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attempt+to+retrieve+data+for+object+Server&LinkId=20476

------------------------------
Program Location:

   at Microsoft.SqlServer.Management.Smo.Server.GetSmoObject(Urn urn)
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.OpenTableHelperClass.SelectFromTableOrView(Server server, Urn urn, Int32 topNValue, Boolean scriptForSelectingRows, Boolean isDw)
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.OpenTableHelperClass.GetScriptForTopNRows(NodeContext parentContext, Int32 topNValue, Boolean scriptForSelectingRows)
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.OpenTableHelperClass.SelectTopNRows(NodeContext parentContext, Int32 topNValue)
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.SelectTopNRows.Invoke()
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ToolsMenuItemBase.MenuInvokedHandler(Object sender, EventArgs args)

===================================

Invalid Urn filter on server level: filter must be empty, or server attribute must be equal with the true server name. (Microsoft.SqlServer.Smo)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=14.0.17230.0+((SSMS_Rel_17_4).180313-0650)&LinkId=20476

------------------------------
Program Location:

   at Microsoft.SqlServer.Management.Smo.Server.CheckValidUrnServerLevel(XPathExpressionBlock xb)
   at Microsoft.SqlServer.Management.Smo.Server.GetSmoObjectRec(Urn urn)
   at Microsoft.SqlServer.Management.Smo.Server.GetSmoObjectRec(Urn urn)
   at Microsoft.SqlServer.Management.Smo.Server.GetSmoObjectRec(Urn urn)
   at Microsoft.SqlServer.Management.Smo.Server.GetSmoObject(Urn urn)

Why MSSMS with MS SQL Server in Docker container causes problems

When you recreate Docker container with Microsoft SQL Server from scratch, it’s like you create new virtual machine, with whole new SQL Server installation. As far as I know, MSSMS was not designed for such situation (even in virtualization era it was not usual case, like it is in containerization era), and it has some internal state cached. It’s probably SQL Server internal instance name, which isn’t the same for new installation, that’s why you see message: server attribute must be equal with the true server name.

How to resolve MSSMS error: Attempt to retrieve data for object failed for Server, Invalid Urn filter on server level

Unfortunately at the time of writing I didn’t find permanent solution. All you can do is to restart Microsoft SQL Server Management Studio every time you recreate Docker container. But what you should do first is to install the newest version, maybe some upgrade will fix this. Moreover, I don’t remember exactly what was the case, but older MSSMS versions got some other related issue, which got fixed.

Summary

To summarize: install the newest MSSMS version, but you will probably still need to restart Management Studio every time you start new instance of SQL Server in Docker container.

If you know something more, please let me know in comment, and of course if you have some questions :)
And share it with others who deals with SQL Server in Docker container too.

tometchy

Tometchy

Passionate focused on agile software development and decentralized systems

Read More