2

I have some db's created with an incorrect logical name for both rows and log. how can I change the logical names to match the db name with a script? (and does not want to change physical file names)

Also how can I find all the databases with same logical name?

(SQL Server 2012)

thanks

migrated from stackoverflow.com Dec 14 '15 at 21:24

This question came from our site for professional and enthusiast programmers.

3

Just use ALTER DATABASE:

ALTER DATABASE mydb 
MODIFY FILE ( NAME = logical_file_name, NEWNAME = new_logical_name ) 
  • so NAME is current name? How about log file, do I need another statement for it? – SJ Johnson Dec 14 '15 at 18:54
  • No, same command – ErikEJ Dec 14 '15 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy