SQL中没有类似VB中的Split的函数。此时,如要匹配 ,6,3,9,22,中的6。可用charindex函数巧妙实现:
charindex( ',' +cast(6 as varchar)+ ',',‘,6,3,9,22,’)>0
SELECT distinct PO_Pomain.POID,PO_Pomain.cPOID,dPODate,Inventory.cInvName,cMaker,cVerifier,'88' as cVouchType
FROM PO_Pomain
INNER JOIN PO_Podetails ON PO_Pomain.POID=PO_Podetails.POID
INNER JOIN Inventory ON PO_Podetails.cInvCode=Inventory.cInvCode
WHERE exists
(
SELECT iSOsID FROM SO_SODetails WHERE cSOCode = '0000000006'
and charindex( ',' +cast(iSOsID as varchar)+ ',',PO_Podetails.CSOsIDs)>0
)