Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All friends

I have faced one problem last four hour's, but can't until find proper solution.

SQL
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(salary,name,sex) select t.salary,t.name,t.sex  from top5 t   
update @temp set sex= case sex when 'm' then 'f' when 'f' then 'm'
return;
end;


Error show like this type : Msg 156, Level 15, State 1, Procedure _swap_row_value, Line 14
Incorrect syntax near the keyword 'return'.


structure of table top5

id      salary  Name         sex
1	1000	joginder	m
2	1500	Suresh	        m
3	1200	vikas	        f
4	1700	abiminau	f
5	500	laxman	        f
6	1600	bhushan	        f
7	100	joginder	m
8	150	Suresh	        m
9	12000	vikas	        f
10	110	abiminau	f
11	550	laxman	        f
12	1510	bhushan	        f


plz solve my problem as soon as possible. This type of question asking in MNC .

thanks for Advanced...................
Posted

1 solution

try this
SQL
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;
 
Share this answer
 
v2
Comments
joginder-banger 3-Sep-14 13:20pm    
thanks Brother.......it's working for me...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900