我試圖從數據庫中的所有標籤上的WonderWare歷史數據庫中獲取數據。已經有一個包含所有標籤的表格,所以我想用一個子查詢來選擇所有的標籤名稱。這個子查詢出現錯誤w.r.t。在WonderWare中使用子查詢來選擇所有標籤
我的SQL語句:
/******
I want to be able to select:
- all columns
- for all tags <-- I'm getting an error here, trying to use a subquery
- between two time stamps
- at a specified resolution
******/
SELECT *
FROM
Runtime.[dbo].AnalogHistory
WHERE
TagName IN (
SELECT DISTINCT TagName
FROM
Runtime.dbo.Tag
)
AND
DateTime >= '2016-01-01 00:00'
AND
DateTime < '2016-01-01 00:30'
AND
wwResolution = 5000
AND
wwRetrievalMode = 'Average'
AND
wwTimeStampRule = 'Start'
我收到的錯誤是:
OLE DB provider "INSQL" for linked server "INSQL" returned message "History queries must contain at least one valid tagname".
我的猜測是指沒有被正確地執行它。
我使用OPENQUERY也試過,但後來我得到相關子查詢無法辨別關於標籤表「模式」信息其他錯誤:
OLE DB provider "INSQL" for linked server "INSQL" returned message "Failed to retrieve schema information for object 'Tag'".
這是摘錄更改:
TagName IN (SELECT * FROM OPENQUERY(INSQL,
'SELECT DISTINCT TagName
FROM
Runtime.dbo.Tag')
)