<?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>data file - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/data-file/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Fri, 23 Jul 2021 12:29:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>data file - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Add Data File to Availability Database?</title>
		<link>https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/</link>
					<comments>https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 11 Jul 2018 03:49:25 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[availability group]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[HowTO]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2418</guid>

					<description><![CDATA[<p>Sometimes, we need to add data file to availability database in Always on Availability Group. Adding database file is a straight forward method but if your databases participate in Always on Availability group then you need to take extra care&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/">How to Add Data File to Availability Database?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes, we need to add data file to availability database in Always on Availability Group. Adding database file is a straight forward method but if your databases participate in Always on Availability group then you need to take extra care while planning or performing such activity. If you add data file to availability database on primary replica without planning then your secondary databases in availability group might get into “<em>Not Synchronizing</em>” state  irrespective of having identical drives and folder structure on all your replica servers.</p>
<p>If your drive letters or folder structures are identical on all replica servers then most of the time you will not face any issue while adding the database files but sometimes if you mount additional drive on all replicas to make it identical and then add data file in this new drive then you might face the issue. If all replica servers don’t have identical path then adding database file operation on primary replica will not successfully replicate to other replica servers because of different drive and folder structure. This, in turn, causes the secondary replica to enter the NOT SYNCHRONIZING state.</p>
<p><strong>Note:</strong> <em>Always try to keep drive and folder structure identical on all secondary replica servers to the corresponding primary replica.</em></p>
<p>If you have added a data file on primary database of Always on Availability group then you will see multiple errors logged in SQL Server error log on your secondary replica where secondary database is suspended from always on availability group and showing in “Not Synchronizing” state. You might see one of the below error codes in your log file.</p>
<p><span style="color: #ff0000;"><em>Error:5123, Severity:16, State:1.</em></span><br />
<span style="color: #ff0000;"><em>CREATE FILE encountered operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file ‘E:\MSSQL\Data\Techyaz_Data2.ndf’.</em></span></p>
<p>Or</p>
<p><span style="color: #ff0000;"><em>Error:5183, Severity:16, State:1.</em></span><br />
<span style="color: #ff0000;"><em>Cannot create the file “Techyaz_Data2”. Use WITH MOVE to specify a usable physical file name. Use WITH REPLACE to overwrite an existing file.</em></span></p>
<p>Or</p>
<p><em><span style="color: #ff0000;">Error: 3313, Severity: 21, State: 2.</span></em><br />
<em><span style="color: #ff0000;">During redoing of a logged operation in database ‘Techyaz’, an error occurred at log record ID (76:659:1).</span></em></p>
<p>Now i will describe how to fix such issues or how to plan and add a database file to always on availability databases.</p>
<h3><span style="color: #333399;">Add Data file to Availability Database</span></h3>
<p>If you have already added data file on primary database and your secondary databases are suspended from availability group then we need to fix it to reestablish always on availability group. If you have not added the data file and want to add it then you can keep reading this article as i have described it later in this article. I have described how to plan database file addition to avoid any future synchronization issue.</p>
<p>Let’s go ahead with the first option where you have already added the data file to primary availability database and secondary database status is showing as not synchronizing due to this change. Now we need to fix this issue to reestablish the synchronization between replicas of availability group. To resolve this problem the DBAs  must complete the following steps:</p>
<ol>
<li>Remove the secondary database from the availability group that is showing as &#8220;<em>Not Synchronizing&#8221;</em>. To do this, either you can use GUI method in SSMS or run below T-SQL statement. You can connect to secondary replica then you can expand <strong>Always On High Availability </strong>node followed by <strong>Availability Groups</strong> Now, select the availability group and then expand the <strong>Availability Databases</strong> node. To remove a single database, select it in either the <strong>Object Explorer</strong> pane or the <strong>Object Explorer Details</strong> pane. Right-click the selected database or databases, and select <strong>Remove Secondary Database</strong> in the command menu. If you want to do it using T-SQL statement then you must connect to secondary replica and execute below Alter command.</li>
</ol>
<pre style="padding-left: 60px;"><span style="color: #0000ff;"><strong>ALTER DATABASE Techyaz SET HADR OFF;  </strong></span>
<strong><span style="color: #0000ff;">GO</span> </strong></pre>
<ol start="2">
<li>Once database will be removed from AOAG, restore a full backup of the filegroup that contains the added file to the secondary database, using WITH <em>NORECOVERY</em> and <em>WITH MOVE</em> option. This option is mandatory if you don’t have any log backups. Although sometimes you can do it by only running log backup on primary replica and restore it on secondary replica in norecovery mode as mentioned in next step.</li>
<li>Now, back up the transaction log that contains the add-file operation on the primary database, and manually restore the log backup on the secondary database using WITH <em>NORECOVERY</em> and <em>WITH MOVE</em>.</li>
<li>Prepare the secondary database for re-joining the availability group, by restoring, WITH NO RECOVERY, any other outstanding log backups from the primary database.</li>
<li>Rejoin the secondary database to the availability group. Read this article to get <a href="https://techyaz.com/sql-server/add-database-availability-group/" target="_blank" rel="noopener">step by step method to add a database to availability group</a>.</li>
</ol>
<p>If you havenot added the data file then you can plan it with following steps.</p>
<ol>
<li>Remove the database from secondary replica as described in above section. Now, secondary database will be showing in to restoring state.</li>
<li>Add the data file to your availability database on primary replica.</li>
<li>Take a log backup of this availability database on primary replica.</li>
<li>Copy this log backup to secondary replica and restore it on its corresponding secondary replica using NORECOVERY and WITH MOVE option.</li>
<li>Now add the database back to always on Availability Group.</li>
</ol>
<p>Here, I have shown you step by step process to add data file to availability database. I have also let you know how to fix the issues that might arise due to adding the database files to availability database on primary replica. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/" target="_blank" rel="noopener">Upgrade or Patch SQL Server Failover Cluster Instance Running with Availability Group</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/" target="_blank" rel="noopener">Understanding Enhanced Database Failover in Always on Availability Group</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/change-failover-mode-of-availability-replica-in-always-on-availability-group/" target="_blank" rel="noopener">How to Change Failover Mode of Availability Replica in AOAG?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">Always ON Availability Group Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/">How to Add Data File to Availability Database?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/how-to-add-data-file-to-availability-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Error 5009: One or more files listed in the statement could not be found or could not be initialized</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 30 May 2018 14:47:37 +0000</pubDate>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[bulk import performance]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[log files]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2355</guid>

					<description><![CDATA[<p>I had to add a log file to a database and then extend the size of this log file to a specific value. I got SQL Server error 5009 while creating the log file and got same error code again&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/">SQL Server Error 5009: One or more files listed in the statement could not be found or could not be initialized</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I had to add a log file to a database and then extend the size of this log file to a specific value. I got SQL Server error 5009 while creating the log file and got same error code again while extending the size of this file. Here i will describe how to fix Microsoft SQL Server Error 5009 while adding a database file or removing a database file or extending the database file size. You can see the screenshot of this error in below image while adding the log file.</p>
<p><img fetchpriority="high" decoding="async" class="size-full wp-image-2356 aligncenter" src="https://techyaz.com/wp-content/uploads/2018/05/1-error-5009-min.jpg" alt="Microsoft SQL Server Error 5009" width="598" height="232" srcset="https://techyaz.com/wp-content/uploads/2018/05/1-error-5009-min.jpg 598w, https://techyaz.com/wp-content/uploads/2018/05/1-error-5009-min-300x116.jpg 300w" sizes="(max-width: 598px) 100vw, 598px" /></p>
<h3><span style="color: #333399;">Microsoft SQL Server Error 5009 While Adding Database File</span></h3>
<p>I was working on a migration project where we had to load huge data in a SQL Server database on the target server. To optimize data load performance, we had decided to create database with the final size on the destination server. The final size of database post data import was around 800 GB. We made some configurational changes to reduce data import time. Extending database files size was one of the step to reduce data load time. If you want to learn<strong> <a href="https://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">how to speed up data import</a></strong> then I would suggest reading attached article.</p>
<p>We decided to add one more log file on separate drive considering extensive log growth during data load. While adding the log file, we got error 5009. Full error details are given below.</p>
<p><em><span style="color: #ff0000;">One or more files listed in the statement could not be found or could not be initialized. CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file &#8216;T:\Techyaz_log3.ldf&#8217;.(Microsoft SQL Server, Error: 5009)</span></em></p>
<p>As error suggests, I don&#8217;t had enough permission to create this file on given location where i was trying to create the log file. There are two solutions to fix this issue. First solution is to set the Operating system permission on the mentioned .ldf file to full permission for your login account and SQL Server service account. While second solution is to change the location to the path where you have enough permission to create or add database files. Any of these two solutions will fix your problem. Let&#8217;s go to another version of Microsoft SQL Server Error 5009 while extending the log file.</p>
<h3><span style="color: #333399;">Microsoft SQL Server Error 5009 While Extending the Size of Log File</span></h3>
<p>When i changed the location to create this ldf file to a directory <em>T:\Data\Techyaz_log3.ldf </em>this time log file was created but we get same issue again while extending the size of this log file. Next, I was assigning bigger value to each data and log files. We had successfully increased data files size in few minutes because we had already <strong><a href="https://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">enabled Instant File Initialization to skip zeros process</a></strong> on storage but we faced Microsoft SQL Server error 5009 again while increasing the size of log files. i was extending  log file with bigger values. As we know Instant File Initialization does not work for transaction log files so extending the size of log files was taking lot of time. This time access denied issue was disappeared but error 5009 issue was there only. Error description for this error is given below.</p>
<p><em><span style="color: #ff0000;">Msg 5009, Level 16, State 9, Line 1</span></em><br />
<em><span style="color: #ff0000;">One or more files listed in the statement could not be found or could not be initialized.</span></em></p>
<p>To fix this error, we had passed small value to extend the file size. Earlier we were trying to increase the log file in a slot of 40 GB in single go. It was taking time to finish but most of time log file size got extended with 40GB but sometimes we had received above Microsoft SQL Server error 5009. When we got this error, we extend the size of log file to 10Gb in place of 40GB that we were doing previously. Reducing the value while extending the log file has fixed this issue and log files had been extended to its future size successfully.</p>
<h3><span style="color: #333399;">Microsoft SQL Server Error 5009 While Removing Database File</span></h3>
<p>Some of the blogs have suggested that they got SQL Server error 5009 while removing a logical file in SQL Server but surprisingly I got this error while creating or increasing the size of log file. So if you are getting this error while removing any database file then you can keep reading this article to solve this issue.</p>
<p>Whenever we add any database file then its entry got captured in system catalog files, if you are trying to delete any database file then there might be possibility that logical name of the file that you try to remove is not unique in the system catalog tables. For example, this issue occurs if the file existed in the database earlier, and then the file was removed. When you remove the file, it will try to drop earlier file that has been removed but its metadata is not cleaned and appear like ghost file.</p>
<p>You should follow below steps to fix this issue.</p>
<ul>
<li>Create a new logical file with different name and the same data type. For example, If your file;s logical name is Techyaz_Logical_Name then create this new file with “Techyaz_Logical_Name_New&#8221;. Run below command to create this file.</li>
</ul>
<pre style="padding-left: 60px;"><span style="color: #0000ff;"><strong>ALTER DATABASE [Techyaz] 
ADD FILE ( NAME = N'Techyaz_Logical_Name_New', FILENAME = N'T:\DATA\Techyaz_file4.ndf', SIZE = 10MB, MAXSIZE = 100MB)</strong></span></pre>
<ul>
<li>Now we will remove the logical file that we have created in step 1, as in the following example:</li>
</ul>
<pre style="padding-left: 60px;"><span style="color: #0000ff;"><strong>ALTER DATABASE [Techyaz] REMOVE FILE [Techyaz_Logical_Name_New]</strong></span></pre>
<ul>
<li>Run a transaction log backup of the database.</li>
<li>Now go ahead and remove the logical file that were trying to remove earlier and your received Microsoft SQL Server Error 5009.</li>
</ul>
<p>Here, I have described multiple possibilities and fixes for Microsoft SQL Server Error 5009. I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">Manage Transaction Log File during Data Load</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">How to get total no of virtual log files in a transaction log file</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-3023-error-3013-error-3041/" target="_blank" rel="noopener">Fix Error 3023: Shrink failed for Log file</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">Understanding SQL Server Transaction Log Architecture</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1105/" target="_blank" rel="noopener">Fix SQL Server Error 1105: Could Not Allocate Space for Object in Database because the Filegroup is Full</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/" target="_blank" rel="noopener">Fix SQl Server Error 5144 and 5145 for long and failed Autogrow of data and log file</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/">SQL Server Error 5009: One or more files listed in the statement could not be found or could not be initialized</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to Change Database Default Locations in SQL Server?</title>
		<link>https://techyaz.com/sql-server/change-database-default-locations-sql-server/</link>
					<comments>https://techyaz.com/sql-server/change-database-default-locations-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 03 May 2018 11:16:42 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[data_files]]></category>
		<category><![CDATA[database property]]></category>
		<category><![CDATA[log files]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2215</guid>

					<description><![CDATA[<p>Sometimes, we need to change default database File locations to some other path in SQL Server. If you have configured SQL Server default database file location as drive C then all SQL Server databases will be created in the path&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/change-database-default-locations-sql-server/">How to Change Database Default Locations in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes, we need to change default database File locations to some other path in SQL Server. If you have configured SQL Server default database file location as drive C then all SQL Server databases will be created in the path set as database default locations if you have not mentioned their specific drives during database creation. You might need to change this path as per your environment standard. Here, I am going to show you how to view or change database default location in SQL Server.</p>
<p>One thing we should always keep in mind that if we change database default path in SQL Server then it will not change or move the database file locations for your existing databases. If you want to move all existing databases or you want to change database files path to the new location then you need to manually do it for each database.</p>
<p>Once you will change default database file locations then all databases you will create on that SQL Server Instance will be created on new location. Suppose your existing SQL Server default database location is set in C drive and now you have decided to change it to D drive for data files and F drive for Log files then all databases you will create post this change will be created in these both drives. If you will mention any other specific drive during database creation then SQL Server uses that drive and not these database default locations. The SQL Server data file will be created in D drive and log file will be created in F drive but all the existing databases that were created earlier in C drive will not move to new SQL server database file location. If you want to move these databases or want to change database files location then you need to manually do it either by detach-attach method or by ALTER statement.</p>
<h3><span style="color: #333399;">Change Database Default Locations in SQL Server</span></h3>
<p>It&#8217;s very simple method to change default log file location or default data file location in SQL Server. Let’s start to change default database path in SQL Server.</p>
<ul>
<li>Launch SQL Server Management Studio and connect to your SQL Server Instance for which you must change default log file location or default data file location in SQL Server.</li>
<li>Now right click at SQL Server Instance node and choose Properties option.</li>
<li>You will get server properties window on your screen. Click at “Database Settings” from left side pane. You will get all server level details for SQL Server databases in right side pane. Look at the database default locations option given bottom of the right-side pane. Here you can see separate default location for data files, Log file and backup files.</li>
</ul>
<p><img decoding="async" class="size-full wp-image-2216 aligncenter" src="http://techyaz.com/wp-content/uploads/2018/05/default-db-path-min.png" alt="Change Default database file location in SQL Server" width="693" height="631" srcset="https://techyaz.com/wp-content/uploads/2018/05/default-db-path-min.png 693w, https://techyaz.com/wp-content/uploads/2018/05/default-db-path-min-300x273.png 300w" sizes="(max-width: 693px) 100vw, 693px" /></p>
<ul>
<li>You can see database default locations for each file are showing in C drive. It means every database that will be created without mentioning their data or log file location will go to above given SQL Server database default locations.</li>
<li>To change database default path, you need to browse current database default locations for each file to new the new location. Click at three dots showing next to data file or log file locations and then select the new path.</li>
<li>Repeat same exercise for each file. To change default data file location, click at three dots next to data path and select new path here. Similarly, click at three dots next to log file location to change default log file location. If you want to change default backup file location then do the same for backup location as well.</li>
<li>Click ak Ok button once you made changes for desired database file locations.</li>
<li>Last step is to restart SQL Server services to apply this change and bring it into effect.</li>
</ul>
<p>Once you will restart SQL Server services, your SQL Server default database location will be changed to the new path. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">Get Total Number of Virtual Log Files in SQL Server Transaction Log File</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-1105/" target="_blank" rel="noopener">SQL Server Error 1105: Could Not Allocate Space for Object in Database because the filegroup is full</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/change-sql-server-instance-name/" target="_blank" rel="noopener">How to Change SQL Server Instance Name?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why Should You Always Turn Off Database Auto Shrink Property?</a></strong></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://techyaz.com/sql-server/change-database-default-locations-sql-server/">How to Change Database Default Locations in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/change-database-default-locations-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Improve SQL Server Bulk Data Import Performance?</title>
		<link>https://techyaz.com/sql-server/performance-tuning/improve-sql-server-bulk-data-import-performance/</link>
					<comments>https://techyaz.com/sql-server/performance-tuning/improve-sql-server-bulk-data-import-performance/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 08 Nov 2017 07:24:07 +0000</pubDate>
				<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Auto shrink]]></category>
		<category><![CDATA[autogrow]]></category>
		<category><![CDATA[autogrowth setting]]></category>
		<category><![CDATA[Autoshrink]]></category>
		<category><![CDATA[batch size]]></category>
		<category><![CDATA[bulk data load]]></category>
		<category><![CDATA[bulk import]]></category>
		<category><![CDATA[bulk import performance]]></category>
		<category><![CDATA[bulk insert]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[data file autogrow]]></category>
		<category><![CDATA[data load]]></category>
		<category><![CDATA[database property]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[IFI]]></category>
		<category><![CDATA[Instant File Initialization]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[maxdop]]></category>
		<category><![CDATA[performance tuning]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1108</guid>

					<description><![CDATA[<p>I am working on a project where we are migrating Oracle databases to SQL Server for SAP applications. We are using SAP migration tools to migrate these databases and we are not using SSMA for Oracle in this migration. These&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/performance-tuning/improve-sql-server-bulk-data-import-performance/">How to Improve SQL Server Bulk Data Import Performance?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I am working on a project where we are migrating Oracle databases to SQL Server for SAP applications. We are using SAP migration tools to migrate these databases and we are not using SSMA for Oracle in this migration. These databases were very big in size so we faced some performance issues during data load. Here I will explain how to avoid such performance issues and speed up SQL Server Bulk Data Import Performance.</p>
<p>Let me first give you some background about SAP migration tool like how it works. SAP Migration tool first captures every related information along with data and creates an export file that needs to be copied to the target location or server and then we perform bulk data import with the help of SAP migration tool. Bulk data import or data load will be done locally and not over network.</p>
<p>When we ran SAP migration tools to capture all details, a dump file was created that we have copied to the SQL Server box. We had approx. 900GB of data that needs to be loaded into SQL Server database. When we performed SQL Server data load using SAP migration tools with standard settings, it took around 14 hrs. to complete the bulk data import.  As 14 hrs. was very long time so we decided to work on reducing the total time taken by import process.</p>
<p>We made some changes from both sides application as well as SQL Server database side. SQL Server data load time has reduced drastically to around little more than 6 hours post these change implementations. Here, I am explaining each parameter that we have configured from database side just for this bulk data import.</p>
<p><span style="color: #800000;"><strong>NOTE:</strong> </span>Make sure to revert these changes as per your application/vendor best practices post this bulk data import for OLTP/normal operations. We are changing value considering Data Load only.</p>
<p><img decoding="async" class="alignleft wp-image-1109 size-medium" src="http://techyaz.com/wp-content/uploads/2017/11/Speed-up-bulk-data-Import-300x169.jpg" alt="Speed up bulk data Import" width="300" height="169" srcset="https://techyaz.com/wp-content/uploads/2017/11/Speed-up-bulk-data-Import-300x169.jpg 300w, https://techyaz.com/wp-content/uploads/2017/11/Speed-up-bulk-data-Import-768x432.jpg 768w, https://techyaz.com/wp-content/uploads/2017/11/Speed-up-bulk-data-Import-1024x576.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/11/Speed-up-bulk-data-Import.jpg 1280w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>It is important to understand the factors that affect bulk data import performance. To speed up the data load, you need to look into below configuration options from DBA standpoint.</p>
<h5><span style="color: #000080;"><strong>Auto Grow</strong></span></h5>
<p><strong> </strong>Autogrow settings can be used to automate SQL Server database file growth. This is very useful property but this can degrade your bulk import performance or data load operations. Read attached article to<strong> <a href="https://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">understand SQL Server Autogrow setting</a> </strong>in detail.</p>
<p>Autogrow setting increment must be large enough to avoid the performance penalties.  If you set default or small value during bulk import or data load, database engine will have to perform data file autogrow operation every time the file will be filled with data till maximum size limit. More autogrow operation will take more resources like IO, CPU etc and time to complete the data load transaction.</p>
<p>The exact value for this setting should be based on data growth. You should not be left autogrow in percentage value rather you should use some value in MBs. A general rule of thumb is to set your autogrow setting to about one-eighth the size of the file. Please read attached article to understand <strong><a href="https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">how to manage transaction log files during huge data load</a>.</strong></p>
<p>I would suggest keeping database size as much as you are expecting your database will grow to avoid autogrow operation. If you are aware that your database size will be 900 GB post data load, you should set your database size to 900 GB before starting the data load. This will improve the bulk import performance. Make sure to enable IFI (Instant File Initialization) for your SQL Server instance to reduce total time SQL Server takes to set the database size.</p>
<h5><span style="color: #000080;"><strong>Instant File Initialization</strong></span></h5>
<p>As I suggested in above point, Turn IFI (Instant File Initialization) ON to speed up AutoGrow process. If you set a considerable large value to autogrow settings, it will take some time to increase the size by zeroing the disk address. IFI speeds up this process and allow us to create enormous size of data files in quick way. Read attached article to learn more about<strong> <a href="https://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">IFI (Instant File Initialization) and how it will speed up autogrow or data load operation</a></strong>. You will also learn how to enable IFI for your SQL Server instance in this attached article.</p>
<h5><span style="color: #000080;"><strong>Auto Shrink</strong></span></h5>
<p>AutoShrink is very costly operation that should be always OFF even during your daily and normal operations. Turn it OFF immediately. Make sure your disk has enough space to sustain during bulk operations or data load. Repeatedly shrinking and growing the data files will cause file-system level fragmentation, which can slow down performance. It also takes lot of CPU and IO. Read attached article to know<strong> <a href="https://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">why you should always keep Auto_Shrink off</a>.</strong></p>
<h5><span style="color: #000080;"><strong>Reduce Logging</strong></span></h5>
<p>Change <strong><a href="https://techyaz.com/sql-server/understanding-sql-server-recovery-model/" target="_blank" rel="noopener">recovery model</a></strong> to SIMPLE or BULK-LOGGED to reduce the logging operations. The simple recovery model minimally logs most bulk operations. For a database under the full recovery model, all row-insert operations that are performed during bulk import are fully logged in the transaction log.</p>
<p>For large data imports, this can cause the transaction log to fill rapidly. For bulk-import operations, minimal logging is more efficient than full logging and reduces the possibility that a bulk-import operation will fill the log space. To minimally log a bulk-import operation on a database that normally uses the full recovery model, you can first switch the database to the bulk-logged recovery model. After bulk importing the data, switch the recovery model back to the full recovery model.</p>
<h5><span style="color: #000080;"><strong>Auto_Update_Statistics</strong></span></h5>
<p>Auto_Update_Statistics is very useful property that should be set to ON during normal business operations but here I would suggest turning it off during huge data load or bulk import operations. Updating the statistics also takes resources from the system. This can lead to performance issues when you are doing bulk data. It’s important to keep up-to-date statistics for the optimizer to use, but here we will turn it off and once data load or bulk data inserts will be performed, we will again enable it.</p>
<h5><span style="color: #000080;"><strong>Auto_Create_Statistics</strong></span></h5>
<p>This should be OFF because creating statistics also takes resources from the system that can degrade the overall bulk import performance. Make sure to enable it post data load or bulk inserts operation.</p>
<h5><span style="color: #000080;"><strong>Parallelism – MAXDOP</strong></span></h5>
<p>SAP suggests setting MAXDOP value to 1 during normal business operation so we had this value during first data load that took around 14 hrs. We had assigned half of the CPU cores for the parallel processes during data load and bulk import operations. I believe MAXDOP has contributed significant role in reducing total data load time. Make sure to revert this change to its original value as per your application best practices.</p>
<p>You can change MAXDOP settings either using <strong>sp_configure</strong> command or using GUI in SSMS by launching SQL Server Instance property window.</p>
<h5><span style="color: #000080;"><strong>Using Batches</strong></span></h5>
<p>Make sure to use an optimum batch size that will increase the bulk data import performance. Importing a large set of data as a single batch can be problematic, so bcp and BULK INSERT let you import data in a series of batches, each of which is smaller than the data file. Each batch is imported and logged in a separate transaction, and after a given transaction is committed, the rows imported by that transaction are committed. If the operation fails, only rows imported from the current batch are rolled back, and you can resume importing data starting at the beginning of the failed batch rather than at the beginning of the data file.</p>
<p>I hope you like this article. Please follow us our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/performance-tuning/improve-sql-server-bulk-data-import-performance/">How to Improve SQL Server Bulk Data Import Performance?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/performance-tuning/improve-sql-server-bulk-data-import-performance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Instant File Initialization and How to enable it on SQL Server Instance?</title>
		<link>https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/</link>
					<comments>https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 07 Sep 2017 08:40:38 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Instant File Initialization]]></category>
		<category><![CDATA[SQL Server Configuration Manager]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=820</guid>

					<description><![CDATA[<p>Instant file initialization is very useful feature to speedup the process of increasing or allocating data file space of a SQL Server database. Have you ever thought how SQL Server initialized its database files during space allocation? General way to&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/">What is Instant File Initialization and How to enable it on SQL Server Instance?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>Instant file initialization</strong> is very useful feature to speedup the process of increasing or allocating data file space of a SQL Server database. Have you ever thought how SQL Server initialized its database files during space allocation? General way to initialize any data and log files is to filling the files with zeros to overwrite any existing data left on the disk from previously deleted files. Data and log file initialization happen during space allocation activities such as database creation, adding any database files, Autogrow operation or increasing the size of any database files and backup file creating.</p>
<p>Read more about auto growth and auto shrink operation in SQL Server. Both are very important activity you should review to improve your database performance.</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">Understanding Database Autogrowth in SQL Server</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why Should You Always Turn Off Database Auto Shrink Property?</a></strong></li>
</ul>
<h2>What is Instant File Initialization?</h2>
<p>Data and log file initialization takes lot of time if you have to create large database files. This can also increase total completion time of large database restore or large amount of data import to the SQL Server. Microsoft has given a feature called <strong>Instant file initialization</strong> that allows fast data file allocations for all data file operations. This feature reclaims used disk space without filling that space with zeros. Instead, disk content is overwritten as new data is written to the files. But unfortunately, this feature <strong>doesn&#8217;t work with log files</strong> so they cannot be initialized instantaneously. This is not enterprise feature any SQL Server edition can use it.</p>
<p>As we know <strong>DELETE operation</strong> deallocates the space and a new allocation can reuse that space which may still have data in it. When we do not zero out the existing space in case of instant file initialization there is a possibility that someone could read data that you thought had been deleted. This is a <strong>known security risk</strong> of this feature that must be considered while enabling it for your SQL Server Instance. Instant File Initialization is not enabled by default in SQL Server because of this security risk.</p>
<h3>Enable Instant File Initialization for SQL Server?</h3>
<p>Below are the steps you need to perform to enable Instant File Initialization.</p>
<p><strong>Step 1-</strong> Login to server where you want to enable Instant File Initialization. This might be your database server or backup server.<br /><strong>Step 2-</strong> Open the <strong>Local Security Policy</strong> application. You can go to <strong>Control Panel-&gt;Administrative Tools-&gt;Local Security Policy</strong>. You can also open it directly by putting <strong>secpol.msc</strong> into run command prompt.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-821" src="http://techyaz.com/wp-content/uploads/2017/09/1-run.jpg" alt="Open Local Security Policy by running secpol.msc" width="461" height="241" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-run.jpg 461w, https://techyaz.com/wp-content/uploads/2017/09/1-run-300x157.jpg 300w" sizes="auto, (max-width: 461px) 100vw, 461px" /></p>
<p><strong>Step 3-</strong> In the left pane, expand <strong>Local Policies</strong>, and then click <strong>User Rights Assignment</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-822" src="http://techyaz.com/wp-content/uploads/2017/09/2-local-policy.jpg" alt="local security policy " width="664" height="576" srcset="https://techyaz.com/wp-content/uploads/2017/09/2-local-policy.jpg 664w, https://techyaz.com/wp-content/uploads/2017/09/2-local-policy-300x260.jpg 300w" sizes="auto, (max-width: 664px) 100vw, 664px" /><br /><strong>Step 4-</strong> In the right pane, double-click <strong>Perform volume maintenance tasks</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-823" src="http://techyaz.com/wp-content/uploads/2017/09/3-local-policy.jpg" alt="Enable Instant file Initialization" width="558" height="542" srcset="https://techyaz.com/wp-content/uploads/2017/09/3-local-policy.jpg 558w, https://techyaz.com/wp-content/uploads/2017/09/3-local-policy-300x291.jpg 300w" sizes="auto, (max-width: 558px) 100vw, 558px" /><br /><strong>Step 5-</strong> Click <strong>Add User or Group</strong> and add any user accounts that are used to run SQL Server services. You can get SQL Server service account from SQL Server Configuration Manager or from services.msc console.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-824" src="http://techyaz.com/wp-content/uploads/2017/09/4-sql-services.jpg" alt="SQL Server Services" width="739" height="273" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-sql-services.jpg 739w, https://techyaz.com/wp-content/uploads/2017/09/4-sql-services-300x111.jpg 300w" sizes="auto, (max-width: 739px) 100vw, 739px" /></p>
<p>Now add account <strong>Domain\techyaz</strong> to above policy. It would be great if you create a group and add this account to that group and then add that group to given policy so that every time you don&#8217;t need to add user account here if SQL Server service account got changed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-825" src="http://techyaz.com/wp-content/uploads/2017/09/5-local-policy.jpg" alt="" width="495" height="525" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-local-policy.jpg 495w, https://techyaz.com/wp-content/uploads/2017/09/5-local-policy-283x300.jpg 283w" sizes="auto, (max-width: 495px) 100vw, 495px" /><br /><strong>Step 6-</strong> Once SQL Server service account will be added, it will look like below image. Click <strong>Apply</strong>, and then close all Local Security Policy dialog boxes.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-826" src="http://techyaz.com/wp-content/uploads/2017/09/6-local-policy.jpg" alt="" width="453" height="523" srcset="https://techyaz.com/wp-content/uploads/2017/09/6-local-policy.jpg 453w, https://techyaz.com/wp-content/uploads/2017/09/6-local-policy-260x300.jpg 260w" sizes="auto, (max-width: 453px) 100vw, 453px" /><br /><strong>Step 7-</strong> <strong>Restart</strong> SQL Server services to apply this change.</p>
<p>If you need to enable this feature on Cluster environment, make sure to perform this activity on all cluster nodes. If you are running with multiple SQL Server Instances, add all required security logins/group to this policy.</p>
<h3>How to Check If instant file initialization is Enabled Or Not?</h3>
<p>Now if you think <strong>how to know Instant File Initialization is enabled on your SQL Server</strong> Instance then here is the answer. You should check SQL Server logs to get the details about Instant File Initialization. When SQL Server service starts, database engine checks all details of SQL Server configurations and capture them into log file. You can see my error log file after restarting SQL Server service. Instant File Initialization is showing as enabled on this server.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span style="color: #0000ff;"><strong>2017-06-16 11:16:49.15 Server Database Instant File Initialization: enabled. </strong></span><span style="color: #0000ff;"><strong>For security and performance considerations see the topic ‘Database Instant File Initialization’ in SQL Server Books Online. This </strong></span><span style="color: #0000ff;"><strong>is an informational message only. No user action is required.
</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-827" src="http://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-1024x238.jpg" alt="instant file initialization in sql server log file" width="1024" height="238" srcset="https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-1024x238.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-300x70.jpg 300w, https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log-768x179.jpg 768w, https://techyaz.com/wp-content/uploads/2017/09/7-Instant-file-initilization-enabled-log.jpg 1091w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h3><span style="color: #000080;">Advantages</span></h3>
<p>Instant File Initialization improves performance of multiple database activities where large size of data file creation or Autogrow operation will perform. This can vastly speed up these operations as zero-initialization can take a long time for large files. Below are the operations that can take advantage from this feature.</p>
<ul>
<li>Data Load/Import</li>
<li>New Database Creation</li>
<li>Database Restore</li>
<li>Autogrow Operation</li>
<li>Data file size Increase</li>
<li>Backup file Creation</li>
</ul>
<h3><span style="color: #000080;">Limitations</span></h3>
<p>This feature will not work if:</p>
<ul>
<li>Your file is a log file.</li>
<li>The account has not the required privilege.</li>
<li>It is a sparse file &#8211; Database Snapshots.</li>
<li>Transparent Data Encryption (TDE) is enabled.</li>
<li>Trace flag 1806 is enabled to disable instant file initialization.</li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><em><strong>Read More: </strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-server-error-5009/" target="_blank" rel="noopener">SQL Server Error 5009: One or more files listed in the statement could not be found or could not be initialized</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/" target="_blank" rel="noopener">Fix SQL Server Msg 5144 and 5145 for long or failed autogrow of data and log files</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">Manage Transaction Log File during Data Load</a></strong></li>
</ul>


<p></p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/">What is Instant File Initialization and How to enable it on SQL Server Instance?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/sql-server-administration/instant-file-initialization-enable-on-sql-server-instance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
