I want to add a group of files / files to an existing database, but I need to get the path from the variable, because it will be different when this script completes. When I check the script in SQL Management Studio 2008 R2, it returns an error in FILENAME = @Path.
How can i use this variable?
SCRIPT WILL NOT WORK FROM A TEAM LINE!
ALTER DATABASE [MyDB]
ADD FILEGROUP [MyDB_FileStream] CONTAINS FILESTREAM
GO
DECLARE @Path VARCHAR(MAX)
SET @Path = 'C:\whatEverIWantItToBe\ThisCouldChangeWithLogic\YouGetThePoint\'
ALTER DATABASE [MyDB]
ADD FILE
(NAME = 'MyDB_FileStream'
, FILENAME = @Path
)
TO FILEGROUP [MyDB_FileStream]
source
share