Click here to Skip to main content
       

Database

 
AnswerRe: SMO Retrieve Table Record Pinmembersavbace28-Jan-13 3:40 
Questionhow can reporting in this Situation [modified] Pinmemberkarimkpg26-Jan-13 2:38 
AnswerRe: how can reporting in this Situation PinmvpSandeep Mewara26-Jan-13 6:02 
QuestionQuery to concatenate multiple rows based on sequence in results set PinmemberAlex Lush24-Jan-13 22:43 
AnswerRe: Query to concatenate multiple rows based on sequence in results set PinmvpEddy Vluggen25-Jan-13 1:51 
AnswerRe: Query to concatenate multiple rows based on sequence in results set PinmemberShameel25-Jan-13 3:20 
GeneralRe: Query to concatenate multiple rows based on sequence in results set PinmemberAlex Lush25-Jan-13 3:30 
AnswerRe: Query to concatenate multiple rows based on sequence in results set Pinmembermmccarth25-Jan-13 5:21 
How about a temporary table:
 
create table #t2
(
    order_no          varchar(255),
    order_line_no     int,
    long_description  varchar(8000),
    done              bit
)
 
Insert	Into #t2 (order_no, order_line_no, long_description, done)
Select  order_no, 
        order_line_no, 
        long_description,
        0
From    #t1
Where   line_type = 'p'
 
Declare @i int
Set @i = 1
 
While (Select count(*) From #t2 where Done = 0) > 1
Begin
 
    Update  t2
    Set     t2.long_description = t2.long_description + ' ' + t1.long_description
    From    #t1 t1
    inner join
            #t2 t2
    On      t1.order_no = t2.order_no
    And     t1.order_line_no = t2.order_line_no + @i
    And     t1.line_type <> 'P'
    And     t2.done = 0
    
    
    Update  t2
    Set     t2.done = 1
    From    #t1 t1
    inner join
            #t2 t2
    On      t1.order_no = t2.order_no
    And     t1.order_line_no = t2.order_line_no + @i
    And     t1.line_type = 'P'
 
Set @i = @i + 1
 
End
 
 

You could also use a cursor.
 
Mike
QuestionSyntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 14:40 
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberMycroft Holmes23-Jan-13 15:02 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 15:25 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23-Jan-13 15:37 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 16:16 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23-Jan-13 16:26 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 16:58 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23-Jan-13 16:59 
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmvpRichard MacCutchan23-Jan-13 23:22 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult24-Jan-13 5:48 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro24-Jan-13 5:54 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult24-Jan-13 6:00 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro24-Jan-13 7:11 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult24-Jan-13 7:56 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmvpRichard MacCutchan24-Jan-13 22:35 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro24-Jan-13 5:51 
Questioncreated tables not dropped in a transaction rollback PinmemberDanzy8320-Jan-13 16:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 31 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid