Is there any way I can do something like this without dropping out to a UDF?
Code:
declare @CMD varchar(4000)
declare @Field1 varchar (20)
declare @Result varchar (40)
set @Field1 = 'Name'
set @CMD = 'select top 1 '+@Field1+' from MyTable'
print @CMD
set @Result = (exec (@CMD))