Moving Sql Server datafile to new disk

I have Sql Server 2016 database  in a vmware VM .  The diskspace is low . How can I move the sql server datafile to a newly created   disk ?
Sam OZAsked:
Who is Participating?
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.

Sam Simon NasserIT Support ProfessionalCommented:
you can increase the virtual disk size
Under Workstation 7, you can adjust the size of the virtual hard disk from the graphical interface:

Select the corresponding virtual machine in the list.
Click on Edit virtual machine settings.
Select the Hard Disk menu item.
Click on Utilities > Expand.
Enter the new size and press Expand.
Execute the steps according tot he VMware Knowledge Base[2] , in order to adjust the guest operating system’s partitions to the new hard disk size.
0
Shaun VermaakTechnical Specialist/DeveloperCommented:
Very straightforward
1) Run the following statement.
ALTER DATABASE database_name SET OFFLINE; 

Open in new window

2) Move the file or files to the new location.
3) For each file moved, run the following statement.
ALTER DATABASE database_name MODIFY FILE ( NAME = logical_name, FILENAME = 'new_path\os_file_name' );

Open in new window

4) Run the following statement.
ALTER DATABASE database_name SET ONLINE;

Open in new window

5) Verify the file change by running the following query.
SELECT name, physical_name AS CurrentLocation, state_desc  
FROM sys.master_files  
WHERE database_id = DB_ID(N'<database_name>');

Open in new window

https://docs.microsoft.com/en-us/sql/relational-databases/databases/move-user-databases
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
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.