FAT Fingered my DB name with a space character...

  • This wa an oops on my part. I created a new DB las week and I fatfingered the space character in it so now it's called: "DUMMY_FATFINGER " (Notice the space)

    Other than recreating it how can I rename it correctly? Just clicking on it to rename it does not work. I get the Database already exists error.

    Thanks

  • there s a stored proc just for it; you'll get an error if anyone is connected to it when you try to rename.

    sp_renamedb [old name with spaces],[newname]

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • From BOL: EXEC sp_renamedb N'Accounting', N'Financial'

  • I get the following error...

    Msg 15032, Level 16, State 1, Procedure sp_renamedb, Line 36

    The database 'HR_TRACKING' already exists. Specify a unique database name.

    Obviously SQL knows the correct name, users are connecting to the correct name that does not have the space at the end. The problem is, when the backup job runs, it is getting the name with the space at the end. When I run the sp_renameDB the system knows already it has the correct name hence the error message above. It's a cosmeting naming thing somewhere in SQL.

    Thanks

  • just be sneaky and rename it twice then...that should fix it:

    sp_renamedb [HR_TRACKING ],[HR_TRACKINGTMP]

    sp_renamedb [HR_TRACKINGTMP],[HR_TRACKING]

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • BINGO!!!!

    Renaming it twice did the trick!

    I actually used the GUI to do it.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply