Added data file of user database to wrong drive

  • Good Morning Experts,

    As per our DBA guidelines, tempdb data files are stored in G drive, and user database data files are stored in J drive. A junior dba added data file in G drive for a user database instead of J drive. Management does not want database to be taken offline or instance recycled. Could you please share on how to rectify this. 

  • coolchaitu - Friday, June 29, 2018 2:26 AM

    Good Morning Experts,

    As per our DBA guidelines, tempdb data files are stored in G drive, and user database data files are stored in J drive. A junior dba added data file in G drive for a user database instead of J drive. Management does not want database to be taken offline or instance recycled. Could you please share on how to rectify this. 

    Add a file on the correct drive, then use shrink file with empty file to move the content to the new file and finally delete the file.
    😎

    You can do this through the SSMS or ping back here if you need help with the syntax.

  • Eirikur Eiriksson - Friday, June 29, 2018 3:32 AM

    coolchaitu - Friday, June 29, 2018 2:26 AM

    Good Morning Experts,

    As per our DBA guidelines, tempdb data files are stored in G drive, and user database data files are stored in J drive. A junior dba added data file in G drive for a user database instead of J drive. Management does not want database to be taken offline or instance recycled. Could you please share on how to rectify this. 

    Add a file on the correct drive, then use shrink file with empty file to move the content to the new file and finally delete the file.
    😎

    You can do this through the SSMS or ping back here if you need help with the syntax.

    Could you please help me with syntax

  • coolchaitu - Friday, June 29, 2018 3:53 AM

    Eirikur Eiriksson - Friday, June 29, 2018 3:32 AM

    coolchaitu - Friday, June 29, 2018 2:26 AM

    Good Morning Experts,

    As per our DBA guidelines, tempdb data files are stored in G drive, and user database data files are stored in J drive. A junior dba added data file in G drive for a user database instead of J drive. Management does not want database to be taken offline or instance recycled. Could you please share on how to rectify this. 

    Add a file on the correct drive, then use shrink file with empty file to move the content to the new file and finally delete the file.
    😎

    You can do this through the SSMS or ping back here if you need help with the syntax.

    Could you please help me with syntax

    This should get you there
    😎

    GO
    USE [master]
    GO
    -- ADD THE NEW FILE
    ALTER DATABASE [DB NAME] ADD FILE ( NAME = N'[LOGICAL NAME]', FILENAME = N'[FULL PATH AND FILE NAME]' , SIZE = 262144KB , FILEGROWTH = 65536KB ) TO FILEGROUP [PRIMARY]
    GO
    USE [DB NAME]
    GO
    -- MOVE THE CONTENT TO THE OTHER FILES IN THE FILEGROUP
    DBCC SHRINKFILE (N'[LOGICAL NAME]' , EMPTYFILE)
    GO
    -- REMOVE THE FILE
    ALTER DATABASE [DB NAME] REMOVE FILE [LOGICAL NAME]
    GO

  • Did you manage to do this?
    😎

  • Eirikur Eiriksson - Sunday, July 1, 2018 1:00 AM

    Did you manage to do this?
    😎

    Yes sir

  • coolchaitu - Sunday, July 1, 2018 2:30 AM

    Eirikur Eiriksson - Sunday, July 1, 2018 1:00 AM

    Did you manage to do this?
    😎

    Yes sir

    Good stuff!
    😎

Viewing 7 posts - 1 through 6 (of 6 total)

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