When I executed the following script, I am getting the following error. What should I do to correct this issue?
Error
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near '@path'.
Script
GO
declare @path varchar(2000)
declare @path1 varchar(2000)
select @path=(SELECT [filename] FROM master..sysdatabases WHERE [name] LIKE 'master')
set @path= REPLACE(@path, 'master', 'test')
set @path1= REPLACE(@path, 'test.mdf', 'test_log.ldf')
select @path
select @path1
CREATE DATABASE [test] ON
( FILENAME = @path ),
( FILENAME =N'D:\Program Files (x86)\Microsoft SQL Server\MSSQL.3\MSSQL\DATA\test_log.ldf' )
FOR ATTACH
GO
masterdatabase which does not have to be identical to the configured default data path (it's not on any of my machines, for instance)