Разработчик моей базы данных дал мне запрос SQL, и он успешно выполняется в SSMS.
USE testdb
DECLARE @Pipeline TABLE
(
pipeline VARCHAR(4000),
unitcode VARCHAR(4000),
designareanumber VARCHAR(4000),
nameofnote VARCHAR(4000)
)
INSERT INTO @Pipeline
SELECT pipeline,
unitcode,
designareanumber,
nameofnote
FROM (SELECT pp.oid AS OID,
nmpp.itemname AS ItemName,
nmpl.itemname AS Pipeline,
tn.trainnumber AS TrainNumber,
uc.unitcode AS UnitCode,
FROM jrtepipepart pp
JOIN jnameditem nmpp
ON pp.oid = nmpp.oid
JOIN xcontainsnote xcn
ON pp.oid = xcn.oidorigin
WHERE gn.text <> ''
AND ( nmpps.itemname = 'Piping_New'
OR nmpps.itemname = 'Piping_Modified/Tie_In' )
--where gn.Text like '%000002A_TP08' AND (nmpps.ItemName = 'Piping_New' OR nmpps.ItemName = 'Piping_Modified/Tie_In')
UNION ALL
SELECT hs.oid AS OID,
nmhs.itemname AS ItemName,
nmpl.itemname AS Pipeline,
tn.trainnumber AS TrainNumber,
uc.unitcode AS UnitCode,
FROM jhgrsupport hs
JOIN jnameditem nmhs
ON hs.oid = nmhs.oid
WHERE gn.text <> ''
AND ( nmpps.itemname = 'Piping_New'
OR nmpps.itemname = 'Piping_Modified/Tie_In' ))A
SELECT pipeline,
unitcode,
designareanumber,
( Stuff((SELECT Cast('; ' + nameofnote AS VARCHAR(max))
FROM @Pipeline p2
WHERE ( p2.pipeline = p1.pipeline
AND p2.unitcode = p1.unitcode
AND p2.designareanumber = p1.designareanumber
AND nameofnote NOT IN ( 'Note 1', '' ) )
FOR xml path ('')), 1, 2, '') ) AS NameOfNote
FROM @Pipeline p1
WHERE nameofnote NOT IN ( 'Note 1', '' )
GROUP BY pipeline,
unitcode,
designareanumber
Когда я запускаю указанный выше запрос в OleDbDataAdapter, он возвращает 0 строк. Я попытался добавить SET NOCOUNT ON
в начале запроса, но не работал. Я увеличил свойство set-timeout.