declare @strcol varchar(max)='';
declare @strsingle varchar(50)='';
declare column_Cursor CURSOR FOR
select column_name
from INFORMATION_SCHEMA.COLUMNS a
where table_catalog='bak'
and table_name='V_BA_FIRSTPAGE'
--and ORDINAL_POSITION>=750
order by ORDINAL_POSITION;
OPEN column_Cursor;
FETCH NEXT FROM column_Cursor INTO @strsingle;
WHILE @@FETCH_STATUS = 0
begin
set @strcol=@strcol+ ',@' + @strsingle;
FETCH NEXT FROM column_Cursor INTO @strsingle;
end;
--print @strcol select @strcol for xml path ('')
CLOSE column_Cursor;
DEALLOCATE column_Cursor;
go