I have to get 500 customer ids from order date >=1/1/2008 to order date <1/1/2013. Currently in my code I am using top 500 but that is pulling only customer ids from 2008 and 2009. Is there a way that I can get a broader range of customers spread out from 2008 to 2012?
Are you saying that you want to limit the number you get at one time to 500 but the criteria would return many more? One way would be to include an ORDER BY clause. If you want the most recent then you can order by orderDate descending. If you really need some sort of even distribution across that time range then you need to define what the rules should be. Perhaps you can get lucky by ordering by something unrelated to date like customerName.
EDIT: the more obvious answer: Remove the "top 500". that will give you your full distribution for your daterange.
Thank you so much for the replies. I am out sick and could not get back. I used both the suggestions and it is working but not what the client expects :-) Thanks again