Monday, September 5, 2016

SQL Server: Invalid Urn filter on server level: filter must be empty, or server attribute must be equal with the true server name

SQL Server Setup sets the server name to the computer name during installation. If someone change the hostname of the computer after installing MSSQL, the MSSQL server name does not change and this causes error message "Invalid Urn filter on server level: filter must be empty, or server attribute must be equal with the true server name".

To check this, execute following:
1. Open cmd, type hostname and execute.
2. Open SQL management studio, in the new query window type SELECT @@SERVERNAME AS 'Server Name' and execute.

Result of 1 and 2 will not match.

To correct the server name, from (as an example) “ServerApp” to “ServerDB”, run this query in SQL management studio.
sp_dropserver 'ServerApp';
GO
sp_addserver 'ServerDB', local;
GO

Restart the server and run the SELECT query again to see the change.

For more information, click here.

16 comments:

  1. Hi ,i have two instance installed on server,both are named instances ,than what is the solution

    ReplyDelete
    Replies
    1. Hello Sanjeev K,

      The solution named instances is following..

      sp_dropserver <'old_server_name\instancename'>
      GO
      sp_addserver <'new_server_name\instancename'>, local
      GO

      Delete
  2. This seems helpful, but why were the example names (in the sentence preceding the sp calls) not used in the sample sp calls?

    ReplyDelete
    Replies
    1. Hello Charlie,

      Thanks for pointing out. I have corrected it.

      Delete
  3. Users have to be careful doing this if they have a Reporting Server instance running on the box in question. This procedure you outlined above may make SSRS stop working. see below for more information:
    https://docs.microsoft.com/en-us/sql/reporting-services/report-server/rename-a-report-server-computer

    ReplyDelete
  4. Hello Sanjeev K,this resolved my situation. Developers cloned an existing database server and renamed the clone server name. However the SQL engine was still handing on to the previous server name and causing issues with login.

    ReplyDelete
  5. That is precisely what I was looking for...resolved my issue perfectly...THANK YOU!

    ReplyDelete
  6. Thank you for this article. It help me a lot.

    ReplyDelete
  7. I experienced this issue with LocalDb

    C:\>hostname
    --> DESKTOP-

    SELECT @@SERVERNAME AS 'Server Name'
    --> DESKTOP-\LOCALDB#4BC350F9

    sp_dropserver 'DESKTOP-\LOCALDB#4BC350F9';
    --> The server 'DESKTOP-\LOCALDB#4BC350F9' does not exist. Use sp_helpserver to show available servers.

    sp_helpserver;
    --> There are no servers defined.

    The following procedure resolved the issue:
    1. SSMS, Object Explorer
    2. Right-click on `(localdb)\MSSQLLocalDB` node
    3. Disconnect
    ----------------------------------------------
    4. SSMS, Object Explorer
    5. [Connect]v drop down
    6. `Database Engine ...`
    7. Server name: `(localdb)\MSSQLLocalDB`
    8. Connect

    ReplyDelete
    Replies
    1. Ok, then disconnect and connect is also 1 way to resolve this issue. Thanks for adding.

      Delete
  8. Fixed my issue. Thanks so much !!!!!!!

    ReplyDelete
  9. You saved my day. Thank you so much.

    ReplyDelete
  10. What are the advantages of online gambling? | KLH Hub
    Online gambling is 구리 출장마사지 a 천안 출장샵 new way of playing 속초 출장마사지 the casino, whether you play slots or table games. It's all about skill, not luck. But when 청주 출장마사지 a 광명 출장샵 casino

    ReplyDelete