我正在尝试将新文件组和文件添加到现有数据库中。
我的脚本:
DECLARE @AlterDB NVarchar(4000),
@FGName NVarchar(30) = 'Partition_DW2_',
@FileLoc NVarchar(50) ='D:\Data\',
@CurrentYR NVarchar(10) ='2014' ,
@FullName Nvarchar(max)
Set @FullName = @FileLoc+@FGName+@CurrentYR+'.ndf'
Print @fullName
et @AlterDB = 'ALTER DATABASE Partition_DWJ2
ADD FILE
( NAME = '+@FGName+@CurrentYR+',FILENAME ='+@FullName +',SIZE = 2048KB ,MAXSIZE = UNLIMITED,FILEGROWTH = 1024KB
)TO FILEGROUP '+@FGName+@CurrentYR
EXECUTE SP_Executesql @AlterDB ,N'@FullName NVarchar(max)',@FullName=@FullName
Print @ALterDB
这给出了错误'Incorrect syntax near 'D:'.'
我做错了什么?