March 27, 2019 at 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?
March 27, 2019 at 11:57 am
keanyukas - Wednesday, March 27, 2019 11:35 AMI 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
March 27, 2019 at 12:22 pm
alter database ENR Access DB
set offline
go
Msg 102, Level 15, State 1, Line 6
Incorrect syntax near 'Access'.
March 27, 2019 at 12:28 pm
keanyukas - Wednesday, March 27, 2019 12:22 PMalter database ENR Access DB
set offline
goMsg 102, Level 15, State 1, Line 6
Incorrect syntax near 'Access'.
Try brackets around the database name [ENR Access DB]
Sue
March 27, 2019 at 12:30 pm
As Sue mentioned, you need to use [ ]. In your case that would be " Alter database [ENR Access DB] "
March 27, 2019 at 12:32 pm
That worked thanks did everything but that
March 28, 2019 at 5:29 am
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
March 28, 2019 at 6:14 am
Can you post the error you are getting?
Thanks
March 28, 2019 at 6:21 am
Msg 153, Level 15, State 1, Line 8
Invalid usage of the option Access in the CREATE/ALTER DATABASE statement.
March 28, 2019 at 6:35 am
So you say that all other commands work, which alter statements work and which don't?
Thanks
March 28, 2019 at 6:48 am
I get the error with the modify file statement
March 28, 2019 at 7:00 am
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
March 28, 2019 at 7:05 am
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