In the below query what should I do to get the results in the same order as the input param.
DECLARE @sql varchar(max)
SET @sql = 'SELECT a.num AS Num, a.photo as Photo , row_number() over (order by (select 0)) rn
FROM tbl a (nolock) WHERE a.num IN (' + @NumList + ') '
I pass in to the @NumList param the following (as an example):
1-235,1-892,2-847,1-479,3-890,1-239,2-892
This works fine, however I need the results returning in the 'SAME ORDER' as the input param.
I have created a SQL Fiddle