Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Order by values in delimited List
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00924189
Message ID:
00924198
Views:
12
This message has been marked as the solution to the initial question of the thread.
Hi Kirk,

Try following (not tested). Change inlist UDF to return table varibale with 2 columns: Room # and SortOrder.
inlist UDF
* Val Ord
  110  1
   89  2
   10  3
...
JOIN  dbo.inlist(@tcDeptList) il ON il.val = dbo.meetings.RoomID 
ORDER BY  dbo.coRooms.deptdisplayorder, il.ord, dbo.meetings.begintime
>Tricky order by clause question. In the snippit of code below, I use a inlist function to determine if a roomID is in the passed list of rooms for selection purposes.
>
>
>and dbo.meetings.RoomID in (select val from dbo.inlist(@tcDeptList))
>ORDER BY  dbo.coRooms.deptdisplayorder,dbo.coRooms.RoomName, dbo.meetings.begintime
>
>
>Sample List Values
>
>110,110,89,10
>
>
>This works and gets me the right records. Now I need to change the order by to match the order of the room ID's in the list. Does anyone have a suggestion how I might be able to do that. This code is in a stored procedure currently.
>
>Thanks for any help.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform