Rename physical filenames of SQL Server 2017 database

I am looking for the correct way to rename physical file names for SQL Server 2017 database.  In 2008 R2 this was so easy to just detach, rename the mdf/ldf files, then reattach and point SSMS to the 'new' mdf/ldf files.  However, in 2017 I cannot figure it out.  I've found different postings when Googling, but they all seem to lead me to a dead end or are too complex for me to understand.  

I would like, for example, to take a database I have attached as Database_1234 - which has physical file names of Database.mdf and Database.ldf - to be renamed to Database_1234.mdf and Database_1234.ldf.

I need the simplest, easiest, non-advanced DB admin way to do this.  Thank you in advance.
SpaceCoastLifeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott PletcherSenior DBACommented:
1) Alter the db filenames to the new names.  You can get the logical file names from the command "EXEC sp_helpfile":

ALTER DATABASE Database_1234 MODIFY FILE ( NAME = <logical_file_name>, FILENAME = 'x:\full\path\to\file\Database_1234.mdf' );
ALTER DATABASE Database_1234 MODIFY FILE ( NAME = <logical_file_name2>, FILENAME = 'y:\full\path\to\file\Database_1234.ldf' );

2) Set the db offline:

ALTER DATABASE Database_1234 SET OFFLINE WITH ROLLBACK AFTER 60 SECONDS; /* or WITH ROLLBACK IMMEDIATE to not wait at all, to just immediately kill anything that's running */

3) Rename the physical file names.  You can use Windows, a script, any method you want to do the renaming

4) Set the db online:

ALTER DATABASE Database_1234 SET ONLINE
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SpaceCoastLifeAuthor Commented:
Thank you for the very straightforward and easy to follow instructions.  Works like a charm.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.