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 →
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’.
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..
Are you connected to the right server in the query window. or some space preceding the db name?
Either you are not connected to right server in the query window or there is a space preceeding the database name.
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.
The query’s connection is to a different database
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…
hmm Interesting, looking forward for your next blog about the issue Amit. 🙂
Suspense in T-SQL
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
Try SELECT * FROM sys.databases and see if the HOCBASE database is listed there.
Could it be a collation issue? Suggest to write n’HOCBASE’ or [HOCBASE]
try
select
‘|’ + name + ‘|’ from sys.databases
to check for a leading or trailing space after the database name
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?
It looks like the user doesn’t have enough permissions to create a database on the server like DB_CREATOR Role
It looks like the user does not have sufficient privileges as DB_CREATOR role
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.
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
May be there are any references to the HOCBASE database?
Hi Amit,
Waiting for your blog post – to know the reason.
Hi Friends,
Answer is posted here: https://www.sqlservergeeks.com/blogs/AmitBansal/sql-server-bi/703/sql-server-strange-things-do-happen-but-why-are-they-allowed-in-the-first-place-the-answer
Regards
Amit – http://www.amitbansal.net