By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Sql Dynamic query on Join with While loop

P: 5
Expand|Select|Wrap|Line Numbers
  1. Select TM.Order_code , TI.Order_NUMBER From OrderCheck TM 
  2. Inner join OrderTable TI
  3. ON TM.OrderCode = TI.OrderCode 
  4. Where OrderDate = @L_INV_DATE 
  6. ELSE 
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_code ) 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
Oct 28 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,430
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.
Oct 29 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.