About Amit Bansal

Amit Bansal is always brainstorming around SQL Server. Despite working with SQL since 1997, he is amazed that he keeps learning new things every single day. SQL Server is AB's first love, and his wife does not mind that. He tries to share as much and spreads the SQL goodness. Internals and Performance Tuning excites him, and also gives him sleepless nights at times, simply because he is not a genius, but quite a hard worker and does not give up. It has been a long and exciting journey since 1997, you can read here: http://sqlmaestros.com/amit-bansal/ He is on Twitter: https://www.twitter.com/A_Bansal

View all posts by Amit Bansal →

20 Comments on “SQL Server – Strange things do happen, but why are they allowed in the first place?”

  1. It might be possible if you run that query twice and you did not refresh the object explorer to check the updated value so it is showing the older database ‘HOCBASE’ but if you refresh the object explorer you will find that database name changed to ‘PRODHOCBASE’.

  2. This may be the reason u r trying to rename the dropped database before refreshing the management studio. Management studio does nor refresh it automatically after any changes..

  3. Either you are not connected to right server in the query window or there is a space preceeding the database name.

  4. The sp_renamedb use a sysname, that is different of showing name, you must use before the properties to get the sysname and then changed, but also this change the sysname, you can use the alter mouse button menu and use the rename to do that. Microsoft indicate that instead use sp_renamedb we must use alter database modify name. Remember that the sysname must be used.

  5. This is not a refresh issue. No issuse with connection. connected to the right server, right database, ie master.

    Julio, I could not follow what you mean… but this is a funny thing that happened and in my next post, I will show how did this happen…

  6. hmm Interesting, looking forward for your next blog about the issue Amit. 🙂

    Suspense in T-SQL

  7. But Amit, the code generated error at line number 29 and the error number is 15010 which is raised only when the DB in question doesn’t exist. NOw i am being impatient.

    — Make sure the database exists.
    if not exists (select * from master.dbo.sysdatabases where name = @dbname)
    begin
    raiserror(15010,-1,-1,@dbname)
    return (1)
    end

  8. try
    select
    ‘|’ + name + ‘|’ from sys.databases

    to check for a leading or trailing space after the database name

  9. This error looks like it is saying that the current user is not part of the dbcreator role(sysadmin would give access also), meaning that you dont have access to rename the database?

  10. It looks like the user doesn’t have enough permissions to create a database on the server like DB_CREATOR Role

  11. This could be because the created database has a leading or trailing space. check if the database exists from sysdatabases before trying to rename it.

  12. Its not a permission issues, If there would be permission issue then below would be an error.

    User does not have permission to perform this action

Leave a Reply

Your email address will not be published.