﻿<?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 Base64 Fonksiyon &#8211; SQL Server Eğitimleri</title>
	<atom:link href="https://sqlserveregitimleri.com/etiket/sql-base64-fonksiyon/feed" rel="self" type="application/rss+xml" />
	<link>https://sqlserveregitimleri.com</link>
	<description>SQL Server ile ilgili her şey</description>
	<lastBuildDate>Fri, 10 Mar 2023 18:08:03 +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 Yazıyı Base64&#8217;e Encode Eden Fonksiyon</title>
		<link>https://sqlserveregitimleri.com/sql-serverda-yaziyi-base64e-encode-eden-fonksiyon</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Wed, 04 May 2022 21:54:18 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Base64 Fonksiyon]]></category>
		<category><![CDATA[SQL Server Base64]]></category>
		<category><![CDATA[TSQL Base64 Fonksiyon]]></category>
		<guid isPermaLink="false">https://sqlserveregitimleri.com/?p=13723</guid>

					<description><![CDATA[Herkese merhaba, Bu yazıda SQL Server’da yazıyı Base64&#8217;e encode eden fonksiyon ile ilgili bilgi vermeye çalışacağım. SQL Server’da bazı durumlarda yazıyı Base64&#8217;e encode etmek isteyebilirsiniz....]]></description>
										<content:encoded><![CDATA[<p>Herkese merhaba,</p>
<p>Bu yazıda SQL Server’da yazıyı Base64&#8217;e encode eden fonksiyon ile ilgili bilgi vermeye çalışacağım.</p>
<p>SQL Server’da bazı durumlarda yazıyı Base64&#8217;e encode etmek isteyebilirsiniz.</p>
<p>Aşağıdaki kodu kullanarak siz de bu işlemi rahatlıkla yapabilirsiniz.</p>
<pre class="line-numbers"><code class="language-sql">CREATE FUNCTION [dbo].[fnBase64Encode]
(
    @plain_text VARCHAR(6000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
    --local variables
    DECLARE @output VARCHAR(8000),
            @input_length INTEGER,
            @block_start INTEGER,
            @partial_block_start INTEGER, -- position of last 0, 1 or 2 characters
            @partial_block_length INTEGER,
            @block_val INTEGER,
            @map CHAR(64);
    SET @map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
    --initialise variables
    SET @output = '';
    --set length and count
    SET @input_length = LEN(@plain_text + '#') - 1;
    SET @partial_block_length = @input_length % 3;
    SET @partial_block_start = @input_length - @partial_block_length;
    SET @block_start = 1;
    --for each block
    WHILE @block_start &lt; @partial_block_start
    BEGIN
        SET @block_val = CAST(SUBSTRING(@plain_text, @block_start, 3) AS BINARY(3));
        --encode the 3 character block and add to the output
        SET @output
            = @output + SUBSTRING(@map, @block_val / 262144 + 1, 1) + SUBSTRING(@map, (@block_val / 4096 &amp; 63) + 1, 1)
              + SUBSTRING(@map, (@block_val / 64 &amp; 63) + 1, 1) + SUBSTRING(@map, (@block_val &amp; 63) + 1, 1);
        --increment the counter
        SET @block_start = @block_start + 3;
    END;
    IF @partial_block_length &gt; 0
    BEGIN
        SET @block_val
            = CAST(SUBSTRING(@plain_text, @block_start, @partial_block_length)
                   + REPLICATE(CHAR(0), 3 - @partial_block_length) AS BINARY(3));
        SET @output
            = @output + SUBSTRING(@map, @block_val / 262144 + 1, 1) + SUBSTRING(@map, (@block_val / 4096 &amp; 63) + 1, 1)
              + CASE
                    WHEN @partial_block_length &lt; 2 THEN
                        REPLACE(SUBSTRING(@map, (@block_val / 64 &amp; 63) + 1, 1), 'A', '=')
                    ELSE
                        SUBSTRING(@map, (@block_val / 64 &amp; 63) + 1, 1)
                END + CASE
                          WHEN @partial_block_length &lt; 3 THEN
                              REPLACE(SUBSTRING(@map, (@block_val &amp; 63) + 1, 1), 'A', '=')
                          ELSE
                              SUBSTRING(@map, (@block_val &amp; 63) + 1, 1)
                      END;
    END;
    --return the result
    RETURN @output;
END;


---Kullanımı
 
SELECT dbo.fnBase64Encode('Yavuz Selim Kart') AS Base64</code></pre>
<p>Yukarıdaki kodu çalıştırdığınızda aşağıdakine benzer bir sonuç göreceksiniz.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-13725 size-full" src="https://sqlserveregitimleri.com/wp-content/uploads/2022/05/sql-serverda-yaziyi-base64e-encode-eden-fonksiyon-1.jpg" alt="SQL Server'da Yazıyı Base64'e Encode Eden Fonksiyon" width="700" height="455" srcset="https://sqlserveregitimleri.com/wp-content/uploads/2022/05/sql-serverda-yaziyi-base64e-encode-eden-fonksiyon-1.jpg 700w, https://sqlserveregitimleri.com/wp-content/uploads/2022/05/sql-serverda-yaziyi-base64e-encode-eden-fonksiyon-1-315x205.jpg 315w, https://sqlserveregitimleri.com/wp-content/uploads/2022/05/sql-serverda-yaziyi-base64e-encode-eden-fonksiyon-1-462x300.jpg 462w, https://sqlserveregitimleri.com/wp-content/uploads/2022/05/sql-serverda-yaziyi-base64e-encode-eden-fonksiyon-1-208x135.jpg 208w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>Görüldüğü üzere yazıyı Base64&#8217;e encode etmiş olduk.</p>
<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"> 309</span><span class='epvc-label'> Kez Okundu</span></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
