Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
bmorency
Starting Member
3 Posts |
Posted - 2011-06-06 : 15:05:52
|
| Hi,I am looking for tips on how to figure out why my sql query does not return some records. My query is linked to a crystal report.My query returns purchase order data from the database. Most purchase orders are retrieved but some are not for some reason. I am thinking some fields are possibly NULL but have no idea what fields are causing my records to not show up. The purchase order does exist as I can query just the purchase order table and it is there. All the data for a purchase order is not stored in one table. I mean customer/vendor contact info is in another table, item data is in another tableDoes anyone have tips how to debug this type of issue?If more info is needed or if I need to make things clearer let me know and I can explain it a bit more.edit: I forgot to mention that I am using MS sql 2008 standard. |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-06-06 : 15:30:48
|
I generally start by running the query in SSMS... try eliminating where clause conditions and then add them back 1 by 1. Same with joins if possibleCorey I Has Returned!! |
 |
|
|
bmorency
Starting Member
3 Posts |
Posted - 2011-06-06 : 15:39:55
|
| I am running it in SSMS right now. The only where clause I have is the one to pick a specific purchase order. As for joins should I take out all joins at once and start adding them back in or should I take one out at a time and see if it helps, if nothing changes but it back in and take out another one?BTW, I have 18 tables in my query.Thanks |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-06-07 : 05:39:27
|
Well since you only have the 1 where condition, your problem is probably going to be an 'inner join'd table. hopefully you don't have 17 inner joins. Keep in mind, you only need to comment them out, so it shouldn't be too bad to remove them all and add them back in 1 at a timeCorey I Has Returned!! |
 |
|
|
bmorency
Starting Member
3 Posts |
Posted - 2011-06-07 : 11:20:10
|
| Ok thanks for the tips. I fixed my query and all the required records are now being returned. |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-06-07 : 12:36:08
|
No problem. Thank you for showing effort, and not just posting up a truck load of info and making us sort it out for you. Corey I Has Returned!! |
 |
|
|
|
|
|