scuttleButt
Programmer
I am using sql server 2000. I am creating a table in a dts with one column for each day.
I have declared my variables and found the last day of the month. I am trying to set up the columns in a "while" loop:
Declare @idx int, @eom int
Set @idx = 1
set @eom = (select day(dateadd(dd,-1,cast(convert(char(7),dateadd(mm,1,getdate()),120)+'-01' as datetime))))
CREATE TABLE dbo.eodReport (
clinics varchar (15) NULL,
fcc char (5) NULL
) ON [PRIMARY]
While @idx <= @eom+1
BEGIN
ALTER TABLE eodReport ADD @idx int
END
I get an error: "Incorrect syntax near '@idx'".
It doesn't seem to like the "@". What am I doing wrong or am I not able to do what I want?
Thanks!
I have declared my variables and found the last day of the month. I am trying to set up the columns in a "while" loop:
Declare @idx int, @eom int
Set @idx = 1
set @eom = (select day(dateadd(dd,-1,cast(convert(char(7),dateadd(mm,1,getdate()),120)+'-01' as datetime))))
CREATE TABLE dbo.eodReport (
clinics varchar (15) NULL,
fcc char (5) NULL
) ON [PRIMARY]
While @idx <= @eom+1
BEGIN
ALTER TABLE eodReport ADD @idx int
END
I get an error: "Incorrect syntax near '@idx'".
It doesn't seem to like the "@". What am I doing wrong or am I not able to do what I want?
Thanks!