To rename my Windows Device name from "DESKTOP-OLD" to "DESKTOP-NEW", I put "DESKTOP-NEW". then clicked on "Next":
Then, clicked on "Restart now" to restart my Windows PC:
After that, I connected to MSSQL with my new server name "DESKTOP-NEW\SQLEXPRESS". *I use MSSQL Express edition:
Then, I clicked on "Properties" from the user "john" under "Security/Logins":
Then, I opened "Securables" page:
Then, I mistakenly checked "Grant" for my old server "DESKTOP-OLD\SQLEXPRESS" to grant the permissions for it, then clicked "OK":
But, I got this error below:
Attempt to retrieve data for object failed for Server 'DESKTOP-NEW\SQLEXPRESS'. (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)
So, from "Search...", I added my new server "DESKTOP-NEW\SQLEXPRESS" to "Securables:" to grant the permissions for it, then clicked "OK":
But, I still got this error below:
So, are there any ways to solve this error?
01 Answer
Your MSSQL server name will still be your old one "DESKTOP-OLD\SQLEXPRESS" rather than your new one "DESKTOP-NEW\SQLEXPRESS". That's why you got the error and in the error, you can see the error hint message below:
ADDITIONAL INFORMATION:
... server attribute must be equal with the true server name.
So, to change your MSSQL server name from your old one "DESKTOP-OLD\SQLEXPRESS" to your new one "DESKTOP-NEW\SQLEXPRESS", first, with two SQL queries below, you need to check your Windows device name and your MSSQL server name respectively:
SELECT HOST_NAME() -- Get Windows device name SELECT @@SERVERNAME -- Get MSSQL server name
Now, you could check your Windows device name "DESKTOP-NEW" and your MSSQL server name "DESKTOP-OLD\SQLEXPRESS" respectively as shown below:
Next, with the SQL queries below, you can drop your old MSSQL server "DESKTOP-OLD\SQLEXPRESS" and add the new MSSQL server "DESKTOP-NEW\SQLEXPRESS":
EXEC sp_dropserver 'DESKTOP-OLD\SQLEXPRESS' -- Drop server GO EXEC sp_addserver 'DESKTOP-NEW\SQLEXPRESS', local -- Add server GO
Now, you could drop the old MSSQL server "DESKTOP-OLD\SQLEXPRESS" and add the new MSSQL server "DESKTOP-NEW\SQLEXPRESS" as shown below:
But, even if you check your MSSQL server name again, your MSSQL server name is still the old MSSQL server "DESKTOP-OLD\SQLEXPRESS" as shown below. *But no worries, in spite of that, the old MSSQL server "DESKTOP-OLD\SQLEXPRESS" is actually dropped properly and the new MSSQL server "DESKTOP-NEW\SQLEXPRESS" is actually added properly:
If you really want to check that the new MSSQL server "DESKTOP-NEW\SQLEXPRESS" is actually added properly, restart MSSQL with SQL Server Configuration Manager(SSCM). This is How to find SQL Server Configuration Manager in your Windows Machine:
Then, if you check your MSSQL server name again, your MSSQL server name is now the new MSSQL server "DESKTOP-NEW\SQLEXPRESS" as shown below.
Next, if opening "Properties" from the user "john" under "Security/Logins":
Now, you can see that your new MSSQL server "DESKTOP-NEW\SQLEXPRESS" is added to "Securables:" and your old MSSQL server "DESKTOP-OLD\SQLEXPRESS" is removed from "Securables:" as shown below:
Finally, you can grant the permissions for your new MSSQL server "DESKTOP-NEW\SQLEXPRESS" by clicking "OK" without error:
1ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobmxtYm5%2BdX6OmqutnZ2lwW7AzmapnqyinrK3sYydmK2ZXZu8s3nOm6Gem6Ris6K1y56bZp6fp3q0sdGvnKtlnZ6ws7vSqJ2tZaOmubSx0a%2Bc