Moving Datafiles

  • I have a number of databases with spaces in the name of the database. No matter what I try to use so I can move the datafiles I get a syntax error. What do I need to use to move database datafiles with spaces in the database name?

  • keanyukas - Wednesday, March 27, 2019 11:35 AM

    I have a number of databases with spaces in the name of the database. No matter what I try to use so I can move the datafiles I get a syntax error. What do I need to use to move database datafiles with spaces in the database name?

    It's hard to say being that we don't know what you tried. Usually you need the database name in brackets - did you try that? Something like:
    ALTER DATABASE [Your Database Name With Spaces]
    MODIFY FILE ( NAME = LogicalName , FILENAME = 'NewPath' )

    Sue

  • alter database ENR Access DB
    set offline
    go

    Msg 102, Level 15, State 1, Line 6
    Incorrect syntax near 'Access'.

  • keanyukas - Wednesday, March 27, 2019 12:22 PM

    alter database ENR Access DB
    set offline
    go

    Msg 102, Level 15, State 1, Line 6
    Incorrect syntax near 'Access'.

    Try brackets around the database name [ENR Access DB]

    Sue

  • As Sue mentioned, you need to use [   ]. In your case that would be  " Alter database [ENR Access DB] "

  • That worked thanks did everything but that

  • When I try the alter command I get an error but all other commands work
    alter database [ENR Access DB]
    set offline
    go

    move files

    alter database [ENR Access DB]
    modify file (name=ENR Access DB_log,filename="F:\Database Logs\ENR Access DB_log.LDF")
    go

    alter database [ENR Access DB]
    set online
    go

  • Can you post the error you are getting?

    Thanks

  • Msg 153, Level 15, State 1, Line 8
    Invalid usage of the option Access in the CREATE/ALTER DATABASE statement.

  • So you say that all other commands work, which alter statements work and which don't?

    Thanks

  • I get the error with the modify file statement

  • Try this:
    alter database [ENR Access DB]
    modify file (name='ENR Access DB_log',filename='F:\Database Logs\ENR Access DB_log.LDF')
    go

    Thanks

  • That worked thanks

Viewing 13 posts - 1 through 12 (of 12 total)

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