0
hi,
assume that you have the columns emp_id and emp_name in your emp-table you can use the following procedure:
create procedure sp_Sortdata
(
@Orderbyclause varchar(50)
)
as
select
*
from
emp e
order by
case when @Orderbyclause = 'emp_id' then e.emp_id end asc
,case when @Orderbyclause = 'emp_name' then e.emp_name end asc
if you execute exec sp_Sortdata 'emp_id' the procedure returns the emp-table ordered by emp_id
i hope this helps
Marcel Hertel