Solved

script to modify collation for all columns varchar for all tables

Posted on 2010-11-17
4
507 Views
Last Modified: 2012-05-10
Hello,

I search a script for modify collation for all columns varchar for all tables.

Thanks

bibi
0
Comment
Question by:bibi92
4 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 34157682
Apologies ... above should not have been a admin comment

sorry not a great solution, but http://www.db-staff.com/index.php/microsoft-sql-server/69-change-collation is a good place to start

hope it helps - if not sorry
0
 
LVL 7

Accepted Solution

by:
Cboudroz earned 500 total points
ID: 34157702
check last column
SELECT 
	o.name as TableName
	, c.Name as ColumnName
	, t.name as Columntype
	, c.max_length as ColumnSize
	, c.collation_name as CurrentCollation -- if null = default collation of the database
	, 'ALTER TABLE ' + O.NAME + ' ALTER COLUMN ' + C.NAME + ' ' + T.NAME + '(' + CONVERT(VARCHAR(100), c.max_length) + ') COLLATE SQL_Latin1_General_CP1_CI_AI'
FROM 
	sys.objects o
	INNER JOIN sys.columns c
		on o.object_id = c.object_id
	INNER JOIN sys.types t
		on t.system_type_id = c.system_type_id 
WHERE 
	o.TYPE = 'U'
	and t.name like '%CHAR%'

Open in new window

0
 

Author Closing Comment

by:bibi92
ID: 34162635
Thanks a lot regards bibi
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question