How to restore a database with ''-'' in the name

  • A few weeks ago I created a database called corp-reports. But when I try to restore the database with the Query Analyzer I get error (near '-').

    I assume that t-sql regards the '-' as an operator or something. How do I restore the database? Do I need to create a variable and insert the variable as database name in the query?

    Enterprise manager works fine - but I need to automate some tasks and need the script to work.

  • Try RESTORE DATATASE [Your-database-name]

  • This should work:

    RESTORE DATABASE [corp-reports] FROM  DISK = N'C:\corp-reports'

     

  • I awe. Works great!!!!

    Thanks

Viewing 4 posts - 1 through 3 (of 3 total)

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