Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i change collation of userdefined datatype

Status
Not open for further replies.

karbon

Programmer
Dec 4, 2003
29
TR

Hi everyone?

How can i change collation of userdefined datatype?
When i try to change it Management Studio Query


varcharUzun = varchar(100) --> userdefined data type....

Code:
ALTER TABLE tbxxxx ALTER COLUMN sDefinition varcharUzun COLLATE Turkish_CI_AS NOT NULL

when i run the query it says.
Code:
Msg 452, Level 16, State 1, Line 2
COLLATE clause cannot be used on user-defined data types.


i also cannot ALTER the userdefinedtypes collation itself. And i canyt chance the collation if the column is PrimaryKey [:(]
Is there any other to change the collation without dropping and re-creating the objects.

Thanks.
 
Karbon,
You should be able to change the collation when you select the data.

SELECT sDefinition collate Latin1_General_CS_AS
FROM tbxxxx

You may need to convert it to varchar.

- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 
thanks ptheriault i know

but
in your example you just change the collation of the result.

Table's Column COLLATION dont change.
i want to change the TABLE STRUCTURE

Code:
ALTER TABLE tbxxxx ALTER COLUMN sDefinition varchar(100) COLLATE Turkish_CI_AS NOT NULL

no problem.

Code:
ALTER TABLE tbxxxx ALTER COLUMN sDefinition xxxuserdatatype COLLATE Turkish_CI_AS NOT NULL

problem
 
Karbon,
As far as I know you can not drop or alter a user defined data type thet is in use.

- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 
As a work around you could alter your table like this.

SELECT * INTO NEW_TABLE FROM OLD_TABLE
WHERE 1=2

Drop the User defined column in NEW_TABLE and re-add with your collation.

Insert all data from OLD_TABLE

Rename OLD_TABLE to something OLD_TABLE_OLD

Rename NEW_TABLE to OLD_TABLE

- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 
I forgot to add, the select * into syntax will only create your table. You will need to re-add any indexes, triggers, or contraints that you had on the old table.

- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 

i understand, and know the method.
BSA(BacktoStoneAge) method. :)))

Thanks a lot but this database is live.
and it has millions of records and PrimaryKey tables and keys and indexes triggers. So i cant stop the engine.

I can easily change the COLLATION with normal datatypes, i only have problem with UDDTypes and also
YOU cannot change the COLLATION of PrimaryKey Columns.

Anyway thank you very much for your replies. ;)

 
No problem. Sorry it wasn't of any use.


- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top