I have a meta table and I am creating stored procedures using T-SQL string concatenation.
declare @sql varchar(max) = 'select ';
select @sql += ... from meta -- select clause
select @sql += ... from meta -- from clause
....
It’s hard to maintain when the stored procedures get complex.
Is it better to
declare @sql xml = (select ... from meta for xml, auto);
-- then apply xslt transformation
How to do xslt in SQL server 2008? Is CLR function the only way? Any other good solution for these kind of meta programming in T-SQL?
I think Xquery should be good enough for this purpose.