Solved

script to modify collation for all columns varchar for all tables

Posted on 2010-11-17
4
508 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OSQL to execute sql command 26 24
LTrim & Double Space Correction 5 40
Stored Proc - Rewrite 42 56
Compare a numeric value to a varchar w/o getting an error 4 20
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

809 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