One way is to get the user preference for the order into a table somehow ... let's say you have a table
CREATE TABLE UserOrder
(
OrderId INT IDENTITY(1,1),
EmpId INT
);
The EmpId is going to be a foreign key to your EmployeeId table.
How you get those values in there is up to you. Say you pass a comma separated list to a Stored Procedure then see
this thread[
^] for a way of getting it into the UserOrder table.
Here is an example:
DECLARE @TheOrder VARCHAR (150)
SET @TheOrder = '5,8,2,3,4,6,7,9'
DECLARE @EmpId VARCHAR
INSERT INTO UserOrder (EmpId)
SELECT items
FROM [dbo].[Split] (@TheOrder, ',')
SELECT E.*
FROM EmployeeId E
INNER JOIN UserOrder O ON E.EmpId = O.EmpId
ORDER BY O.OrderId
(N.B. Note the implicit cast from the varchar items returned from the function and the int that is stored on the table.)