Trying to restore a database backup I got from a client. Nothing new, no surprises. But SQL server (this time SQL2012) just flatly refused to restore to the location where the database should go (q:\rad\db\data\) because the path "c:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\" didn't exist. I actually had to create the bloody location just for this. Then again it wouldn't restore, because of "SQL Server Database Error: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\blabla.mdf'." I had to add the "NT Service\MSSQL$SQEX12" user to that folder and give it full rights.
Now I understand why the script has to say
WITH replace, FILE = 1,
move N'blabla' to N'q:\rad\db\DATA\blabla.mdf',
move N'blabla_log' to N'q:\rad\db\DATA\blabla_log.ldf',...
- because it actually doesn't know how to restore to a different location, so it restores to where it originally was and then MOVES the files to where they go.
What was it that you were teaching us all those years about hardcoded paths, Microsoft?
Set Rant Half