Search code examples
c#sql-serversmo

Change logical database name with SMO


How can I change the logical database name when restoring a database with SMO?

/Viktor


Solution

  • You can't rename the logical database files with a SQL RESTORE DATABASE: it's not offered. Only physical files can be changed using WITH MOVE

    You rename logical files by using ALTER DATABASE in SQL, normally.

    This appears to be be confirmed by the RelocateFile SMO class.