Problems creating a functioning table
Posted
by
Hoser
on Server Fault
See other posts from Server Fault
or by Hoser
Published on 2012-06-01T15:17:10Z
Indexed on
2012/06/01
16:42 UTC
Read the original article
Hit count: 216
This is a pretty simple SQL query I would assume, but I'm having problems getting it to work.
if (object_id('#InfoTable')is not null)
Begin
Drop Table #InfoTable
End
create table #InfoTable (NameOfObject varchar(50), NameOfCounter varchar(50), SampledValue float(30), DayStamp datetime)
insert into #InfoTable(NameOfObject, NameOfCounter, SampledValue, DayStamp)
select vPerformanceRule.ObjectName AS NameOfObject, vPerformanceRule.CounterName AS NameOfCounter, Perf.vPerfRaw.SampleValue AS SampledValue, Perf.vPerfHourly.DateTime AS DayStamp
from vPerformanceRule, vPerformanceRuleInstance, Perf.vPerfHourly, Perf.vPerfRaw
where (ObjectName like 'Logical Disk' and CounterName like '% Free Space' AND SampleValue > 95 AND SampleValue < 100)
order by DayStamp desc
select NameOfObject, NameOfCounter, SampledValue, DayStamp
from #InfoTable
Drop Table #InfoTable
I've tried various other forms of syntax, but no matter what I do, I get these error messages.
Msg 207, Level 16, State 1, Line 10
Invalid column name 'NameOfObject'.
Msg 207, Level 16, State 1, Line 10
Invalid column name 'NameOfCounter'.
Msg 207, Level 16, State 1, Line 10
Invalid column name 'SampledValue'.
Msg 207, Level 16, State 1, Line 10
Invalid column name 'DayStamp'.
Msg 207, Level 16, State 1, Line 22
Invalid column name 'NameOfObject'.
Msg 207, Level 16, State 1, Line 22
Invalid column name 'NameOfCounter'.
Msg 207, Level 16, State 1, Line 22
Invalid column name 'SampledValue'.
Msg 207, Level 16, State 1, Line 22
Invalid column name 'DayStamp'.
Line 10 is the first 'insert into' line, and line 22 is the second select line. Any ideas?
© Server Fault or respective owner