You could use UNION ALL
and have one SELECT
that has the column headings, and then another with the actual values cast to varchar
as appropriate:
SELECT 'AccCode', 'CodeDesc', 'AccountType_id', 'AccGroupName'
UNION ALL
SELECT
CAST(AccCode AS varchar(100)),
CAST(CodeDesc AS varchar(100)),
CAST(AccountType_id AS varchar(100)),
CAST(AccGroupName AS varchar(100))
FROM @gl
(Of course, if some columns are already non-numeric you could leave them as such, otherwise CAST
as appropriate.)