Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Sort sequence in SqlServer2005
I have a file that has a record in it with the ID [All] (including the
"[" and "]" characters). When I do a sort on the file, this record comes
out before the other alphanumeric IDs, even though the "[" character is
after the letter "Z" in the ASCII chart (char(91) for "[" vs char(90)
for "Z"). Also upper and lower case IDs are mixed together rather than
separated by case.

Looking through some documentation, I see there is a collating property
which must be set. However, all the documentation indicates that this
must be done during Setup. Is there a way to change the collating
sequence even after setup via SqlServer Management Studio? Also, what is
the correct collation choice I should use to get the ASCII sequencing?

Thanks

Report this thread to moderator Post Follow-up to this message
Old Post
SH
03-30-06 02:23 PM


RE: Sort sequence in SqlServer2005
Hi

You can use the collate keyword in your select statement to force a
collation, although if your default collation is wrong then you should chang
e
it. e.g http://tinyurl.com/n9jna

John


"SH" wrote:

> I have a file that has a record in it with the ID [All] (including the
> "[" and "]" characters). When I do a sort on the file, this record com
es
> out before the other alphanumeric IDs, even though the "[" character i
s
> after the letter "Z" in the ASCII chart (char(91) for "[" vs char(90)
> for "Z"). Also upper and lower case IDs are mixed together rather than
> separated by case.
>
> Looking through some documentation, I see there is a collating property
> which must be set. However, all the documentation indicates that this
> must be done during Setup. Is there a way to change the collating
> sequence even after setup via SqlServer Management Studio? Also, what is
> the correct collation choice I should use to get the ASCII sequencing?
>
> Thanks
>

Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
03-30-06 04:23 PM


Re: Sort sequence in SqlServer2005
Thanks, John.

I'm wondering if there is a way to set the whole SqlServer (or at least
the whole database) to the proper collating sequence without having to
use the COLLATE keyword whenever I run into this problem.

John Bell  wrote:[color=darkred
]
> Hi
>
> You can use the collate keyword in your select statement to force a
> collation, although if your default collation is wrong then you should cha
nge
> it. e.g http://tinyurl.com/n9jna
>
> John
>
>
> "SH" wrote:
>
> 

Report this thread to moderator Post Follow-up to this message
Old Post
SH
03-31-06 01:23 AM


Re: Sort sequence in SqlServer2005
SH  wrote:
> Thanks, John.
>
> I'm wondering if there is a way to set the whole SqlServer (or at least
> the whole database) to the proper collating sequence without having to
> use the COLLATE keyword whenever I run into this problem.
>

You can set a default for the database (ALTER DATABASE) but because the
collation is set on each column anyway that doesn't help if you've
already created the tables. Also consider that a BIN (binary) collation
is case-sensitive, which is inconvenient in many cases. Changing the
database collation from case-insensitive to case-sensitive will break
any code that doesn't use the proper case to reference objects.

In your case I would just order by another column or use CASE
expressions to fix the order.

...
ORDER BY
CASE WHEN x = '[all]' THEN 1 ELSE NULL END, x

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--


Report this thread to moderator Post Follow-up to this message
Old Post
David Portas
03-31-06 01:23 AM


Re: Sort sequence in SqlServer2005
Hi

It sounds like you need to change the default at all levels rather than just
the columns. In which case you will need to change it a column, database and
system level. There are many posts that already describe how to do this.

If you only specify it database level or for specific columns you may need
to make sure that you force the collation on temporary tables that are used
with these columns otherwise there could be collation conflicts.

John

"SH" wrote:

> Thanks, John.
>
> I'm wondering if there is a way to set the whole SqlServer (or at least
> the whole database) to the proper collating sequence without having to
> use the COLLATE keyword whenever I run into this problem.
>
> John Bell wrote: 
>

Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
03-31-06 08:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 07:47 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006