SET NOCOUNT ON
declare @n int
set @n = 1
while @n <=27
begin
select 'select ''' + ObjectName + '--' + CounterName + ''' as CounterName,
b.CounterValue,
b.CounterDateTime
from CounterDetails a inner join CounterData b
on a.counterID = b.counterID
where a.counterID = ' + convert(nvarchar,CounterID) + '
and CounterDateTime between ''2009-01-07 08:30:03.824'' and ''2009-01-07 08:50:03.824''
GO' from CounterDetails where CounterID = @n
set @n = @n + 1
end
|