Re: sorting variables in a stored procedure
From: Derek Shi (shi.d_at_ghc.org)
Date: 01/06/05
- Next message: Hilary Cotter: "Re: Problem Transact-SQL Statement"
- Previous message: Allen Yu: "Problem Transact-SQL Statement"
- In reply to: Adam Machanic: "Re: sorting variables in a stored procedure"
- Next in thread: Adam Machanic: "Re: sorting variables in a stored procedure"
- Reply: Adam Machanic: "Re: sorting variables in a stored procedure"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 6 Jan 2005 08:58:31 -0800
For example: I need to insert 5 parameters @p1, @p2, @p3,
@p4, @p5 into one row in a table NUMBER_TABLE, such as
follows:
NUMBER_TABLE
n1 n2 n3 n4 n5
-- -- -- -- --
7 12 45 67 78
I need the numbers to be sorted before insert because I
need to calculate some statistics for each n1, n2, ... n5.
However, when the procedure is called (supposing procedure
is AddNumber @p1 int, @p2 int, @p3 int, @p4 int, @p5 int
As ...), the user might enter like this:
Exec AddNumber 12, 7, 45, 78, 67
I need to sort those five numbers from the smallest to the
largest before do the insertion. Hope it helps.
Thanks,
Derek
>-----Original Message-----
>Can you post some more information on this? How will you
know what order
>they were inserted in? Why does it matter if they were
passed in randomly?
>Can't you just order them when you select from the table?
>
>--
>Adam Machanic
>SQL Server MVP
>http://www.sqljunkies.com/weblog/amachanic
>--
>
>
>"Derek Shi" <shi.d@ghc.org> wrote in message
>news:0ac601c4f37d$357c59e0$a601280a@phx.gbl...
>> Hi,
>>
>> I have a stored procedure with 5 integer parameters
passed
>> in. Those 5 integers need to be stored in one table row
>> from the smallest one to the largest. But when the
>> procedure is used, the 5 integers will be randomly
passed
>> in. How can I sort them inside the procedure before
insert
>> them into a table row?
>>
>> Thanks,
>>
>> Derek
>
>
>.
>
- Next message: Hilary Cotter: "Re: Problem Transact-SQL Statement"
- Previous message: Allen Yu: "Problem Transact-SQL Statement"
- In reply to: Adam Machanic: "Re: sorting variables in a stored procedure"
- Next in thread: Adam Machanic: "Re: sorting variables in a stored procedure"
- Reply: Adam Machanic: "Re: sorting variables in a stored procedure"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|