sql server - Retrieve values for multiple ids given in the order -
i having stored procedure uses csv accept multiple ids. want retrieve values table in order of ids given. stored procedure using is
create procedure [dbo].[proc1] @userid varchar(max)=null begin set nocount on; declare @useridord table (userid varchar(max),position int identity(1,1)); insert @useridord select item [dbo].[split] (@userid, ',') select * user user.userid in (select top 100 percent userid @useridord order position) end go
what trying csv inserting values temporary table adding order value position. use orderby position, implemented in inner select. output given order in table. know use orderby in outer select statement don't know correct syntax execute it. can me?
how using inner join
?
select u.* user u inner join @useridord uo on uo.userid = u.userid order uo.position
Comments
Post a Comment