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

La consulta de transposición crea nodos (SQL Server 2008)

Si no desea el <Expr1> - ¡entonces simplemente no lo pidas!

Tienes:

(SELECT ', ' + CAST(taxonomy_id AS varchar) AS Expr1

Que AS Expr1 provoca el <Expr1> para ser agregado, así que simplemente no tenga esa expresión allí.

Prueba

SELECT 
    taxonomy_item_id, 
    SUBSTRING(
      (SELECT ', ' + CAST(taxonomy_id AS VARCHAR) 
       FROM dbo.taxonomy_item_tbl AS t2
       WHERE t1.taxonomy_item_id = taxonomy_item_id
       AND taxonomy_language_id = 2067
       ORDER BY taxonomy_item_id, taxonomy_id 
       FOR XML PATH('')
      ), 1, 1000) AS taxonomy_ids
FROM 
    dbo.taxonomy_item_tbl AS t1
WHERE 
    taxonomy_language_id = 2067
    AND taxonomy_item_id = 180555
GROUP BY 
    taxonomy_item_id