Wednesday, March 2, 2016

Read collation information about a column in SQL Server


If collation of two columns is different then SQL server throws and exception when migrating data between the columns like so


Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation. 
 Thus we need to know about collation of the columns if we want to migrate information from one column to the other. I tried to open sys.sp_help stored procedure and figured out that its possible to read collation information of a column with following statements

declare @objid int
declare @sysobj_type char(2)
select @objid = object_id, @sysobj_type = type from sys.all_objects where object_id = object_id('<Table Name>')
select collation_name from sys.all_columns where object_id = @objid and name = '<Column Name>'



No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...