I have the following sql query (this is a transpose query to get comma separated table)
SELECT CAST ((SELECT taxonomy_id + ','
FROM content
FOR XML PATH('')) AS bigint) AS NewTaxonomytableName
But I am getting Error converting data type varchar to bigint.
The table taxonomy_id
is a bigint
Any ideas?
UPDATE:
SELECT CAST ((SELECT CAST(taxonomy_id AS varchar) + ',' AS Expr1 FROM taxonomy_item_tbl FOR XML PATH('')) AS varchar) AS Expr1
Running this gives me one row.
But in fact it is not right for me. It needs to comma separate only the taxonomy_id's for a specific content_id.
An example:
content_id taxonomy_id
1 15
1 16
5 24
5 19
needs to be:
content_id taxonomy_id
1 15,16
5 24,19
I am really stuck with this for 8 hours. If anyone can help me I will really appreciate it...
Thanks