Question : Problem with update query

I am trying to use an update query to populate a table. The query below works and results in 3 rows of data. When I put this into an update query it says 0 rows affected and I can't figure out why.

This query alone works:
----------------------------------------------------------------------------------------------------
select DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),getdate()),datetime)  as CST,
case when (availability*100)/100 = 1 then 'Up.gif' else 'Down.gif' end StatusLED,
Target as Target, responsetime, case when responsetime > 6.2 then 'Down.gif' else 'Up.gif' end RTLED
FROM OPENROWSET('SQLOLEDB','1xx.1xx.1xx.2xx';'username';'password',
'SELECT     TOP 100 PERCENT DATETIME, PROBENAME, CUSTOMER, TARGET, AVAILABILITY, RESPONSETIME
FROM         dbo.IOPS_DETAIL_DATA
WHERE     (TARGET like ''CVS%'') AND (DATETIME BETWEEN DATEADD(mi, - 6, GETDATE()) AND GETDATE())
ORDER BY AVAILABILITY, DATETIME DESC, TARGET')
----------------------------------------------------------------------------------------------------

When I put it into this Update Query I get (0 row(s) affected)
----------------------------------------------------------------------------------------------------
update ovis1
set cst = t.cst,
statusled = t.statusled,
Target = t.Target,
ResponseTime=t.ResponseTime,
RtLED = t.RTLed
from
(select DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),getdate()),datetime)  as CST,
case when (availability*100)/100 = 1 then 'Up.gif' else 'Down.gif' end StatusLED,
Target as Target, responsetime, case when responsetime > 6.2 then 'Down.gif' else 'Up.gif' end RTLED
FROM OPENROWSET('SQLOLEDB','1xx.1xx.1xx.2xx';'username';'password',
'SELECT     TOP 100 PERCENT DATETIME, PROBENAME, CUSTOMER, TARGET, AVAILABILITY, RESPONSETIME
FROM         dbo.IOPS_DETAIL_DATA
WHERE     (TARGET like ''CVS%'') AND (DATETIME BETWEEN DATEADD(mi, - 6, GETDATE()) AND GETDATE())
ORDER BY AVAILABILITY, DATETIME DESC, TARGET'))t
----------------------------------------------------------------------------------------------------

What am I overlooking here?

Answer : Problem with update query

>> This query alone works and provides the following data:

Yes.. if you see your earlier query this result set is not joined to your ovis1 table..
And missed the update query in my earlier post.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
update ovis1
set cst = t.cst,
statusled = t.statusled,
Target = t.Target,
ResponseTime=t.ResponseTime,
RtLED = t.RTLed
from ovis1 inner join 
(select DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),getdate()),datetime)  as CST,
case when (availability*100)/100 = 1 then 'Up.gif' else 'Down.gif' end StatusLED,
Target as Target, responsetime, case when responsetime > 6.2 then 'Down.gif' else 'Up.gif' end RTLED
FROM OPENROWSET('SQLOLEDB','1xx.1xx.1xx.2xx';'username';'password',
'SELECT     TOP 100 PERCENT DATETIME, PROBENAME, CUSTOMER, TARGET, AVAILABILITY, RESPONSETIME
FROM         dbo.IOPS_DETAIL_DATA
WHERE     (TARGET like ''CVS%'') AND (DATETIME BETWEEN DATEADD(mi, - 6, GETDATE()) AND GETDATE())
ORDER BY AVAILABILITY, DATETIME DESC, TARGET'))t on ovis1.pk = t.pk
Random Solutions  
 
programming4us programming4us