Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Logical Name

my_Data

my_Log

Path:

C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

FileName:

my.MDF

my_1.LDF

What would be the sql script to move these files to a new location: D:\DATA

Database is live so I would need to close existing connections.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

While you could do this with a SQL Script, this is one of those cases where it's easier to use the management console.

Start the SQL Server 2008 Management Studio and connect to your server as a user with the sysadmin server role. Navigate to your database, right-click and select Tasks -> Detach..., click OK. Now you can move your database files to their new location. Finally, right-click the Databases folder and select Attach..., select the appropriate files and click OK. Your database will now be online using the files in their new location.

share|improve this answer
    
easy! thanks for the help! –  FiveTools Jul 5 '11 at 19:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.