Questione : Come aggiungere ordine vicino in una procedura immagazzinata di SQL

Ho la seguente procedura immagazzinata.  Sto provando ad aggiungere un ORDINE [RQH_iID] DA DESC che funziona per quella variabile ma le altre variabili che non funziona.  Delle idee quanto a come posso convincere questo per funzionare?  Che cosa sto cercando è basicamente per ogni variabile che le informazioni ritornano specie da ordine [RQH_iID].

class= > " libero " del
> " del codeSnippet " del class= del
class= " lineNumbers " del
class= del
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
>USE notpretty " del class= " del id= " codeSnippet960214 del
 
 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
USANO [UTC]
ANDARE
/Oggetto del ******:  StoredProcedure [dbo]. data [sp_utRequestQuoteHeaderListFiltered    ] dello scritto: 08/23/2010 di 15:12: 49 ******/
REGOLARE ANSI_NULLS SOPRA
ANDARE
REGOLARE QUOTED_IDENTIFIER SOPRA
ANDARE

ALTERARE  LA PROCEDURA [dbo]. [sp_utRequestQuoteHeaderListFiltered]
        @UserID int,
        @RQH_iStatus int,
        punta del @OnlyHW,
        punta del @OnlyQR
AS
DICHIARARE il @sql        nvarchar (4000)
REGOLARE NOCOUNT SOPRA
REGOLARE il @sql = '
        SELEZIONARE  [RQH_iID],
        RQH. [UserID],
        [RQH_dDate],
        [RQH_sTicketNumber],
        [STO_iID],
        [RQH_sLocContactName],
        [RQH_sLocContactPhone],
        [RQH_sLocShippingAdress],
        [RQH_sLocShippingAdress1],
        [RQH_sLocShippingAdress2],
        [RQH_sLocShippingCity],
        [RQH_sLocShippingState],
        [RQH_sLocShippingZip],
        [RQH_sTrackingOut1],
        [RQH_sTrackingOut2],
        [RQH_sTrackingOut3],
        [RQH_sTrackingIn1],
        [RQH_sTrackingIn2],
        [RQH_sTrackingIn3],
        [RQH_sNotes],
        [RQH_lHotSwap],
        [RQH_iStatus],
        [RQH_dCreatedOn],
        [RQH_lCancelled],
        [RQH_dClosedOn]
Da utRequestQuoteHeader  RQH DOVE 1=1 '  

Identificazione usuario di/* */
SE @UserID <> 0                                          
        REGOLARE il @sql = il @sql + 'E RQH.UserId = '+ convertito (varchar (20), @UserId)
Condizione di/* */
SE @RQH_iStatus <> -1                                      
        REGOLARE il @sql = il @sql + 'E RQH_iStatus = '+ convertito (varchar (20), @RQH_iStatus)

Scambio caldo di/* */
SE @OnlyHW = 1
        REGOLARE il @sql = il @sql + “E RQH_lHotSwap = 1„

Scambio caldo di/* */
SE @OnlyQR = 1
        REGOLARE il @sql = il @sql + “E (RQH_lHotSwap = 0 o RQH_lHotSwap è nullo)„


REGOLARE il @sql = il @sql + “l'ORDINE [RQH_iID] da DESC„
        
EXEC (@sql)
Altre soluzioni  

 
programming4us programming4us