Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Need help concatenating when pulling data from AS400/DB2 DB into Excel

$
0
0

Hello All,

I am using a connection within Excel 2010 to connect to a AS400/DB2 database and the connection works fine however the query that I am trying to write keeps throwing the errorSQL1014 - Token . was not valid.  Valid tokens: ) UNION EXCEPT.  I am trying to concatenate the field/column (ntda - comments field 50 characters) as there are multiple rows of these comments (ntlno1 is row number for each comment and not sure if I should show this number anywhere) perwono (work order number).  My code is as follows:

SELECT DISTINCT WOHDR.wono AS WONO,
       stuff( (SELECT ','+WONOT2.ntda
               FROM FROM libd09.wopnote0 WONOT2
               WHERE WONOT2.wono = WONOT1.wono
               ORDER BY WONOT2.ntda
               FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
            ,1,1,' ')
       AS Comments
FROM libd09.wophdrs0 WOHDR 
LEFT JOIN libd09.wopsegs0 WOSEG ON (WOHDR.wono = WOSEG.wono)
LEFT JOIN libd09.cslusrp0 USR ON (WOSEG.clsdby = USR.uspfid)
LEFT JOIN libd09.woplabr0 WOLBR ON (WOHDR.wono = WOLBR.wono)
LEFT JOIN libd09.wopnote0 WONOT1 ON (WOHDR.wono = WONOT1.wono)
LEFT JOIN libd09.wopmisc0 WOMISC ON (WOHDR.wono = WOMISC.wono)
LEFT JOIN libd09.wopempf0 WOEMP ON (WOMISC.epidno = WOEMP.epidno)
LEFT JOIN libd09.woppart0 WOPART ON (WOHDR.wono = WOPART.wono)
LEFT JOIN tafilev22.employ01 TAEMP ON (WOMISC.epidno = TAEMP.ememp)

WHERE WOHDR.opndt8 BETWEEN ? AND ?

Any help or assistance would be greatly appreciated!

Thank you.


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>