here im getting error when im using union all and order by newid() together, can any one help me to solve this issue..
select distinct * from(select top 500 (A.AdId),A.AdImgPath,A.OnAdURL,A.AdSize from KZ_AdDetails A,KZ_Add_Cat Cat,KZ_Add_City Cit where A.AddU_ID=Cat.AddU_ID and A.AddU_ID=Cit.AddU_ID and AdSize='250x250' order by newid()) X
union all
select distinct * from(select top 500 (A.AdId),A.AdImgPath,A.OnAdURL,A.AdSize from KZ_AdDetails A,KZ_Add_Cat Cat,KZ_Add_District Dis where A.AddU_ID=Cat.AddU_ID and A.AddU_ID=Dis.AddU_ID and AdSize='250x250' order by newid()) Y
regards
Divya
regards
Divya

Iftikar HussainPosted Jun 26, 2013, 3:26 AM
Modify your query as like below
select distinct * from(
Regards,
Iftikar
Remember to click "Mark as Answer" on the post, if it helps you.
Pankaj PandeyPosted May 31, 2013, 7:07 AM
i have varified with insertion of some data manually.
it working....may be this problem is comming with live data..
id you can then do one thing...export data into csv format of all tables, and upload here, i will check it then may be i help you..
divyaPosted May 31, 2013, 6:06 AM
Thanku Pankaj Pandey sir,Have u verified that order by newid is working properly??????
Jignesh TrivediPosted May 31, 2013, 6:02 AM
hi,
with the test data it work fine for me.
Are you getting any error? or data mismatch?
Pankaj PandeyPosted May 31, 2013, 5:43 AM
i have check it but in my machine its working well with data.
may be this problem is with your data.
Pankaj PandeyPosted May 31, 2013, 5:43 AM
i have check it but in my machine its working well with data.
divyaPosted May 31, 2013, 5:11 AM
Thanku for u r response.Here im uploading tables ,please kindly find the attached file.Order by newid() is not working with union all...
Regards
Divya
Pankaj PandeyPosted May 31, 2013, 12:21 AM
please share table scripts and error also.
Jignesh TrivediPosted May 30, 2013, 11:05 PM
Query look ok, and also it work with newid() for my test data.
Can you please error desc?