November 6, 2007 at 7:51 am
i tried using dynamic sql for creating a filegroup as a task in the beginning of the package but that is giving me an error now..could you plz give me some kind of direction on how i can solve this:
declare @newfilegroup varchar(60)
set @newfilegroup = substring(CONVERT(VARCHAR, DATEPART(YEAR, GETDATE())), 3, 4)
EXEC ('ALTER DATABASE test ADD FILEGROUP ' + @newfilegroup)
this gives me a synatx error where as
declare @newfilegroup varchar(60)
set @newfilegroup = 'a' + substring(CONVERT(VARCHAR, DATEPART(YEAR, GETDATE())), 3, 4)
EXEC ('ALTER DATABASE test ADD FILEGROUP ' + @newfilegroup)
works fine
November 6, 2007 at 8:10 am
My guess (note, guess) is that filegroup names cannot start with a number.
-- Cory
November 6, 2007 at 8:30 am
filegorup names can start with number.. right now they are manually created as 07, 08 and so on..
November 6, 2007 at 8:39 am
declare @newfilegroup varchar(60)
set @newfilegroup = substring(CONVERT(VARCHAR, DATEPART(YEAR, GETDATE())), 3, 4)
EXEC ('ALTER DATABASE northwind ADD FILEGROUP [' + @newfilegroup + ']')
It needs to be wrapped in the [ ].
-- Cory
November 6, 2007 at 9:19 am
Thankyou so much!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply