| Author |
Topic |
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-16 : 05:35:26
|
| question 1) order by company ,(date desc)1)why "SONS" is above in order compraed to "SON"2)wHY Alden is above ALDEN? THANKS FOR HELPA.FINKL & SONS COMPANY 012945491 01/01/2010A.FINKL & SONS COMPANY 012945491 01/01/2009A.FINKL & SON 01/01/2009A.FINKL & SON 01/01/2008Alden Management Services 01/01/2010ALDEN MANAGEMENT SERVICES 015253279 01/01/2010ALDEN MANAGEMENT SERVICES 015253279 01/01/2009________________________-quetion 2 names are equal so as per desc order should be 8,6,5 while result is 6,5,8.This is problem for only this record .for all other result are in descending.any help? MANAGEMENT SERVICES 12/01/2006 MANAGEMENT SERVICES 12/01/2005 MANAGEMENT SERVICES 01/01/2008 |
|
|
paultech
Yak Posting Veteran
79 Posts |
Posted - 2011-10-16 : 07:01:40
|
| i think your databse collation is set to be case sensetive you can overcome that convert.binary .You can use the CONVERT function to convert the data from character format to a string of hexadecimal values.find the following linkhttp://support.microsoft.com/kb/171299good luckpaul Tech |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 07:28:22
|
what does this return?SELECT DATABASEPROPERTYEX('Your database name', 'Collation')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-16 : 08:06:28
|
sql latin1 general cp1 cl asquote: Originally posted by visakh16 what does this return?SELECT DATABASEPROPERTYEX('Your database name', 'Collation')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 13:52:52
|
| then you're currently using a case insensitive collation.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-16 : 13:59:34
|
then what could be solution?thequote: Originally posted by visakh16 then you're currently using a case insensitive collation.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-16 : 14:01:29
|
| you're ordering also by date right. what are associated date values for them?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-16 : 14:23:47
|
actually it is conver varchar(10) date descvalues displayed as in question first post.first on name and if name equal then datequote: Originally posted by visakh16 you're ordering also by date right. what are associated date values for them?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
somsahi
Starting Member
23 Posts |
|
|
jassi.singh
Posting Yak Master
122 Posts |
Posted - 2011-10-17 : 01:33:24
|
| You can select a Cyrillic collation like:order by STR collate Cyrillic_General_CI_AIA full list of collations can be found with a call to:select * from ::fn_helpcollations()CS means Case Sensitive, AI means Accent Insensitive.Please mark answer as accepted if it helped you.Thanks,Jassi Singh |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-17 : 01:36:36
|
quote: Originally posted by somsahi actually it is conver varchar(10) date descvalues displayed as in question first post.first on name and if name equal then datequote: Originally posted by visakh16 you're ordering also by date right. what are associated date values for them?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
why are you converting dates as varchar. if you want to get sorting based on date you need retain them as dates itself.see illustration belowdeclare @tbl table(dateval datetime)insert @tblselect '20100111' union allselect '20101008' union allselect '20110309' union allselect '20110123' union allselect '20100917' union allselect '20100806' union allselect '20091201'--ordering date values as dates itselfselect convert(varchar(10),dateval,105) as [datesorted]from @tblorder by dateval--ordering after converting to varcharselect convert(varchar(10),dateval,105) as [stringsorted]from @tblorder by convert(varchar(10),dateval,105)output------------------------------------datesorted-----------------01-12-200911-01-201006-08-201017-09-201008-10-201023-01-201109-03-2011stringsorted------------------01-12-200906-08-201008-10-201009-03-201111-01-201017-09-201023-01-2011 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-17 : 21:53:27
|
| will check today and update by end of day.i think my code uing stringorted |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-18 : 01:44:43
|
| ok. thats fine------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-18 : 06:07:04
|
| 1)Collate not working2)Used vishal solution(which is working in querymanager ) but when used in java then page is not diplayed.in database effective date datatype is datetimeActual query issql ="select distinct p.I_ProspectID, p.ProspectName, CONVERT(VARCHAR(10), pa.effectivedate, 101) AS [MM/DD/YYYY], " +" pa.MarketOfficeName, p.Status, pa.SmartSuite, pa.UWID, pa.UASID, pa.RUM, pa.UWShop, UWDue, UASDue, pa.SalesMarket, pa.FundingType, p.isLockedPerm " +" FROM dbo.EWS_Prospect p INNER JOIN" +" dbo.EWS_RFP r ON p.I_ProspectId = r.I_ProspectID INNER JOIN" +" dbo.EWS_Proposal pr ON r.I_RFPID = pr.I_RFPID INNER JOIN" +" dbo.EWS_Package pa ON pr.I_ProposalID = pa.I_ParentProposalID " +" where p.ProspectName like ? and p.GroupID like ? " +uwLocSql + uwSql + uasSql + mktSql + agSql + ftSql + statusSql + effDtSql + sMktSql + asfSrchSql +" order by p.ProspectName, CONVERT(VARCHAR(10), pa.effectivedate, 101) DESC"; |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-18 : 07:49:12
|
| why page is not displayed while used in java? is it throwing some exception?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
somsahi
Starting Member
23 Posts |
Posted - 2011-10-18 : 09:06:20
|
| yes page not found 404.I have written query also.will be back after 3 hour.but in querymanager it is working |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-18 : 09:44:54
|
| that means somewhere its breaking in java code. can you step through and find exact place where it breaks in java?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|