sql >> Base de Datos >  >> RDS >> Sqlserver

SQL Server 2008 - Dividir

Puedes usar CROSS APPLY para usar la función de división con una columna como parámetro.

SELECT pd.contentnodeid,
       pt.name,
       s.Value
FROM   vw_abc pd
       INNER JOIN propertytype pt
         ON pd.propertytypeid = pt.id
       INNER JOIN tab t
         ON t.id = pt.tabid
       INNER JOIN contenttype ct
         ON ct.nodeid = pt.contenttypeid
       INNER JOIN propertytype pt1
         ON pt1.name = pt.name
       INNER JOIN vw_abc pd1
         ON pd1.propertytypeid = pt1.id
       CROSS APPLY dbo.split(',', pd1.datanvarchar) as s
WHERE  t.TEXT LIKE 'ANC'
       AND pd1.datanvarchar <> 'NULL'
       AND pd1.datanvarchar <> ''
       AND pd.datanvarchar LIKE '%'
       AND pd1.datanvarchar LIKE '%'