﻿<?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>Text Dosyasına Yazı Yazdırıp Kaydeten prosedür &#8211; SQL Server Eğitimleri</title>
	<atom:link href="https://sqlserveregitimleri.com/etiket/text-dosyasina-yazi-yazdirip-kaydeten-prosedur/feed" rel="self" type="application/rss+xml" />
	<link>https://sqlserveregitimleri.com</link>
	<description>SQL Server ile ilgili her şey</description>
	<lastBuildDate>Tue, 01 Feb 2022 18:23:26 +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’da Prosedür ile Text Dosyasına Yazı Yazdırıp Kaydetmek</title>
		<link>https://sqlserveregitimleri.com/sql-serverda-prosedur-ile-text-dosyasina-yazi-yazdirip-kaydetmek</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Thu, 31 Oct 2019 10:59:36 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server’da Prosedür ile Text Dosyasına Yazı Yazdırıp Kaydetmek]]></category>
		<category><![CDATA[Text Dosyasına Yazı Yazdırıp Kaydeten prosedür]]></category>
		<category><![CDATA[Text Dosyasına Yazı Yazdırıp Kaydetmek]]></category>
		<guid isPermaLink="false">http://sqlserveregitimleri.com/?p=7959</guid>

					<description><![CDATA[Herkese merhaba, Bu yazıda SQL Server’da prosedür ile text dosyasına yazı yazdırıp kaydetme hakkında bilgi vereceğim. SQL Server&#8217;da bazı durumlarda text dosyası oluşturup içine veri...]]></description>
										<content:encoded><![CDATA[<p>Herkese merhaba,</p>
<p>Bu yazıda SQL Server’da prosedür ile text dosyasına yazı yazdırıp kaydetme hakkında bilgi vereceğim.</p>
<p>SQL Server&#8217;da bazı durumlarda text dosyası oluşturup içine veri eklemek isteyebiliriz.</p>
<p>İşlemi yapmak için ilk olarak test için bir veritabanı oluşturmanız gerekmekte sonrasında aşağıdaki ayarları SQL Server komut ekranında çalıştırmalısınız.</p>
<pre class="line-numbers"><code class="language-sql">EXEC sp_configure 'show advanced options', 1;

EXEC sp_configure 'Ole Automation Procedures', 1;

RECONFIGURE;</code></pre>
<p>Sonrasında aşağıdaki prosedürü çalıştıralım.</p>
<pre class="line-numbers"><code class="language-sql">CREATE PROCEDURE TextDosyasinaYaziKaydetme
(
    @Yazi AS NVARCHAR(MAX),
    @DosyaAdi VARCHAR(200)
)
AS
BEGIN
    DECLARE @Object INT,
            @Deger INT,
            @DosyaID INT;
    EXEC @Deger = sp_OACreate 'Scripting.FileSystemObject', @Object OUT;
    EXEC @Deger = sp_OAMethod @Object,
                              'OpenTextFile',
                              @DosyaID OUT,
                              @DosyaAdi,
                              2,
                              1;
    SET @Yazi = REPLACE(REPLACE(REPLACE(@Yazi, '&amp;', '&amp;'), '&lt;', '&lt;'), '&gt;', '&gt;');
    EXEC @Deger = sp_OAMethod @DosyaID, 'WriteLine', NULL, @Yazi;
    EXEC @Deger = master.dbo.sp_OADestroy @DosyaID;
    DECLARE @Ekleme BIT;
    SELECT @Ekleme = 0;
    IF @Deger &lt;&gt; 0
    BEGIN
        EXEC @Deger = master.dbo.sp_OAMethod @Object,
                                             'SaveFile',
                                             NULL,
                                             @Yazi,
                                             @DosyaAdi,
                                             @Ekleme;
    END;
    EXEC @Deger = master.dbo.sp_OADestroy @Object;
END;


--Prosedürün kullanımı 

EXEC dbo.TextDosyasinaYaziKaydetme @Yazi = N'Yavuz Selim Kart', -- nvarchar(max) 
                                   @DosyaAdi = 'D:\MSSQL.txt';  -- varchar(200)</code></pre>
<p><span style="color: #ff0000;"><strong>Not :</strong></span> <strong>Windows’un yüklü olduğu sürücüde bu işlemi yaptığınız zaman hata alabilirsiniz.</strong></p>
<p>Ben sürücü olarak D sürücüsünü seçtim siz istediğinizi seçebilirsiniz. Dosya adını da <strong>MSSQL</strong> olarak belirledim. Burada <strong>dosya adı</strong> ve <strong>dosya uzantısını</strong> yazmanız önemli.</p>
<p>Prosedürü oluşturup sonrasında çalıştırdığımız zaman aşağıdaki sonucu alacaksınız.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-7961 size-full" src="https://sqlserveregitimleri.com/wp-content/uploads/2019/10/sql-serverda-prosedur-ile-text-dosyasina-yazi-yazdirip-kaydetmek-1.jpg" alt="SQL Server’da Prosedür ile Text Dosyasına Yazı Yazdırıp Kaydetmek" width="700" height="461" srcset="https://sqlserveregitimleri.com/wp-content/uploads/2019/10/sql-serverda-prosedur-ile-text-dosyasina-yazi-yazdirip-kaydetmek-1.jpg 700w, https://sqlserveregitimleri.com/wp-content/uploads/2019/10/sql-serverda-prosedur-ile-text-dosyasina-yazi-yazdirip-kaydetmek-1-315x207.jpg 315w, https://sqlserveregitimleri.com/wp-content/uploads/2019/10/sql-serverda-prosedur-ile-text-dosyasina-yazi-yazdirip-kaydetmek-1-456x300.jpg 456w, https://sqlserveregitimleri.com/wp-content/uploads/2019/10/sql-serverda-prosedur-ile-text-dosyasina-yazi-yazdirip-kaydetmek-1-205x135.jpg 205w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>Dosyanın içinde Yavuz Selim Kart yazıyor.</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"> 704</span><span class='epvc-label'> Kez Okundu</span></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
