Hi can someone help.
I have the following code:
Set @LowTime ='01/02/2006 00:00'
Set @HighTime='01/02/2006 23:59'
set @counter ='1'
while @counter <= '28'
begin
select @LowTimeSeconds = DATEDIFF(second, @FixedStartDate, @LowTime)
select @HighTimeSeconds = DATEDIFF(second, @FixedStartDate, @HighTime)
insert into serverresults
SELECT @servername as Servername, t.name as Taskname, @lowtime , AVG(Dp.value)as AverageCounterName,MAX(Dp.value)as MaxCounterName from datapoint DP
JOIN taskbinder tb on dp.taskbinder_id = tb.taskbinder_id
JOIN server s on tb.server_id = s.server_id
JOIN counter c on tb.counter_id = c.counter_id
Join taskparam tp on tb.task_id = tp.task_id
Join task t on tp.taskdescr_id = t.taskdescr_id
where s.name = @ServerName
and c.name = @CounterName
and dp.recordtime between @LowTimeSeconds and @HighTimeSeconds
set @counter = @counter +1
set @lowtime = @lowtime +1
set @hightime = @lowtime +1
end
When I run it I get the following error:
Server: Msg 8118, Level 16, State 1, Line 59
Column 't.name' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
If I put in the following command:
Group by taskname
I then get the follwoing error:
Server: Msg 207, Level 16, State 3, Line 59
Invalid column name 'taskname'.
Server: Msg 207, Level 16, State 1, Line 59
Invalid column name 'taskname'.
Can anybody help me get this working.
Cheers
J
I have the following code:
Set @LowTime ='01/02/2006 00:00'
Set @HighTime='01/02/2006 23:59'
set @counter ='1'
while @counter <= '28'
begin
select @LowTimeSeconds = DATEDIFF(second, @FixedStartDate, @LowTime)
select @HighTimeSeconds = DATEDIFF(second, @FixedStartDate, @HighTime)
insert into serverresults
SELECT @servername as Servername, t.name as Taskname, @lowtime , AVG(Dp.value)as AverageCounterName,MAX(Dp.value)as MaxCounterName from datapoint DP
JOIN taskbinder tb on dp.taskbinder_id = tb.taskbinder_id
JOIN server s on tb.server_id = s.server_id
JOIN counter c on tb.counter_id = c.counter_id
Join taskparam tp on tb.task_id = tp.task_id
Join task t on tp.taskdescr_id = t.taskdescr_id
where s.name = @ServerName
and c.name = @CounterName
and dp.recordtime between @LowTimeSeconds and @HighTimeSeconds
set @counter = @counter +1
set @lowtime = @lowtime +1
set @hightime = @lowtime +1
end
When I run it I get the following error:
Server: Msg 8118, Level 16, State 1, Line 59
Column 't.name' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
If I put in the following command:
Group by taskname
I then get the follwoing error:
Server: Msg 207, Level 16, State 3, Line 59
Invalid column name 'taskname'.
Server: Msg 207, Level 16, State 1, Line 59
Invalid column name 'taskname'.
Can anybody help me get this working.
Cheers
J