--create function นะจ๊ะ
create function fnSimple(@id varchar(30)) returns Table as
return select * from TB1 where fieldID=@id
--เรียกใช้งานจ๊ะ
select fieldID,
(select fieldname from fnSimple(1)) as columns1, --เรียกใช้ fuction fnSimple
(select fieldname from fnSimple(2)) as columns2,
(select fieldname from fnSimple(3)) as columns3
from TB1