1. 程式人生 > >SQL將字串拆分為表集合

SQL將字串拆分為表集合

SELECT  mso.StationGUID
FROM    (
SELECT  CASE WHEN allitem = '' THEN NULL ELSE allitem END AS ProjCode

FROM dbo.fn_split('XYCG.007.01;XYCG.007.02;XYCG.007.06;XYCG.007.12122212', ';')

) child

INNER JOIN p_Project parent ON child.ProjCode LIKE parent.ProjCode + '.%' OR child.ProjCode = parent.ProjCode
INNER JOIN myStationObject mso ON (mso.TableName = '專案' AND parent.ProjGUID = mso.ObjectGUID)