Sql Dynamic query on Join with While loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kumarlalit
    New Member
    • Oct 2012
    • 5

    Sql Dynamic query on Join with While loop

    Code:
    Select TM.Order_code , TI.Order_NUMBER From OrderCheck TM 
    Inner join OrderTable TI
    ON TM.OrderCode = TI.OrderCode 
    Where OrderDate = @L_INV_DATE 
    PRINT 'NULL VALUE'
    ELSE 
    PRINT 'NOT NULL'
    In the above code i have write the query as per below steps but not giving the proper result , pls sort me out from this problem as the steps to create the above query as mentioned below

    Select all the Order codes(order_cod e ) from OrderCode table
    For each Order code, select the Order Number and Date from Order Master table ( OrderTable ) for all the Orders where date is same as parameter date
    If there are no order for a particular Order_code, select the next Order_code from the OrderCode table and start again from step 1. Otherwise, insert the Date and Order code in the New table OrderDetail table


    Here the OrderDetail table have some column common in the above mentioned table
    Last edited by Rabbit; Oct 29 '12, 05:20 AM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code. This is your second warning.

    Obviously this isn't all the code because you talk about a lot of code that isn't shown in what you posted. It's hard to spot the error if you don't include all the code that you talk about.

    You also say that there are common columns between the tables but you never say what that is. Without the table design, there's no way for us to know what the common columns are.

    All in all, a lot of information is missing that makes it almost impossible to answer the question. Please provide that missing information. It would also help if you posted sample data and results.

    Comment

    Working...