﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sql Collation &#8211; SQL Server Eğitimleri</title>
	<atom:link href="https://sqlserveregitimleri.com/etiket/sql-collation/feed" rel="self" type="application/rss+xml" />
	<link>https://sqlserveregitimleri.com</link>
	<description>SQL Server ile ilgili her şey</description>
	<lastBuildDate>Mon, 15 May 2023 18:29:52 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>
	<item>
		<title>SQL Server&#8217;da Tüm Kolonların Collation&#8217;ını Değiştirme</title>
		<link>https://sqlserveregitimleri.com/sql-serverda-tum-kolonlarin-collationini-degistirme</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Mon, 15 May 2023 17:22:28 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sql Collation]]></category>
		<category><![CDATA[sql server Collation]]></category>
		<category><![CDATA[tslq Collation değiştirme]]></category>
		<guid isPermaLink="false">https://sqlserveregitimleri.com/?p=16280</guid>

					<description><![CDATA[Herkese merhaba. Bu yazıda SQL Server&#8217;da tüm kolonların collation&#8217;ını değiştirme ile ilgili bilgi vermeye çalışacağım. SQL Server&#8217;da bazı durumlarda veritabanının Collation’ını değiştirdiğiniz zaman Collation kolonlarda...]]></description>
										<content:encoded><![CDATA[<p>Herkese merhaba. Bu yazıda SQL Server&#8217;da tüm kolonların collation&#8217;ını değiştirme ile ilgili bilgi vermeye çalışacağım.</p>
<p>SQL Server&#8217;da bazı durumlarda veritabanının Collation’ını değiştirdiğiniz zaman Collation kolonlarda değişmeyebilir ve tüm kolonların Collation&#8217;ını değiştirmek isteyebilirsiniz.</p>
<p>Aşağıdaki sorguyu kullanarak sizler de bu işlemi rahatlıkla yapabilirsiniz.</p>
<pre class="line-numbers"><code class="language-sql">DECLARE @collate NVARCHAR(100);
DECLARE @table NVARCHAR(255);
DECLARE @column_name NVARCHAR(255);
DECLARE @column_id INT;
DECLARE @data_type NVARCHAR(255);
DECLARE @max_length INT;
DECLARE @row_id INT;
DECLARE @sql NVARCHAR(MAX);
DECLARE @sql_column NVARCHAR(MAX);

SET @collate = N'Turkish_CI_AI';

DECLARE local_table_cursor CURSOR FOR
SELECT [name]
FROM sysobjects
WHERE OBJECTPROPERTY(id, N'IsUserTable') = 1;

OPEN local_table_cursor;
FETCH NEXT FROM local_table_cursor
INTO @table;

WHILE @@FETCH_STATUS = 0
BEGIN

    DECLARE local_change_cursor CURSOR FOR
    SELECT ROW_NUMBER() OVER (ORDER BY c.column_id) AS row_id,
           c.name column_name,
           t.Name data_type,
           c.max_length,
           c.column_id
    FROM sys.columns c
        JOIN sys.types t
            ON c.system_type_id = t.system_type_id
        LEFT OUTER JOIN sys.index_columns ic
            ON ic.object_id = c.object_id
               AND ic.column_id = c.column_id
        LEFT OUTER JOIN sys.indexes i
            ON ic.object_id = i.object_id
               AND ic.index_id = i.index_id
    WHERE c.object_id = OBJECT_ID(@table)
    ORDER BY c.column_id;

    OPEN local_change_cursor;
    FETCH NEXT FROM local_change_cursor
    INTO @row_id,
         @column_name,
         @data_type,
         @max_length,
         @column_id;

    WHILE @@FETCH_STATUS = 0
    BEGIN

        IF (@max_length = -1)
            SET @max_length = 4000;

        IF (@data_type LIKE '%char%')
        BEGIN TRY
            SET @sql
                = N'ALTER TABLE ' + @table + N' ALTER COLUMN ' + @column_name + N' ' + @data_type + N'('
                  + CAST(@max_length AS NVARCHAR(100)) + N') COLLATE ' + @collate;
            PRINT @sql;
            EXEC sp_executesql @sql;
        END TRY
        BEGIN CATCH
            PRINT 'ERROR: Some index or contraint rely on the column' + @column_name + '. No conversion possible.';
            PRINT @sql;
        END CATCH;

        FETCH NEXT FROM local_change_cursor
        INTO @row_id,
             @column_name,
             @data_type,
             @max_length,
             @column_id;

    END;

    CLOSE local_change_cursor;
    DEALLOCATE local_change_cursor;

    FETCH NEXT FROM local_table_cursor
    INTO @table;

END;

CLOSE local_table_cursor;
DEALLOCATE local_table_cursor;

GO</code></pre>
<p>Herkese çalışma hayatında ve yaşamında başarılar kolaylıklar.</p>
<div class='epvc-post-count'><span class='epvc-eye'></span>  <span class="epvc-count"> 215</span><span class='epvc-label'> Kez Okundu</span></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
