try this
alter function _swap_row_value
()
returns @temp table
(
id int not null,
salary int not null,
name varchar(max) not null,
sex varchar(max) not null
)
as
begin
insert into @temp(id,salary,name,sex) select t.id,t.salary,t.name,t.sex from top5 t
update @temp set sex= case sex when 'm' then 'f' when 'f' then 'm' else '' end
return;
end;