• The query you posted uses group_concat() which is not a function in SQL Server. That smells MySQL to me, but I could be wrong. Furthermore, the error message you posted is not from SQL Server. (And this is an SQL Server forum.)

    Here is a way to write this query in SQL Server, but which will not work in any other product:

    SELECT TABLE_NAME, substring(collist, 1, len(collist) - 2)

    FROM INFORMATION_SCHEMA.TABLES T

    CROSS APPLY (SELECT COLUMN_NAME + ' - '

    FROM INFORMATION_SCHEMA.COLUMNS C

    WHERE T.TABLE_NAME = C.TABLE_NAME

    AND C.COLUMN_NAME IN ('a', 'b')

    FOR XML PATH('')) AS C (collist)

    WHERE collist IS NOT NULL

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]