Hello there
I need to alter the collation of collumns on my databases.
It failes on columns that connected to indexes
What should i do to alter them in this case?You'll need to drop the indexes/constraints and recreate after changing the
collation.
Hope this helps.
Dan Guzman
SQL Server MVP
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%237WdGTuOGHA.3896@.TK2MSFTNGP15.phx.gbl...
> Hello there
> I need to alter the collation of collumns on my databases.
> It failes on columns that connected to indexes
> What should i do to alter them in this case?
>
>|||Drop the indexes (and any constraints) first, then alter the column and
restore the indexes (and constraints).
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:%237WdGTuOGHA.3896@.TK2MSFTNGP15.phx.gbl...
Hello there
I need to alter the collation of collumns on my databases.
It failes on columns that connected to indexes
What should i do to alter them in this case?|||Whell Tom
It seems to be very agly to do that.
When i do it with the enterprise Manager i don't do all this stuff
Are you sure i need to do all of that?
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:ev8nGguOGHA.2704@.TK2MSFTNGP15.phx.gbl...
> Drop the indexes (and any constraints) first, then alter the column and
> restore the indexes (and constraints).
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> .
> "Roy Goldhammer" <roy@.hotmail.com> wrote in message
> news:%237WdGTuOGHA.3896@.TK2MSFTNGP15.phx.gbl...
> Hello there
> I need to alter the collation of collumns on my databases.
> It failes on columns that connected to indexes
> What should i do to alter them in this case?
>
>|||
Roy Goldhammer wrote:
>Whell Tom
>It seems to be very agly to do that.
>When i do it with the enterprise Manager i don't do all this stuff
>
Enterprise Manager probably does it for you behind the scenes. While
EM doesn't do everything in the best way, you could generate the change
script from EM and use it as a template for creating your own script. If
an index exists on a varchar column, and then the collation is changed,
the index must be rebuilt. There's no way around it, since a change in
collation may change the ordering of the values, which is what the
index is there to implement.
Steve Kass
Drew University
>Are you sure i need to do all of that?
>"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
>news:ev8nGguOGHA.2704@.TK2MSFTNGP15.phx.gbl...
>
>
>
Showing posts with label collation. Show all posts
Showing posts with label collation. Show all posts
Tuesday, March 27, 2012
Wednesday, March 7, 2012
Alter Database Collation ( If possible )
Dear Experts
Can i change my existing database collation with new one ,if it is possible than how i will be done
Thank's for any suggesion
Faheem Lati
NETWORK SOLUTIONHello Faheem,
You can change the default database collation by writing something like
this:
ALTER DATABSE [testing] COLLATE French_CI_AS
But - this will only change the collation for any new tables. Already
created tables will keep their collation, and you have to change them also,
if that's what you're looking for. Look in BOL for the ALTER TABLE syntax to
change the collation of a table.
HTH,
Andrés Taylor
"Faheem" <anonymous@.discussions.microsoft.com> wrote in message
news:EFF8D2E4-951F-470B-B75D-DFCCE4F1C237@.microsoft.com...
> Dear Experts ,
> Can i change my existing database collation with new one ,if it is
possible than how i will be done.
> Thank's for any suggesion .
> Faheem Latif
> NETWORK SOLUTION
Can i change my existing database collation with new one ,if it is possible than how i will be done
Thank's for any suggesion
Faheem Lati
NETWORK SOLUTIONHello Faheem,
You can change the default database collation by writing something like
this:
ALTER DATABSE [testing] COLLATE French_CI_AS
But - this will only change the collation for any new tables. Already
created tables will keep their collation, and you have to change them also,
if that's what you're looking for. Look in BOL for the ALTER TABLE syntax to
change the collation of a table.
HTH,
Andrés Taylor
"Faheem" <anonymous@.discussions.microsoft.com> wrote in message
news:EFF8D2E4-951F-470B-B75D-DFCCE4F1C237@.microsoft.com...
> Dear Experts ,
> Can i change my existing database collation with new one ,if it is
possible than how i will be done.
> Thank's for any suggesion .
> Faheem Latif
> NETWORK SOLUTION
Alter Database Collation ( If possible )
Dear Experts ,
Can i change my existing database collation with new one ,if it is possible than how i will be done.
Thank's for any suggesion .
Faheem Latif
NETWORK SOLUTION
Hello Faheem,
You can change the default database collation by writing something like
this:
ALTER DATABSE [testing] COLLATE French_CI_AS
But - this will only change the collation for any new tables. Already
created tables will keep their collation, and you have to change them also,
if that's what you're looking for. Look in BOL for the ALTER TABLE syntax to
change the collation of a table.
HTH,
Andrs Taylor
"Faheem" <anonymous@.discussions.microsoft.com> wrote in message
news:EFF8D2E4-951F-470B-B75D-DFCCE4F1C237@.microsoft.com...
> Dear Experts ,
> Can i change my existing database collation with new one ,if it is
possible than how i will be done.
> Thank's for any suggesion .
> Faheem Latif
> NETWORK SOLUTION
Can i change my existing database collation with new one ,if it is possible than how i will be done.
Thank's for any suggesion .
Faheem Latif
NETWORK SOLUTION
Hello Faheem,
You can change the default database collation by writing something like
this:
ALTER DATABSE [testing] COLLATE French_CI_AS
But - this will only change the collation for any new tables. Already
created tables will keep their collation, and you have to change them also,
if that's what you're looking for. Look in BOL for the ALTER TABLE syntax to
change the collation of a table.
HTH,
Andrs Taylor
"Faheem" <anonymous@.discussions.microsoft.com> wrote in message
news:EFF8D2E4-951F-470B-B75D-DFCCE4F1C237@.microsoft.com...
> Dear Experts ,
> Can i change my existing database collation with new one ,if it is
possible than how i will be done.
> Thank's for any suggesion .
> Faheem Latif
> NETWORK SOLUTION
Alter Database Collation ( If possible )
Dear Experts ,
Can i change my existing database collation with new one ,if it is possible
than how i will be done.
Thank's for any suggesion .
Faheem Latif
NETWORK SOLUTIONHello Faheem,
You can change the default database collation by writing something like
this:
ALTER DATABSE [testing] COLLATE French_CI_AS
But - this will only change the collation for any new tables. Already
created tables will keep their collation, and you have to change them also,
if that's what you're looking for. Look in BOL for the ALTER TABLE syntax to
change the collation of a table.
HTH,
Andrs Taylor
"Faheem" <anonymous@.discussions.microsoft.com> wrote in message
news:EFF8D2E4-951F-470B-B75D-DFCCE4F1C237@.microsoft.com...
> Dear Experts ,
> Can i change my existing database collation with new one ,if it is
possible than how i will be done.
> Thank's for any suggesion .
> Faheem Latif
> NETWORK SOLUTION
Can i change my existing database collation with new one ,if it is possible
than how i will be done.
Thank's for any suggesion .
Faheem Latif
NETWORK SOLUTIONHello Faheem,
You can change the default database collation by writing something like
this:
ALTER DATABSE [testing] COLLATE French_CI_AS
But - this will only change the collation for any new tables. Already
created tables will keep their collation, and you have to change them also,
if that's what you're looking for. Look in BOL for the ALTER TABLE syntax to
change the collation of a table.
HTH,
Andrs Taylor
"Faheem" <anonymous@.discussions.microsoft.com> wrote in message
news:EFF8D2E4-951F-470B-B75D-DFCCE4F1C237@.microsoft.com...
> Dear Experts ,
> Can i change my existing database collation with new one ,if it is
possible than how i will be done.
> Thank's for any suggesion .
> Faheem Latif
> NETWORK SOLUTION
ALTER DATABASE and schema bound views.
Hello, everyone!
The question is: Can I alter the collation of a database
inside which there is a schema bound view, under SQL
Server 2000?
If you could help me with it, I'd ve extremely thankful.
We've got a product which is commercialized
internationally.
In order to do so, we have a basic database, and we alter
its collation to fit the target market.
Lately, we added a materialized view, and the ALTER
DATABASE COLLATE... command stopped working.
This is part of the script:
SELECT DATABASEPROPERTYEX('db', 'Collation') --
'SQL_Latin1_General_CP1255_CI_AS'
GO
DROP VIEW [DBO].[MATERIAL_VIEW_001]
GO
CREATE VIEW [DBO].[MATERIAL_VIEW_001]
WITH SCHEMABINDING
AS
SELECT DV.[DEPARTMENT], -- char(10)
DV.[FILENUM], -- tinyint
DV.[FIELDNUM], -- smallint
DV.[FROM_DATE], -- datetime
DV.[VALUE], -- varchar(1024), usually <
20.
EI.[DEP_INF] -- tinyint
FROM [DBO].[DEPVAL] DV WITH (NOLOCK)
JOIN [DBO].[EMPINF] EI WITH (NOLOCK)
ON EI.FILENUM = DV.FILENUM -- tinyint
AND EI.FIELDNUM = DV.FIELDNUM -- smallint
WHERE EI.DEP_INF > 0 -- tinyint
GO
CREATE UNIQUE CLUSTERED INDEX PK_MATERIAL_VIEW_001
ON DBO.[MATERIAL_VIEW_001]
( [DEPARTMENT], [FILENUM], [FIELDNUM], [FROM_DATE],
[DEP_INF], [VALUE] )
GO
-- drop index lv_depval_inf.pk_MATERIAL_VIEW_001 -- This
doesn't help.
ALTER DATABASE DB COLLATE French_CI_AS
/*
Server: Msg 5075, Level 16, State 1, Line 1
The object 'MATERIAL_VIEW_001' is dependent on database
collation.
Server: Msg 5072, Level 16, State 1, Line 1
ALTER DATABASE failed. The default collation of
database 'db' cannot be set to French_CI_AS.
*/
Can you help me with this?
Thanks in advance,
PabloHi
You don't mention if you change the column collations? e.g
http://tinyurl.com/91sg
I would also expect you to check what collation the system is set to:
Select SERVERPROPERTY(N'Collation')
I would expect the way around this is to drop and re-create the view after
you have changed the collation.
John
"Pablo Aliskevicius" wrote:
> Hello, everyone!
> The question is: Can I alter the collation of a database
> inside which there is a schema bound view, under SQL
> Server 2000?
> If you could help me with it, I'd ve extremely thankful.
> We've got a product which is commercialized
> internationally.
> In order to do so, we have a basic database, and we alter
> its collation to fit the target market.
> Lately, we added a materialized view, and the ALTER
> DATABASE COLLATE... command stopped working.
> This is part of the script:
> SELECT DATABASEPROPERTYEX('db', 'Collation') --
> 'SQL_Latin1_General_CP1255_CI_AS'
> GO
> DROP VIEW [DBO].[MATERIAL_VIEW_001]
> GO
> CREATE VIEW [DBO].[MATERIAL_VIEW_001]
> WITH SCHEMABINDING
> AS
> SELECT DV.[DEPARTMENT], -- char(10)
> DV.[FILENUM], -- tinyint
> DV.[FIELDNUM], -- smallint
> DV.[FROM_DATE], -- datetime
> DV.[VALUE], -- varchar(1024), usually <
> 20.
> EI.[DEP_INF] -- tinyint
> FROM [DBO].[DEPVAL] DV WITH (NOLOCK)
> JOIN [DBO].[EMPINF] EI WITH (NOLOCK)
> ON EI.FILENUM = DV.FILENUM -- tinyint
> AND EI.FIELDNUM = DV.FIELDNUM -- smallint
> WHERE EI.DEP_INF > 0 -- tinyint
> GO
> CREATE UNIQUE CLUSTERED INDEX PK_MATERIAL_VIEW_001
> ON DBO.[MATERIAL_VIEW_001]
> ( [DEPARTMENT], [FILENUM], [FIELDNUM], [FROM_DATE],
> [DEP_INF], [VALUE] )
> GO
> -- drop index lv_depval_inf.pk_MATERIAL_VIEW_001 -- This
> doesn't help.
> ALTER DATABASE DB COLLATE French_CI_AS
> /*
> Server: Msg 5075, Level 16, State 1, Line 1
> The object 'MATERIAL_VIEW_001' is dependent on database
> collation.
> Server: Msg 5072, Level 16, State 1, Line 1
> ALTER DATABASE failed. The default collation of
> database 'db' cannot be set to French_CI_AS.
> */
> Can you help me with this?
>
> Thanks in advance,
> Pablo
>|||Thank you, John, for your answer.
Maybe I wasn't clear enough: the application I'm
supporting has dozens of installations in at least ten
countries (that I know of) spanning three continents (or
four, if you count South America and North America as
two). Two more countries will be added in the next few
months. As a result, the server collation can be just
about any.
The software works on top of SQL Server. Since the
software is alive, the database keeps changing: fields
are added to existing tables, new tables and procedures
are added from time to time, new views appear from time
to time. We have already dozens of tables, and over 300
procedures.
As a result, an automatic upgrade program was written,
which compares the production database at the client's
site, with a 'last model' database. This 'last model'
exists in one place only, with one collation only.
In order to compare the databases, the 'model' database
must assume the 'target' database's collation.
Since there are a LOT of objects, dropping and recreating
objects can be done only as a last resource. A way to
execute ALTER DATABASE even when a schema-bound view
exists would be the best possible solution. After that, I
run a script quite like the one described in the URL you
mention - but the DATABASE_DEFAULT is UNKNOWN until run
time.
Thanks again,
Pablo.
>--Original Message--
>Hi
>You don't mention if you change the column collations?
e.g
>http://tinyurl.com/91sg
>I would also expect you to check what collation the
system is set to:
>Select SERVERPROPERTY(N'Collation')
>I would expect the way around this is to drop and re-
create the view after
>you have changed the collation.
>John
>
The question is: Can I alter the collation of a database
inside which there is a schema bound view, under SQL
Server 2000?
If you could help me with it, I'd ve extremely thankful.
We've got a product which is commercialized
internationally.
In order to do so, we have a basic database, and we alter
its collation to fit the target market.
Lately, we added a materialized view, and the ALTER
DATABASE COLLATE... command stopped working.
This is part of the script:
SELECT DATABASEPROPERTYEX('db', 'Collation') --
'SQL_Latin1_General_CP1255_CI_AS'
GO
DROP VIEW [DBO].[MATERIAL_VIEW_001]
GO
CREATE VIEW [DBO].[MATERIAL_VIEW_001]
WITH SCHEMABINDING
AS
SELECT DV.[DEPARTMENT], -- char(10)
DV.[FILENUM], -- tinyint
DV.[FIELDNUM], -- smallint
DV.[FROM_DATE], -- datetime
DV.[VALUE], -- varchar(1024), usually <
20.
EI.[DEP_INF] -- tinyint
FROM [DBO].[DEPVAL] DV WITH (NOLOCK)
JOIN [DBO].[EMPINF] EI WITH (NOLOCK)
ON EI.FILENUM = DV.FILENUM -- tinyint
AND EI.FIELDNUM = DV.FIELDNUM -- smallint
WHERE EI.DEP_INF > 0 -- tinyint
GO
CREATE UNIQUE CLUSTERED INDEX PK_MATERIAL_VIEW_001
ON DBO.[MATERIAL_VIEW_001]
( [DEPARTMENT], [FILENUM], [FIELDNUM], [FROM_DATE],
[DEP_INF], [VALUE] )
GO
-- drop index lv_depval_inf.pk_MATERIAL_VIEW_001 -- This
doesn't help.
ALTER DATABASE DB COLLATE French_CI_AS
/*
Server: Msg 5075, Level 16, State 1, Line 1
The object 'MATERIAL_VIEW_001' is dependent on database
collation.
Server: Msg 5072, Level 16, State 1, Line 1
ALTER DATABASE failed. The default collation of
database 'db' cannot be set to French_CI_AS.
*/
Can you help me with this?
Thanks in advance,
PabloHi
You don't mention if you change the column collations? e.g
http://tinyurl.com/91sg
I would also expect you to check what collation the system is set to:
Select SERVERPROPERTY(N'Collation')
I would expect the way around this is to drop and re-create the view after
you have changed the collation.
John
"Pablo Aliskevicius" wrote:
> Hello, everyone!
> The question is: Can I alter the collation of a database
> inside which there is a schema bound view, under SQL
> Server 2000?
> If you could help me with it, I'd ve extremely thankful.
> We've got a product which is commercialized
> internationally.
> In order to do so, we have a basic database, and we alter
> its collation to fit the target market.
> Lately, we added a materialized view, and the ALTER
> DATABASE COLLATE... command stopped working.
> This is part of the script:
> SELECT DATABASEPROPERTYEX('db', 'Collation') --
> 'SQL_Latin1_General_CP1255_CI_AS'
> GO
> DROP VIEW [DBO].[MATERIAL_VIEW_001]
> GO
> CREATE VIEW [DBO].[MATERIAL_VIEW_001]
> WITH SCHEMABINDING
> AS
> SELECT DV.[DEPARTMENT], -- char(10)
> DV.[FILENUM], -- tinyint
> DV.[FIELDNUM], -- smallint
> DV.[FROM_DATE], -- datetime
> DV.[VALUE], -- varchar(1024), usually <
> 20.
> EI.[DEP_INF] -- tinyint
> FROM [DBO].[DEPVAL] DV WITH (NOLOCK)
> JOIN [DBO].[EMPINF] EI WITH (NOLOCK)
> ON EI.FILENUM = DV.FILENUM -- tinyint
> AND EI.FIELDNUM = DV.FIELDNUM -- smallint
> WHERE EI.DEP_INF > 0 -- tinyint
> GO
> CREATE UNIQUE CLUSTERED INDEX PK_MATERIAL_VIEW_001
> ON DBO.[MATERIAL_VIEW_001]
> ( [DEPARTMENT], [FILENUM], [FIELDNUM], [FROM_DATE],
> [DEP_INF], [VALUE] )
> GO
> -- drop index lv_depval_inf.pk_MATERIAL_VIEW_001 -- This
> doesn't help.
> ALTER DATABASE DB COLLATE French_CI_AS
> /*
> Server: Msg 5075, Level 16, State 1, Line 1
> The object 'MATERIAL_VIEW_001' is dependent on database
> collation.
> Server: Msg 5072, Level 16, State 1, Line 1
> ALTER DATABASE failed. The default collation of
> database 'db' cannot be set to French_CI_AS.
> */
> Can you help me with this?
>
> Thanks in advance,
> Pablo
>|||Thank you, John, for your answer.
Maybe I wasn't clear enough: the application I'm
supporting has dozens of installations in at least ten
countries (that I know of) spanning three continents (or
four, if you count South America and North America as
two). Two more countries will be added in the next few
months. As a result, the server collation can be just
about any.
The software works on top of SQL Server. Since the
software is alive, the database keeps changing: fields
are added to existing tables, new tables and procedures
are added from time to time, new views appear from time
to time. We have already dozens of tables, and over 300
procedures.
As a result, an automatic upgrade program was written,
which compares the production database at the client's
site, with a 'last model' database. This 'last model'
exists in one place only, with one collation only.
In order to compare the databases, the 'model' database
must assume the 'target' database's collation.
Since there are a LOT of objects, dropping and recreating
objects can be done only as a last resource. A way to
execute ALTER DATABASE even when a schema-bound view
exists would be the best possible solution. After that, I
run a script quite like the one described in the URL you
mention - but the DATABASE_DEFAULT is UNKNOWN until run
time.
Thanks again,
Pablo.
>--Original Message--
>Hi
>You don't mention if you change the column collations?
e.g
>http://tinyurl.com/91sg
>I would also expect you to check what collation the
system is set to:
>Select SERVERPROPERTY(N'Collation')
>I would expect the way around this is to drop and re-
create the view after
>you have changed the collation.
>John
>
Alter Dabatase Collation
ALTER DATABASE <database name>
COLLATE SQL_Latin1_General_Cp1_CI_AS
Can anyone tell me the implication of using the above SQL statement against a database. I am running a third party financial planning software application that communicates with an SQL2000 database component. The database vendor has specified a collation setting of : charset=iso_1 sort_order=nocase_iso charset_num=1 sort_order_num=52 My SQL Server default instance is case insensitive. Will an alter database command adequately change all elements required or may i still encounter operating problems with the software due to conflicting collation issues?This would change the default collation for the database. Any objects created after this would take up this collation unless otherwise stated.
All of your previously created objects will retain their collation(s) however. I suggest you take a look at "collate" in sql book online for some details on handling multi collations.|||Thanks Oj
If I wanted all future databases to inherit the new collation setting using the ALTER DATABASE command, could i safely alter the model database from which all other databases inherit collation settings?
Would this be a safe method as there is no data in there as yet?|||Sure. That is what Model is intended to be used.
Do be aware that you could specify the desired collation when creating the database (whether or not it's the same as model). Take a look at 'collate' option of the 'create database' in sql book online.
COLLATE SQL_Latin1_General_Cp1_CI_AS
Can anyone tell me the implication of using the above SQL statement against a database. I am running a third party financial planning software application that communicates with an SQL2000 database component. The database vendor has specified a collation setting of : charset=iso_1 sort_order=nocase_iso charset_num=1 sort_order_num=52 My SQL Server default instance is case insensitive. Will an alter database command adequately change all elements required or may i still encounter operating problems with the software due to conflicting collation issues?This would change the default collation for the database. Any objects created after this would take up this collation unless otherwise stated.
All of your previously created objects will retain their collation(s) however. I suggest you take a look at "collate" in sql book online for some details on handling multi collations.|||Thanks Oj
If I wanted all future databases to inherit the new collation setting using the ALTER DATABASE command, could i safely alter the model database from which all other databases inherit collation settings?
Would this be a safe method as there is no data in there as yet?|||Sure. That is what Model is intended to be used.
Do be aware that you could specify the desired collation when creating the database (whether or not it's the same as model). Take a look at 'collate' option of the 'create database' in sql book online.
Labels:
alter,
collation,
dabatase,
database,
implication,
ltdatabase,
microsoft,
mysql,
namegtcollate,
oracle,
server,
sql,
sql_latin1_general_cp1_ci_ascan,
statement
Friday, February 24, 2012
Alpha-Numeric Collation
I have a column of data that needs to be sorted alpha-numerically.
Rules: I can not do this in a SQL Select statement or programming on the
middle-tier. It must be set as an index or some sort of collation property
of the collumn.
Data Example: This is the order it is returning.
PSW1
PSW2
PSW17
PSW3
I need it to return like this:
PSW1
PSW2
PSW3
PSW17
Is this possible with a certain type of index or collation setting?
Firstly this is not having a go at you personally but this question occurs
time and time again so I will explain my experiences and solution.
Secondly it does not provide you with a complete solution. I'm sorry. (but
you may be able to write a function that returns an integer of the first
numeric and then sort on the substrings)
ORDER BY SUBSTRING([Key], 1, [dbo].fn_FirstNumeric([Key]) -1),
CONVERT(INT,SUBSTRING([Key], [dbo].fn_FirstNumeric([Key]), 999))
WHERE the function looks like
CREATE FUNCTION fn_FirstNumeric ( @.Data NVARCHAR(255) ) RETURNS INT
AS
BEGIN
RETURN PATINDEX('%[0-9]%', @.Data)
END
It may be that my explanation of your situation is not correct but it seems
that you have a key PSW17 which should be further sub-divided into
constituent keys.
While working for a very large semi-conductor manufacturing company I was
asked to perform exactly the same sort of collation/sorting on part numbers
such as
SNJ74LS145J
SNC72LP245N
SNB74S174N
the first 3 characters meant something specific so did the next 2 numbers,
the middle letters also, then the next digits something else and finally the
last character.
If I remember correctly it was (in that order)
Specification type/burn type (components were subjected to high temperaturs
and re-tested, those that still worked were sold to military)
Can't remember the next one
Another spec type L = low power, LS = low power Schottkey
Parent bar type (all 174 bars became either military, standard, encapsulated
in plastic or ceramic).
Package (plastic, ceramic)
You can imagine trying to get at data when asked
"I want all low power schottkey with parent bar 174 for non-military"
So we decided that at the point of data entry the part number would be split
up into into constituent parts and for display puproses the parts were
concatenated to provide the complete part number. We could then process the
data as requested as each part was in a seperate column.
So what's is the point of explaining this?
Well, SQL manages "Databases" the first part of this word is Data and if
this is not correct then you do not have a database but a base of data which
your will struggle with. You must correctly normalize and identify all
correct data parts, keys and sub-key for your system to work correctly.
Nik Marshall-Blank MCSD/MCDBA
"Eric Laechelin" <EricLaechelin@.discussions.microsoft.com> wrote in message
news:36414A3C-54F4-43FD-9633-F95918E47A84@.microsoft.com...
>I have a column of data that needs to be sorted alpha-numerically.
> Rules: I can not do this in a SQL Select statement or programming on the
> middle-tier. It must be set as an index or some sort of collation
> property
> of the collumn.
> Data Example: This is the order it is returning.
> PSW1
> PSW2
> PSW17
> PSW3
> I need it to return like this:
> PSW1
> PSW2
> PSW3
> PSW17
> Is this possible with a certain type of index or collation setting?
Rules: I can not do this in a SQL Select statement or programming on the
middle-tier. It must be set as an index or some sort of collation property
of the collumn.
Data Example: This is the order it is returning.
PSW1
PSW2
PSW17
PSW3
I need it to return like this:
PSW1
PSW2
PSW3
PSW17
Is this possible with a certain type of index or collation setting?
Firstly this is not having a go at you personally but this question occurs
time and time again so I will explain my experiences and solution.
Secondly it does not provide you with a complete solution. I'm sorry. (but
you may be able to write a function that returns an integer of the first
numeric and then sort on the substrings)
ORDER BY SUBSTRING([Key], 1, [dbo].fn_FirstNumeric([Key]) -1),
CONVERT(INT,SUBSTRING([Key], [dbo].fn_FirstNumeric([Key]), 999))
WHERE the function looks like
CREATE FUNCTION fn_FirstNumeric ( @.Data NVARCHAR(255) ) RETURNS INT
AS
BEGIN
RETURN PATINDEX('%[0-9]%', @.Data)
END
It may be that my explanation of your situation is not correct but it seems
that you have a key PSW17 which should be further sub-divided into
constituent keys.
While working for a very large semi-conductor manufacturing company I was
asked to perform exactly the same sort of collation/sorting on part numbers
such as
SNJ74LS145J
SNC72LP245N
SNB74S174N
the first 3 characters meant something specific so did the next 2 numbers,
the middle letters also, then the next digits something else and finally the
last character.
If I remember correctly it was (in that order)
Specification type/burn type (components were subjected to high temperaturs
and re-tested, those that still worked were sold to military)
Can't remember the next one
Another spec type L = low power, LS = low power Schottkey
Parent bar type (all 174 bars became either military, standard, encapsulated
in plastic or ceramic).
Package (plastic, ceramic)
You can imagine trying to get at data when asked
"I want all low power schottkey with parent bar 174 for non-military"
So we decided that at the point of data entry the part number would be split
up into into constituent parts and for display puproses the parts were
concatenated to provide the complete part number. We could then process the
data as requested as each part was in a seperate column.
So what's is the point of explaining this?
Well, SQL manages "Databases" the first part of this word is Data and if
this is not correct then you do not have a database but a base of data which
your will struggle with. You must correctly normalize and identify all
correct data parts, keys and sub-key for your system to work correctly.
Nik Marshall-Blank MCSD/MCDBA
"Eric Laechelin" <EricLaechelin@.discussions.microsoft.com> wrote in message
news:36414A3C-54F4-43FD-9633-F95918E47A84@.microsoft.com...
>I have a column of data that needs to be sorted alpha-numerically.
> Rules: I can not do this in a SQL Select statement or programming on the
> middle-tier. It must be set as an index or some sort of collation
> property
> of the collumn.
> Data Example: This is the order it is returning.
> PSW1
> PSW2
> PSW17
> PSW3
> I need it to return like this:
> PSW1
> PSW2
> PSW3
> PSW17
> Is this possible with a certain type of index or collation setting?
Labels:
alpha-numeric,
alpha-numerically,
collation,
column,
database,
microsoft,
mysql,
oracle,
programming,
rules,
select,
server,
sorted,
sql,
statement
Alpha-Numeric Collation
I have a column of data that needs to be sorted alpha-numerically.
Rules: I can not do this in a SQL Select statement or programming on the
middle-tier. It must be set as an index or some sort of collation property
of the collumn.
Data Example: This is the order it is returning.
PSW1
PSW2
PSW17
PSW3
I need it to return like this:
PSW1
PSW2
PSW3
PSW17
Is this possible with a certain type of index or collation setting?Firstly this is not having a go at you personally but this question occurs
time and time again so I will explain my experiences and solution.
Secondly it does not provide you with a complete solution. I'm sorry. (but
you may be able to write a function that returns an integer of the first
numeric and then sort on the substrings)
ORDER BY SUBSTRING([Key], 1, [dbo].fn_FirstNumeric([Key]) -1),
CONVERT(INT,SUBSTRING([Key], [dbo].fn_FirstNumeric([Key]), 999))
WHERE the function looks like
CREATE FUNCTION fn_FirstNumeric ( @.Data NVARCHAR(255) ) RETURNS INT
AS
BEGIN
RETURN PATINDEX('%[0-9]%', @.Data)
END
It may be that my explanation of your situation is not correct but it seems
that you have a key PSW17 which should be further sub-divided into
constituent keys.
While working for a very large semi-conductor manufacturing company I was
asked to perform exactly the same sort of collation/sorting on part numbers
such as
SNJ74LS145J
SNC72LP245N
SNB74S174N
the first 3 characters meant something specific so did the next 2 numbers,
the middle letters also, then the next digits something else and finally the
last character.
If I remember correctly it was (in that order)
Specification type/burn type (components were subjected to high temperaturs
and re-tested, those that still worked were sold to military)
Can't remember the next one
Another spec type L = low power, LS = low power Schottkey
Parent bar type (all 174 bars became either military, standard, encapsulated
in plastic or ceramic).
Package (plastic, ceramic)
You can imagine trying to get at data when asked
"I want all low power schottkey with parent bar 174 for non-military"
So we decided that at the point of data entry the part number would be split
up into into constituent parts and for display puproses the parts were
concatenated to provide the complete part number. We could then process the
data as requested as each part was in a seperate column.
So what's is the point of explaining this?
Well, SQL manages "Databases" the first part of this word is Data and if
this is not correct then you do not have a database but a base of data which
your will struggle with. You must correctly normalize and identify all
correct data parts, keys and sub-key for your system to work correctly.
Nik Marshall-Blank MCSD/MCDBA
"Eric Laechelin" <EricLaechelin@.discussions.microsoft.com> wrote in message
news:36414A3C-54F4-43FD-9633-F95918E47A84@.microsoft.com...
>I have a column of data that needs to be sorted alpha-numerically.
> Rules: I can not do this in a SQL Select statement or programming on the
> middle-tier. It must be set as an index or some sort of collation
> property
> of the collumn.
> Data Example: This is the order it is returning.
> PSW1
> PSW2
> PSW17
> PSW3
> I need it to return like this:
> PSW1
> PSW2
> PSW3
> PSW17
> Is this possible with a certain type of index or collation setting?
Rules: I can not do this in a SQL Select statement or programming on the
middle-tier. It must be set as an index or some sort of collation property
of the collumn.
Data Example: This is the order it is returning.
PSW1
PSW2
PSW17
PSW3
I need it to return like this:
PSW1
PSW2
PSW3
PSW17
Is this possible with a certain type of index or collation setting?Firstly this is not having a go at you personally but this question occurs
time and time again so I will explain my experiences and solution.
Secondly it does not provide you with a complete solution. I'm sorry. (but
you may be able to write a function that returns an integer of the first
numeric and then sort on the substrings)
ORDER BY SUBSTRING([Key], 1, [dbo].fn_FirstNumeric([Key]) -1),
CONVERT(INT,SUBSTRING([Key], [dbo].fn_FirstNumeric([Key]), 999))
WHERE the function looks like
CREATE FUNCTION fn_FirstNumeric ( @.Data NVARCHAR(255) ) RETURNS INT
AS
BEGIN
RETURN PATINDEX('%[0-9]%', @.Data)
END
It may be that my explanation of your situation is not correct but it seems
that you have a key PSW17 which should be further sub-divided into
constituent keys.
While working for a very large semi-conductor manufacturing company I was
asked to perform exactly the same sort of collation/sorting on part numbers
such as
SNJ74LS145J
SNC72LP245N
SNB74S174N
the first 3 characters meant something specific so did the next 2 numbers,
the middle letters also, then the next digits something else and finally the
last character.
If I remember correctly it was (in that order)
Specification type/burn type (components were subjected to high temperaturs
and re-tested, those that still worked were sold to military)
Can't remember the next one
Another spec type L = low power, LS = low power Schottkey
Parent bar type (all 174 bars became either military, standard, encapsulated
in plastic or ceramic).
Package (plastic, ceramic)
You can imagine trying to get at data when asked
"I want all low power schottkey with parent bar 174 for non-military"
So we decided that at the point of data entry the part number would be split
up into into constituent parts and for display puproses the parts were
concatenated to provide the complete part number. We could then process the
data as requested as each part was in a seperate column.
So what's is the point of explaining this?
Well, SQL manages "Databases" the first part of this word is Data and if
this is not correct then you do not have a database but a base of data which
your will struggle with. You must correctly normalize and identify all
correct data parts, keys and sub-key for your system to work correctly.
Nik Marshall-Blank MCSD/MCDBA
"Eric Laechelin" <EricLaechelin@.discussions.microsoft.com> wrote in message
news:36414A3C-54F4-43FD-9633-F95918E47A84@.microsoft.com...
>I have a column of data that needs to be sorted alpha-numerically.
> Rules: I can not do this in a SQL Select statement or programming on the
> middle-tier. It must be set as an index or some sort of collation
> property
> of the collumn.
> Data Example: This is the order it is returning.
> PSW1
> PSW2
> PSW17
> PSW3
> I need it to return like this:
> PSW1
> PSW2
> PSW3
> PSW17
> Is this possible with a certain type of index or collation setting?
Labels:
alpha-numeric,
alpha-numerically,
collation,
column,
database,
microsoft,
mysql,
oracle,
programming,
rules,
select,
server,
sorted,
sql,
statement
Alpha-Numeric Collation
I have a column of data that needs to be sorted alpha-numerically.
Rules: I can not do this in a SQL Select statement or programming on the
middle-tier. It must be set as an index or some sort of collation property
of the collumn.
Data Example: This is the order it is returning.
PSW1
PSW2
PSW17
PSW3
I need it to return like this:
PSW1
PSW2
PSW3
PSW17
Is this possible with a certain type of index or collation setting?Firstly this is not having a go at you personally but this question occurs
time and time again so I will explain my experiences and solution.
Secondly it does not provide you with a complete solution. I'm sorry. (but
you may be able to write a function that returns an integer of the first
numeric and then sort on the substrings)
ORDER BY SUBSTRING([Key], 1, [dbo].fn_FirstNumeric([Key]) -1),
CONVERT(INT,SUBSTRING([Key], [dbo].fn_FirstNumeric([Key]), 999))
WHERE the function looks like
CREATE FUNCTION fn_FirstNumeric ( @.Data NVARCHAR(255) ) RETURNS INT
AS
BEGIN
RETURN PATINDEX('%[0-9]%', @.Data)
END
It may be that my explanation of your situation is not correct but it seems
that you have a key PSW17 which should be further sub-divided into
constituent keys.
While working for a very large semi-conductor manufacturing company I was
asked to perform exactly the same sort of collation/sorting on part numbers
such as
SNJ74LS145J
SNC72LP245N
SNB74S174N
the first 3 characters meant something specific so did the next 2 numbers,
the middle letters also, then the next digits something else and finally the
last character.
If I remember correctly it was (in that order)
Specification type/burn type (components were subjected to high temperaturs
and re-tested, those that still worked were sold to military)
Can't remember the next one
Another spec type L = low power, LS = low power Schottkey
Parent bar type (all 174 bars became either military, standard, encapsulated
in plastic or ceramic).
Package (plastic, ceramic)
You can imagine trying to get at data when asked
"I want all low power schottkey with parent bar 174 for non-military"
So we decided that at the point of data entry the part number would be split
up into into constituent parts and for display puproses the parts were
concatenated to provide the complete part number. We could then process the
data as requested as each part was in a seperate column.
So what's is the point of explaining this?
Well, SQL manages "Databases" the first part of this word is Data and if
this is not correct then you do not have a database but a base of data which
your will struggle with. You must correctly normalize and identify all
correct data parts, keys and sub-key for your system to work correctly.
--
Nik Marshall-Blank MCSD/MCDBA
"Eric Laechelin" <EricLaechelin@.discussions.microsoft.com> wrote in message
news:36414A3C-54F4-43FD-9633-F95918E47A84@.microsoft.com...
>I have a column of data that needs to be sorted alpha-numerically.
> Rules: I can not do this in a SQL Select statement or programming on the
> middle-tier. It must be set as an index or some sort of collation
> property
> of the collumn.
> Data Example: This is the order it is returning.
> PSW1
> PSW2
> PSW17
> PSW3
> I need it to return like this:
> PSW1
> PSW2
> PSW3
> PSW17
> Is this possible with a certain type of index or collation setting?
Rules: I can not do this in a SQL Select statement or programming on the
middle-tier. It must be set as an index or some sort of collation property
of the collumn.
Data Example: This is the order it is returning.
PSW1
PSW2
PSW17
PSW3
I need it to return like this:
PSW1
PSW2
PSW3
PSW17
Is this possible with a certain type of index or collation setting?Firstly this is not having a go at you personally but this question occurs
time and time again so I will explain my experiences and solution.
Secondly it does not provide you with a complete solution. I'm sorry. (but
you may be able to write a function that returns an integer of the first
numeric and then sort on the substrings)
ORDER BY SUBSTRING([Key], 1, [dbo].fn_FirstNumeric([Key]) -1),
CONVERT(INT,SUBSTRING([Key], [dbo].fn_FirstNumeric([Key]), 999))
WHERE the function looks like
CREATE FUNCTION fn_FirstNumeric ( @.Data NVARCHAR(255) ) RETURNS INT
AS
BEGIN
RETURN PATINDEX('%[0-9]%', @.Data)
END
It may be that my explanation of your situation is not correct but it seems
that you have a key PSW17 which should be further sub-divided into
constituent keys.
While working for a very large semi-conductor manufacturing company I was
asked to perform exactly the same sort of collation/sorting on part numbers
such as
SNJ74LS145J
SNC72LP245N
SNB74S174N
the first 3 characters meant something specific so did the next 2 numbers,
the middle letters also, then the next digits something else and finally the
last character.
If I remember correctly it was (in that order)
Specification type/burn type (components were subjected to high temperaturs
and re-tested, those that still worked were sold to military)
Can't remember the next one
Another spec type L = low power, LS = low power Schottkey
Parent bar type (all 174 bars became either military, standard, encapsulated
in plastic or ceramic).
Package (plastic, ceramic)
You can imagine trying to get at data when asked
"I want all low power schottkey with parent bar 174 for non-military"
So we decided that at the point of data entry the part number would be split
up into into constituent parts and for display puproses the parts were
concatenated to provide the complete part number. We could then process the
data as requested as each part was in a seperate column.
So what's is the point of explaining this?
Well, SQL manages "Databases" the first part of this word is Data and if
this is not correct then you do not have a database but a base of data which
your will struggle with. You must correctly normalize and identify all
correct data parts, keys and sub-key for your system to work correctly.
--
Nik Marshall-Blank MCSD/MCDBA
"Eric Laechelin" <EricLaechelin@.discussions.microsoft.com> wrote in message
news:36414A3C-54F4-43FD-9633-F95918E47A84@.microsoft.com...
>I have a column of data that needs to be sorted alpha-numerically.
> Rules: I can not do this in a SQL Select statement or programming on the
> middle-tier. It must be set as an index or some sort of collation
> property
> of the collumn.
> Data Example: This is the order it is returning.
> PSW1
> PSW2
> PSW17
> PSW3
> I need it to return like this:
> PSW1
> PSW2
> PSW3
> PSW17
> Is this possible with a certain type of index or collation setting?
Labels:
alpha-numeric,
alpha-numerically,
collation,
column,
database,
microsoft,
mysql,
oracle,
programming,
rules,
select,
server,
sorted,
sql,
statement
Subscribe to:
Posts (Atom)