per favore prova questo codice
declare @Sql_Str varchar(8000)='';
select @[email protected]_Str+' select cast (' +name +' as varchar(500)) from
<yourtable> union' from sys.columns where [object_id]=object_id('<yourtable>')
set @Sql_Str=SUBSTRING(@Sql_Str,1,len(@Sql_Str)-6)
exec(@Sql_Str)