Solved

SQL Server 2000 Rename DB with illegal character

Posted on 2003-11-10
2
735 Views
Last Modified: 2012-08-14
Need an answer fast to this question.

I created a database with a - ("dash") in the name. The ultimate sin! If its such a sin it should not allow you to create it. You get no error when you create it which is really stupid if you ask me.

Help!! Please!! I need to rename the database I want to change the - to an _ which I think is legal. Any ideas on how? I tried ALTER DATABASE MODIFY NAME= , but it gives me an error "error near -". SQL Server 2000. I even tired a proc, but it got the same error. Has anyone ever done this before???

Doug
0
Comment
Question by:DougC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
syntnx earned 60 total points
ID: 9716850
Try this procedure. I had it bookmarked from the following http://databasejournal.com/features/mssql/article.php/1440501

CREATE PROCEDURE usp_RenameDB
    @OldDatabaseName varchar(50),
    @NewDatabaseName varchar(50)
WITH ENCRYPTION
AS
BEGIN
    DECLARE @OldTranCount  INTEGER;

    SET @OldTranCount = @@TRANCOUNT;

    WHILE (@@TRANCOUNT > 0)
        ROLLBACK TRANSACTION

    EXEC sp_dboption @OldDatabaseName, 'single user', 'TRUE'
    EXEC sp_renamedb @OldDatabaseName, @NewDatabaseName
    EXEC sp_dboption @NewDatabaseName, 'single user', 'FALSE'

    WHILE (@@TRANCOUNT < @OldTranCount)
        BEGIN TRANSACTION
END
GO

syntnx
0
 

Expert Comment

by:WinstonRaja
ID: 9721227
Hi

Alternatively you can use [ ]  brace to overcome these errors
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question