<?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 Server - Techyaz.com</title>
	<atom:link href="https://techyaz.com/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Sun, 09 Apr 2023 08:20:07 +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>SQL Server - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Fix SQL Server Error 18456: A Comprehensive Guide</title>
		<link>https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/</link>
					<comments>https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sat, 08 Apr 2023 13:27:20 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2773</guid>

					<description><![CDATA[<p>SQL Server, developed by Microsoft, is a popular relational database management system (RDBMS) used by millions of businesses worldwide. However, like any software, SQL Server may encounter errors, and one common error that users often encounter is SQL Server Error&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/">How to Fix SQL Server Error 18456: A Comprehensive Guide</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>SQL Server, developed by Microsoft, is a popular relational database management system (RDBMS) used by millions of businesses worldwide. However, like any software, SQL Server may encounter errors, and one common error that users often encounter is SQL Server Error 18456. This error occurs when users are unable to log in to their SQL Server instance due to authentication failure. In this article, we will delve into the details of SQL Server Error 18456 and provide a comprehensive guide on how to fix it.</p>



<p>SQL Server Error 18456, also known as the &#8220;Login failed for user&#8221; error, is a common authentication error that occurs when a user fails to log in to SQL Server. The error message associated with Error 18456 usually reads:</p>



<p><em>&#8220;Login failed for user &#8216;&lt;username>&#8217;. (Microsoft SQL Server, Error: 18456)&#8221;</em></p>



<p>The error occurs when SQL Server is unable to authenticate the user trying to connect to the SQL Server instance. There are several reasons why this error may occur, including incorrect login credentials, disabled user accounts, expired passwords, or issues with SQL Server authentication settings.</p>


<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img fetchpriority="high" decoding="async" src="https://techyaz.com/wp-content/uploads/2023/04/SQL-Server-error-18456.png" alt="Fix SQL Server error 18456" class="wp-image-2774" width="342" height="212" srcset="https://techyaz.com/wp-content/uploads/2023/04/SQL-Server-error-18456.png 851w, https://techyaz.com/wp-content/uploads/2023/04/SQL-Server-error-18456-300x186.png 300w, https://techyaz.com/wp-content/uploads/2023/04/SQL-Server-error-18456-768x476.png 768w" sizes="(max-width: 342px) 100vw, 342px" /></figure></div>


<h2 class="wp-block-heading">How to Fix SQL Server Error 18456?</h2>



<p>Fixing SQL Error 18456 requires identifying the root cause of the error and applying the appropriate solution. Here are some common solutions to fix SQL Error 18456:</p>



<ol class="wp-block-list" type="1">
<li><strong>Verify Login Credentials: </strong>The most basic step in fixing SQL Server Error 18456 is to verify that the login credentials, including the username and password, are correct. Make sure you are entering the correct login credentials for the SQL Server instance you are trying to connect to.</li>



<li><strong>Enable Mixed Mode Authentication: </strong>SQL Server supports two types of authentication modes &#8211; Windows Authentication mode and Mixed Mode (Windows Authentication and SQL Server Authentication) mode. If you are using SQL Server Authentication, make sure that Mixed Mode Authentication is enabled in SQL Server. You can do this through SQL Server Management Studio (SSMS) by right-clicking on the SQL Server instance, selecting Properties, and then navigating to the Security tab.</li>



<li><strong>Check User Account Status: </strong>Ensure that the user account you are trying to log in with is not disabled or locked out. If the user account is disabled or locked out, unlock or enable the account using SQL Server Management Studio or SQL Server command-line tools.</li>



<li><strong>Reset Password: </strong>If you suspect that the password for the SQL Server login is incorrect or has expired, reset the password. You can do this through SQL Server Management Studio or by using the ALTER LOGIN statement in SQL Server.</li>



<li><strong>Check SQL Server Error Logs:</strong> SQL Server logs detailed information about authentication failures in its error logs. Review the SQL Server error logs to identify any specific error messages related to Error 18456. The error logs may provide additional insights into the root cause of the issue.</li>



<li><strong>Verify SQL Server Permissions: </strong>Ensure that the user account has the necessary permissions to log in to the SQL Server instance. Check the server-level and database-level permissions for the user account and grant the appropriate permissions if necessary.</li>



<li><strong>Check Firewall Settings:</strong> If you are connecting to a remote SQL Server instance, verify that the appropriate ports are open in the firewall to allow communication between the client and the server. Check the firewall settings on both the client and server machines to ensure that they are not blocking the required ports.</li>



<li><strong>Check SQL Server Version:</strong> Error 18456 can also occur if there is a version mismatch between the SQL Server client and server components. Ensure that the SQL Server client version matches the server version to avoid compatibility issues.</li>



<li><strong>Apply SQL Server Service Packs and Cumulative Updates: </strong>Microsoft regularly releases service packs and cumulative updates for SQL Server that address known issues and provide bug fixes.</li>
</ol>



<p>You can also read the below articles to fix SQL error 18456:</p>



<ul class="wp-block-list">
<li><a href="https://techyaz.com/sql-server/failed-to-open-the-explicitly-specified-database/" target="_blank" rel="noreferrer noopener">Fix SQL Error 18456: failed to open the explicitly specified database</a></li>



<li><a href="https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/" target="_blank" rel="noreferrer noopener">Fix SQL Server Error 18456: Login failed for user ‘User_Name’.</a></li>



<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/" target="_blank" rel="noreferrer noopener">Fix Error 18452: Login failed. The login is from an untrusted domain</a></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/">How to Fix SQL Server Error 18456: A Comprehensive Guide</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Error 18456: failed to open the explicitly specified database</title>
		<link>https://techyaz.com/sql-server/failed-to-open-the-explicitly-specified-database/</link>
					<comments>https://techyaz.com/sql-server/failed-to-open-the-explicitly-specified-database/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sat, 18 Sep 2021 10:16:39 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2747</guid>

					<description><![CDATA[<p>This article will help you fixing SQL Server Error: 18456, Severity: 14, State: 38, Reason: Failed to Open the Explicitly Specified Database. We were getting below error in our SQL Server error log for one of our login. Login Failed&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/failed-to-open-the-explicitly-specified-database/">Fix SQL Error 18456: failed to open the explicitly specified database</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This article will help you fixing SQL Server  Error: 18456, Severity: 14, State: 38, Reason: Failed to Open the Explicitly Specified Database. We were getting below error in our SQL Server error log for one of our login.</p>



<p><strong>Login Failed – Error: 18456, Severity: 14, State: 38</strong></p>



<p><strong>Reason: Failed to Open the Explicitly Specified Database</strong></p>



<h2 class="wp-block-heading">Fix Error &#8220;Failed to Open the Explicitly Specified Database&#8221;</h2>



<p>The error log is saying &#8220;<em>Failed to Open the Explicitly Specified Database</em>&#8220;, it means either your have specified wrong database in your connection string or your login does not have access to the specified database. You can validate below options to isolate this issue.</p>



<ul class="wp-block-list">
<li>Check whether you have specified correct database in your connection string or not</li>



<li>If you are using correct database then whether the login you are using to establish database connection has access to this specified database or not.</li>



<li>Correct if you find something in any of the above two options.</li>



<li>Check login properties whether it is using correct database as default database configuration or not. If correct database is defined then login has access to that database or not. I will explain about this step in below section as well.</li>



<li>You should also check whether number of connections to the database is exhausted or not. Review your maximum number of connections setting.</li>



<li>Ensure your database is not set to AUTO CLOSE setting or not inaccessible. Database should be online and healthy state to accept connections.</li>



<li>Make sure you have a trust between both machines, database server and the machine from where you are trying to connect. I would suggest you to read below article as well where i have explained various steps to troubleshoot SQL Server connection issues.</li>
</ul>



<p><strong><em>Read more articles on SQL error 18456 and connection issues:</em></strong></p>



<ul class="wp-block-list">
<li><a href="https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/" target="_blank" rel="noreferrer noopener"><strong>How to Fix SQL Server Error 18456: A Comprehensive Guide</strong></a></li>



<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-53-not-open-connection-sql-server/" target="_blank" rel="noreferrer noopener">How to fix SQL Server error 53 &#8211; Not able to open database connection</a></strong></li>



<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/" target="_blank" rel="noreferrer noopener">Fix SQL Server error 18456 &#8211; Login failed for user</a></strong></li>
</ul>



<p>Let&#8217;s learn how to check default database settings for a SQL Server login and a user mapping for any database to the login.</p>



<h3 class="wp-block-heading">Check Login Properties</h3>



<p>The solution to fix this issue can also come by reviewing the properties of this login. Launch its properties window and change the default database to the correct one if this setting is showing wrong database. Sometimes, we drop the databases from the SQL Server instances but never update other objects. If this login is not showing any database and it is showing blank then click at its drop-down to choose your desired database as the default database for this login. Click on Ok button to apply that change. You will stop getting this issue after making this change. </p>



<p>You can open login properties windows by right click at the identified login and then choose properties from dropdown options.</p>



<p>Sometimes, you have chosen the default database as &#8220;master&#8221; but your login doesn&#8217;t have connect permission on master database so ensure you have at least connect permission on the database which you are choosing as the default database for your login. You can click at &#8220;User Mapping&#8221; tab from left side pane of the login properties window. You will get all databases in top side of right side pane and level of access in bottom side pane. Click at your database from right side pane along with its level of permission which you want to assign. Click at Ok button to apply this change.</p>



<p>Have a look at below screenshot to understand default database of a login and from where you can access User Mapping tab to provide appropriate access to your database. Your login should have access to both databases, the one mentioned as default database for your login and the specified database in connection strings.</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="//i0.wp.com/techyaz.com/wp-content/uploads/2021/09/image.png" alt="" class="wp-image-2748" width="586" height="526" srcset="https://techyaz.com/wp-content/uploads/2021/09/image.png 585w, https://techyaz.com/wp-content/uploads/2021/09/image-300x269.png 300w" sizes="(max-width: 586px) 100vw, 586px" /><figcaption class="wp-element-caption">SQL Server Login properties window</figcaption></figure>



<p>You can fix SQL error &#8220;Failed to Open the Explicitly Specified Database&#8221; by following above steps. Write your feedback if you have fixed this issue by other way. I will update this article accordingly with credits.</p>
<p>The post <a href="https://techyaz.com/sql-server/failed-to-open-the-explicitly-specified-database/">Fix SQL Error 18456: failed to open the explicitly specified database</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/failed-to-open-the-explicitly-specified-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix Always ON Connection Timeout Error 35206 in SQL Server</title>
		<link>https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/</link>
					<comments>https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 23 Jul 2021 09:01:25 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2613</guid>

					<description><![CDATA[<p>Recently, my company has migrated all critical SAP systems from on prem Linux based Oracle databases to Azure Cloud windows based SQL Server. These are very high end machines on which very large SQL Server databases are running with Alwayson&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/">Fix Always ON Connection Timeout Error 35206 in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, my company has migrated all critical SAP systems from on prem Linux based Oracle databases to Azure Cloud windows based SQL Server. These are very high end machines on which very large SQL Server databases are running with Alwayson configuration between 3 replicas. These databases are highly transactional, very large in size approximately more than 10 TB and these are configured to run critical SAP systems. Since few weeks, we have started facing very strange issue of connection timeout ( SQL error 35206 ) on one of our secondary availability replica. Below is full text of this SQL Server error 35206.</p>



<p class="has-vivid-red-color has-text-color"><em><strong>A connection timeout has occurred on a previously established connection to availability replica &#8216;manvendradbggp03&#8217; with id [availability group id]. Either a networking or a firewall issue exists or the availability replica has transitioned to the resolving role.</strong></em></p>



<p>You may also receive similar issue under different alwayson error 35201. Below error will generate while attempting to establish the connection to availability group but failed because of connection timeout error 35206. The error text of this SQL error 35201 is given below.</p>



<p class="has-vivid-red-color has-text-color"> <strong><em>A connection timeout has occurred while attempting to establish a connection to availability replica &#8216;manvendradbggp03&#8217; with id [availability group id]. Either a networking or firewall issue exists, or the endpoint address provided for the replica is not the database mirroring endpoint of the host server instance.</em></strong></p>



<p>If you are always getting above issues and unable to establish any connection to its respective availability replica then you should immediately look in to network side whether there is poor network latency, any network packet drop issue or firewall is blocking some connections or not as suggested in error code. But if you are getting this issue on intermittent basis then you should keep reading this article to understand more about alwayson error 35206.</p>



<h2 class="wp-block-heading">SQL Server Error 35206 and Error 35201 in Always on</h2>



<p>Both errors come because of connection timeout error between their respective replicas. Microsoft has categorized these errors as <a href="https://support.microsoft.com/en-us/topic/kb3213703-fix-an-always-on-secondary-replica-goes-into-a-disconnecting-state-10131118-b63a-f49f-b140-907f77774dc2" target="_blank" rel="noreferrer noopener">product issue</a> and released cumulative updates to fix them. You should also consider these cumulative updates as per your SQL Server version. These issues will be very problematic if you will not address them on time because of below reasons:</p>



<ul class="wp-block-list"><li>Availability databases will stop synchronizing. This could be a risk of potential data loss.</li><li>Log file will start growing on your primary replica. This could be a potential risk for an outage if we will not address this issue on time.</li><li>Frequent repetitive alerts for your critical systems</li></ul>



<p>You must fix this issue by applying the cumulative update to avoid above problematic scenarios. But if you already have applied these updates and are still facing these issues then i would recommend you to read below section to try out other options.</p>



<h2 class="wp-block-heading">Fix Always on Connection Timeout SQL Error 35206 </h2>



<p>Generally, this problem encounters only on high end systems where you have more than 24 cores CPU and SQL Server is highly transactional. One very simple workaround to overcome this issue is to restart SQL Server service on your secondary replica where you are getting this issue. Don&#8217;t restart SQL Server on primary replica. Restarting SQL Server on impacted availability replica will surely fix the issue for the time being. </p>



<p>Additionally, you should consider below checks to review and make changes accordingly as per your system design if you are still getting this issue on frequent basis.</p>



<h3 class="wp-block-heading">Use Default Network Packet Size</h3>



<p>Review network packet size configuration in SQL Server. Microsoft suggested to keep network packet size configuration with default value but sometime we make changes as per our need and forgot to revert these changes to their original values so i would recommend to revert this change to its default value. Read below article if you want to learn how to change network packet size configuration in SQL Server.</p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/sql-server-administration/change-network-packet-size-sql-server/" target="_blank" rel="noreferrer noopener"><strong>How to Change Network Packet Size in SQL Server?</strong></a></li></ul>



<p>You should also consider evaluating your network bandwidth and firewall settings to make sure and isolate the issue. I would suggest you to work with network engineer on this front to review network or firewall related configurations.</p>



<h3 class="wp-block-heading">Review Connection Timeout Setting</h3>



<p>Another option i would recommend you to evaluate and review the session or connection time out settings. Make sure that session timeout setting for your always on configuration must be more than or equal to 10 seconds. You can consider increasing session time out if you have slow network between your replicas. Although if you are running highly transactional databases on high end box i assume you already have good network bandwidth but nothing wrong in reviewing the settings. Read below article if you want to reconfigure or change session time out in always on availability group.</p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/" target="_blank" rel="noreferrer noopener"><strong>How to Change Session Timeout in Always on Availability Group Configuration?</strong></a></li></ul>



<p>If you are running your always on availability group configuration between multi subnet environment then i would recommend you to read attached Microsoft article to fix <a href="https://docs.microsoft.com/en-us/archive/blogs/alwaysonpro/connection-timeouts-in-multi-subnet-availability-group" target="_blank" rel="noreferrer noopener">connection timeout errors in multi subnet availability groups</a>.</p>



<p><strong><em>Read More:</em></strong> </p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-976/" target="_blank" rel="noreferrer noopener">Fix SQL Server Error 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</a></strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/" target="_blank" rel="noreferrer noopener">Fix SQL Server Error 19471: Listener issue that came during Configuring SQL Server AlwaysOn Availability Group</a> </strong></li><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Interview Questions &amp; Answers</a></strong></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/always-on-connection-timeout-error-35206/">Fix Always ON Connection Timeout Error 35206 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/alwayson/always-on-connection-timeout-error-35206/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to Change Session Timeout for Availability Group Replica</title>
		<link>https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/</link>
					<comments>https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Staff]]></dc:creator>
		<pubDate>Thu, 22 Jul 2021 17:44:39 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Connection Issue]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[HowTO]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2615</guid>

					<description><![CDATA[<p>Sometimes we get alwayson connection timeout errors on availability group replicas. Always on Connection timeout or alwayson session timeout is same and must be configured as per Microsoft recommendation. SQL Server Session timeout for availability replica is the time (in&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/">How to Change Session Timeout for Availability Group Replica</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Sometimes we get alwayson connection timeout errors on availability group replicas. Always on Connection timeout or alwayson session timeout is same and must be configured as per Microsoft recommendation. SQL Server Session timeout for availability replica is the time (in seconds) an availability replica will wait to get a ping response from connected replica before considering the connection as failed. </p>



<p>The connection timeout setting in AOAG applies only to identified secondary replica and its respective primary replica. Each secondary replica has its different session timeout value which works between the given replica and its primary replica. The default value for session timeout configuration is 10 seconds. Microsoft recommends to keep this setting value to 10 seconds or more to prevent system missing pings and false failure alerts.</p>



<h2 class="wp-block-heading">Change Session Timeout for Availability Replica</h2>



<p>This section will explain how to change or modify connection or session timeout value for an AOAG availability replica. This is needed sometimes if you are frequently getting connection timeout errors for your availability replicas. I will show two ways to modify session timeout in always on availability group. One is by using SQL Server Management Studio and another one by using T-SQL statement.</p>



<h3 class="wp-block-heading">Modify Alwayson Connection Timeout using SQL Server Management Studio</h3>



<p>Make sure you have connected to your SQL Server Instance which is hosting primary replica of always on availability group configuration. Follow below steps to change session timeout or connection timeout for identified availability replica where you are facing connection timeout errors 35206 or 35201.</p>



<ul class="wp-block-list"><li>Launch SQL Server Management Studio and connect to the primary replica</li><li>Expand folders once you connected to the primary replica instance. Click at plus sign to expand Always on High Availability node followed by Availability Groups node.</li><li>Identify and click the availability group for which you have to configure connection timeout for one of its availability replica</li><li>Identify the availability replica for which you have to change this value. Right click at this replica and click at Properties option to launch its properties page</li><li>You can see Session timeout (seconds)&nbsp;option In the&nbsp;Availability Replica Properties&nbsp;dialog box. Use Session timeout (seconds)&nbsp;option to change the number of seconds for the session timeout period on this replica. Always keep it 10 or more as per your specific need. </li></ul>



<p>We have successfully changed alwayson connection timeout for an availability replica using SQL Server management studio in above steps. Now, i will show you T-SQL approach to get this done in below section.</p>



<h3 class="wp-block-heading">Change Alwayson Connection Timeout using T-SQL Statement</h3>



<p>Here, i will show you how to change session timeout for an availability replica using T-SQL statement.</p>



<ul class="wp-block-list"><li>Launch SQL Server Management Studio and connect to the primary replica.</li><li>Open New Query window and run below ALTER AVAILABILITY GROUP statement.</li></ul>



<p class="has-text-align-left has-black-color has-text-color"><strong>ALTER AVAILABILITY GROUP&nbsp;<em>group_name</em></strong></p>



<p class="has-text-align-left has-black-color has-text-color"><strong>MODIFY REPLICA ON &#8216;<em>instance_name</em>&#8216; WITH ( SESSION_TIMEOUT =<em>seconds</em>&nbsp;)</strong></p>



<p>Make sure to replace <em>group_name</em> with your availability group name, <em>instance_name</em> with your secondary replica name for which you want to change session timeout value and <em>seconds</em> with appropriate time in seconds.</p>



<p>Once you will execute above statement, connection timeout value will change as per your specified value for your availability replica. Now, you can go ahead and monitor the connection timeout errors to see whether your issue has been fixed or not.</p>



<p>Here, i have explained how to modify or change session timeout for an always on availability group replica.</p>



<p><strong><em>Read More:</em></strong></p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Interview Questions &amp; Answers</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/alwayson/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noreferrer noopener">Understanding Backup Preferences for AlwaysOn Availability Group Databases</a></strong></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/">How to Change Session Timeout for Availability Group Replica</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/change-session-timeout-for-availability-group-replica/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Learn How to use SQL Server BETWEEN Operator</title>
		<link>https://techyaz.com/sql-server/t-sql/learn-how-to-use-sql-server-between-operator/</link>
					<comments>https://techyaz.com/sql-server/t-sql/learn-how-to-use-sql-server-between-operator/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Staff]]></dc:creator>
		<pubDate>Sat, 17 Jul 2021 16:06:06 +0000</pubDate>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[T-SQL Operators]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2563</guid>

					<description><![CDATA[<p>SQL BETWEEN operator is used to get values between a range of data inputs. We can use SQL BETWEEN operator with SELECT, UPDATE, INSERT and DELETE statements. Range can be defined based on text, date or numbers values. Here i&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/t-sql/learn-how-to-use-sql-server-between-operator/">Learn How to use SQL Server BETWEEN Operator</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>SQL BETWEEN operator is used to get values between a range of data inputs. We can use SQL BETWEEN operator with SELECT, UPDATE, INSERT and DELETE statements. Range can be defined based on text, date or numbers values. Here i will show you multiple use cases of this operator like get values between two date ranges using SQL BETWEEN operator, get details between two numbers using SQL Server operator BETWEEN etc.</p>



<h2 class="wp-block-heading">Get Values between Two Dates using SQL BETWEEN</h2>



<p>Let&#8217;s say you have a requirement to get all values between two date ranges or specific date time ranges. You can use SQL BETWEEN operator to get this done. Here is the example to get all values between date 19th March 2021 and 20th March 2021. Below example is also an use case of how to use BETWEEN operator in WHERE clause. You can remove &#8216;-&#8216; from date ranges if you want and you can directly mention date ranges as <em>&#8216;20210319&#8217; AND &#8216;20210320&#8217;.</em></p>



<p class="has-text-color" style="color:#0a43eb"><strong>SELECT name, type_desc,create_date, modify_date<br>FROM sys.objects<br>WHERE modify_date BETWEEN &#8216;2021-03-19&#8217; AND &#8216;2021-03-20&#8217;</strong></p>



<p>Here, i have fetched all modified objects on my SQL Server between given date range. Here is the output. We can see there are more than 730 rows returned. You can compare the dates in modify_date column whether output has returned correct data or not. </p>



<figure class="wp-block-image size-large is-style-default"><img decoding="async" width="1024" height="609" src="//i0.wp.com/techyaz.com/wp-content/uploads/2021/07/1-BETWEEN-Operator-1024x609.jpg" alt="SQL BETWEEN Operator with Date ranges" class="wp-image-2580" srcset="https://techyaz.com/wp-content/uploads/2021/07/1-BETWEEN-Operator-1024x609.jpg 1024w, https://techyaz.com/wp-content/uploads/2021/07/1-BETWEEN-Operator-300x178.jpg 300w, https://techyaz.com/wp-content/uploads/2021/07/1-BETWEEN-Operator-768x456.jpg 768w, https://techyaz.com/wp-content/uploads/2021/07/1-BETWEEN-Operator.jpg 1489w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now, Next requirement could be to retrieve some data between two date time ranges like you want details between specific time of dates. I will take same above query to show case this example as well. When we don&#8217;t specify the time along with date range then it defaults to 12:00 A.M. </p>



<p class="has-text-color" style="color:#0a43eb"><strong>SELECT name, type_desc,create_date, modify_date<br>FROM sys.objects<br>WHERE modify_date BETWEEN &#8216;2021-03-19 4:38:00&#8217; AND &#8216;2021-03-19 4:38:30&#8217;</strong></p>



<p>Here, i have retrieved all modified objects between 30 seconds of above given time (Time 4:38:00 to 4:38:30). Here is the output and it is showing only 35 rows.</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="1024" height="608" src="//i0.wp.com/techyaz.com/wp-content/uploads/2021/07/2-BETWEEN-Operator-1024x608.jpg" alt="SQL BETWEEN Operator with two date time ranges" class="wp-image-2581" srcset="https://techyaz.com/wp-content/uploads/2021/07/2-BETWEEN-Operator-1024x608.jpg 1024w, https://techyaz.com/wp-content/uploads/2021/07/2-BETWEEN-Operator-300x178.jpg 300w, https://techyaz.com/wp-content/uploads/2021/07/2-BETWEEN-Operator-768x456.jpg 768w, https://techyaz.com/wp-content/uploads/2021/07/2-BETWEEN-Operator.jpg 1485w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>You can use this SQL between two date ranges or datetime ranges to fetch your data. You can use this operator in INSERT, UPDATE or DELETE statements as well.</p>



<h2 class="wp-block-heading">Get Values between Two Numbers</h2>



<p>This section will explain about getting details between two number ranges. Let me take same table which we have taken for above section sys.objects. Now, i want to get all objects having object id between 25 to 30 or you can mention any range. This is just an example to showcase. These number ranges will change as per your need and nature of data. </p>



<p class="has-text-color" style="color:#0a43eb"><strong>SELECT name, object_id, type_desc, create_date<br>FROM sys.objects<br>WHERE object_id BETWEEN &#8217;25&#8217; AND &#8217;30&#8217;</strong></p>



<p>Note, above object_id is column name and not the T-SQL function. Have a look at its output in below image. We have got only rows which are assigned with these object ids.</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="500" height="305" src="//i0.wp.com/techyaz.com/wp-content/uploads/2021/07/3-BETWEEN-Operator.jpg" alt="SQL BETWEEN Operator with number ranges" class="wp-image-2582" srcset="https://techyaz.com/wp-content/uploads/2021/07/3-BETWEEN-Operator.jpg 500w, https://techyaz.com/wp-content/uploads/2021/07/3-BETWEEN-Operator-300x183.jpg 300w" sizes="auto, (max-width: 500px) 100vw, 500px" /></figure>



<h2 class="wp-block-heading">Use BETWEEN with NOT Operator</h2>



<p>Above all examples shows how to get data between two ranges but we can use NOT operator with BETWEEN to return all values which is not between specified two ranges. Let&#8217;s take above example where BETWEEN operator has returned only 5 rows based on their specified two ranges. Now if i will use NOT operator in above T-SQL statement then output will return all rows of table sys.objects except above 4 rows which will be prevented by NOT operator. Let me show you this example.</p>



<p class="has-text-color" style="color:#0a43eb"><strong>SELECT name, object_id, type_desc, create_date<br>FROM sys.objects<br>WHERE object_id NOT BETWEEN &#8217;25&#8217; AND &#8217;30&#8217;</strong></p>



<p>Have  a look at below highlighted are where objects ids between 25 to 30 are missing.</p>



<figure class="wp-block-image size-large is-style-default"><img loading="lazy" decoding="async" width="547" height="597" src="//i0.wp.com/techyaz.com/wp-content/uploads/2021/07/4-BETWEEN-Operator.jpg" alt="SQL BETWEEN Operator with NOT operator" class="wp-image-2583" srcset="https://techyaz.com/wp-content/uploads/2021/07/4-BETWEEN-Operator.jpg 547w, https://techyaz.com/wp-content/uploads/2021/07/4-BETWEEN-Operator-275x300.jpg 275w" sizes="auto, (max-width: 547px) 100vw, 547px" /></figure>



<p>Here, i have shown you few use cases of SQL Server T-SQL operator BETWEEN statement. You can go head and try this operator for your business needs. For more information on this operator, visit <a href="https://docs.microsoft.com/en-us/sql/t-sql/language-elements/between-transact-sql?view=sql-server-ver15" target="_blank" rel="noreferrer noopener">MSDN</a> article.</p>



<p class="has-vivid-red-color has-text-color"><strong><em>Read More</em></strong></p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/" target="_blank" rel="noreferrer noopener">Fix:VIEW SERVER STATE permission was denied on object ‘server’, database ‘master’</a></strong></li><li><strong><a href="https://techyaz.com/sql-server/t-sql/difference-between-union-and-union-all-operators/" target="_blank" rel="noreferrer noopener">Difference between UNION and UNION ALL T-SQL Operators</a></strong></li><li><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-interview-questions-answers-indexes/" target="_blank" rel="noreferrer noopener"><strong>SQL Server Interview Questions &amp; Answers on Indexes</strong></a></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/t-sql/learn-how-to-use-sql-server-between-operator/">Learn How to use SQL Server BETWEEN Operator</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/t-sql/learn-how-to-use-sql-server-between-operator/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 121 &#8211; The Semaphore Timeout Period Has Expired</title>
		<link>https://techyaz.com/sql-server/fix-sql-server-error-121-semaphore-timeout-period-has-expired/</link>
					<comments>https://techyaz.com/sql-server/fix-sql-server-error-121-semaphore-timeout-period-has-expired/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 15 Jun 2021 14:15:47 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2549</guid>

					<description><![CDATA[<p>Yesterday one of my teammate got a weird error while executing a T-SQL script. We are talking about SQL Server error 121 the semaphore timeout period has expired. Error details are showing below: A transport-level error has occured when receiving&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/fix-sql-server-error-121-semaphore-timeout-period-has-expired/">Fix SQL Server Error 121 &#8211; The Semaphore Timeout Period Has Expired</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Yesterday one of my teammate got a weird error while executing a T-SQL script. We are talking about SQL Server error 121 the semaphore timeout period has expired. Error details are showing below:</p>



<p><strong>A transport-level error has occured when receiving results from the server. (provider: TCP Provider, error: 0 &#8211; The semaphore timeout period has expired.) (Microsoft SQL Server, Error:121)</strong></p>



<p>This was an intermittent issue and when we were executing the script from other server it was not throwing any issue. I did some research on this and found out that this error came because of unstable network connectivity.</p>



<h2 class="wp-block-heading">SQL Server Error 121 The Semaphore Timeout Period Has Expired &#8211; Root Cause</h2>



<p>There are various parameters that can affect network connectivity like network adaptors, packet drop, configured packet size etc. So i would suggest first you should connect to your network team and ask them to look into this issue. If network team has not found anything then you need to check application level network configurations at your level.</p>



<p>You should ask some questions to your network resource like whether any network packet drop being observed or not, or is there any NIC card issue etc. Let&#8217;s assume you have already reached out to network team and they haven&#8217;t found anything. I would suggest you to look into below options at your level to make sure everything is in place and not misconfigured.</p>



<ul class="wp-block-list"><li>Check TCP\IP settings</li><li>Ensure you have appropriate network packet size configured in SQL Server</li><li>Make sure you have properly configured TCP Chimney Offload</li><li>Validate you don&#8217;t have Network Interface Card (NIC) driver issue, you can get it checked with your network team</li></ul>



<h2 class="wp-block-heading">Solution</h2>



<p>I have already described high level areas where you need to look in in above section. Let&#8217;s discuss them further here.</p>



<h4 class="wp-block-heading"><strong>Check TCP\IP settings</strong> </h4>



<p>You should open SQL Server configuration manager and check whether TCP configuration is properly done or not. Make sure to review all settings in SQL Server Network configuration settings. You should also read below article about this settings which causes a network error.</p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-network-interfaces-error-28-server-doesnt-support-requested-protocol/" target="_blank" rel="noreferrer noopener"><strong>Fix: SQL Network Interfaces Error 28&nbsp;– Server doesn’t support requested protocol</strong></a></li></ul>



<h4 class="wp-block-heading"><strong>Review Network Packet Size</strong></h4>



<p>You should also review network packet size configuration in SQL Server. This could be one of the possible reason for this issue. Ideally we should not change the default value of this setting and keep it as it is until you have a specific requirement to change network packet size. Read below article to understand and learn network packet size in SQL Server and also step by step process about how to change the network packet size to your desired value.</p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/sql-server-administration/change-network-packet-size-sql-server/" target="_blank" rel="noreferrer noopener"><strong>How to Change Network Packet Size Configuration in SQL Server</strong></a></li></ul>



<h4 class="wp-block-heading"><strong>TCP Chimney Offload</strong></h4>



<p>This settings is very important if we have network related connectivity issue. <a href="https://docs.microsoft.com/en-US/troubleshoot/windows-server/networking/information-about-tcp-chimney-offload-rss-netdma-feature" target="_blank" rel="noreferrer noopener">TCP Chimney Offload</a> is a networking technology that helps transfer the workload from the CPU to a network adapter during network data transfer. It can be enabled or disabled in the following two locations:</p>



<ul class="wp-block-list"><li>The operating system</li><li>The advanced properties page of the network adapter</li></ul>



<p>TCP Chimney Offload will work only if it is enabled in both locations. By default, TCP Chimney Offload is disabled in both these locations. However, OEM installations may enable TCP Chimney Offload in the operating system, in the network adapter, or in both the operating system and the network adapter. </p>



<h4 class="wp-block-heading"><strong>Validate Network related Driver Issues</strong></h4>



<p>You should speak to your network resource and Windows OS platform resource and validate all drivers at OS layer and network layer should be up to date and they should not have any issue. Make sure to update the drivers if you found any issue any of these layer.</p>



<p>I hope you can fix your issue by following above steps mentioned in this article. Comment us how you have fixed this issue, the semaphore timeout period has expired.) (Microsoft SQL Server, Error:121)</p>



<p><strong><span style="color:#2e65d1" class="has-inline-color">Related Articles</span></strong></p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-40-network-related-instance-specific-error-occurred-establishing-connection/" target="_blank" rel="noreferrer noopener">SQL Server Error 40: A network-related or instance-specific error occurred while establishing a connection to SQL Server.</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1418-the-server-network-address-cannot-be-reached-or-does-not-exist/" target="_blank" rel="noreferrer noopener">Fix Error 1418: The server network address cannot be reached or does not exist.</a></strong></li><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-network-interfaces-error-28-server-doesnt-support-requested-protocol/" target="_blank" rel="noreferrer noopener">Fix: SQL Network Interfaces Error 28&nbsp;– Server doesn’t support requested protocol</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/a-network-error-occurred-while-attempting-to-read-from-the-file/" target="_blank" rel="noreferrer noopener">SQL Server Native Client Error 50000: A network error occurred while attempting to read from the file</a></strong></li></ul>
<p>The post <a href="https://techyaz.com/sql-server/fix-sql-server-error-121-semaphore-timeout-period-has-expired/">Fix SQL Server Error 121 &#8211; The Semaphore Timeout Period Has Expired</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/fix-sql-server-error-121-semaphore-timeout-period-has-expired/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Change Authentication Mode in SQL Server?</title>
		<link>https://techyaz.com/sql-server/change-authentication-mode-in-sql-server/</link>
					<comments>https://techyaz.com/sql-server/change-authentication-mode-in-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 14 Jun 2021 16:24:20 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2539</guid>

					<description><![CDATA[<p>Authentication is a process to establish a successful connection. SQL Server provides two types of authentication modes to connect to their database instances. Authentication Mode is configured while installing SQL Server instance. We can also change SQL Server authentication mode&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/change-authentication-mode-in-sql-server/">How to Change Authentication Mode in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Authentication is a process to establish a successful connection. SQL Server provides two types of authentication modes to connect to their database instances. Authentication Mode is configured while installing SQL Server instance. We can also change SQL Server authentication mode later post installation. Below are two types of authentication modes in SQL Server.</p>



<ul class="wp-block-list"><li>Mixed Mode ( Windows +SQL Server login )</li><li>Windows Mode (Only Windows)</li></ul>



<p>Mixed mode provides two ways to establish database connections. One is using SQL Server logins at SQL Server layer and another one is using Windows domain user authenticated using active directory and whose login is created and mapped on SQL Server instance.</p>



<p>Windows Mode has only one way to establish database connections and that is using windows domain accounts. We must map windows accounts on SQL Server first before making any database connections. This mode doesn&#8217;t provide access to SQL Server logins. </p>



<p class="has-text-color has-vivid-red-color"><strong>Read More to Grow:</strong></p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-interview-questions-answers-indexes/" target="_blank" rel="noreferrer noopener">SQL Server Interview Questions &amp; Answers on Indexes</a></strong></li><li><strong><a href="https://techyaz.com/learning/prepare-for-job-interview/" target="_blank" rel="noreferrer noopener">How to Prepare for a Job Interview?</a></strong></li><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noreferrer noopener">SQL Server Alwayson Interview Questions &amp; Answers</a></strong></li><li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/replication-qa-part-1/">SQL Server Replication Interview Questions &amp; Answers</a></strong></li></ul>



<h2 class="wp-block-heading">Why Windows Authentication Mode is More Secure in SQL Server?</h2>



<p>Windows mode is secure than Mixed mode authentication because mixed mode has SQL Server authentication which cannot use Kerberos security protocol. Windows account needs to be authenticated to domain active directory every time you establish a database connection. Also, Windows provides additional password policies that are not available for SQL Server logins and that is why Microsoft always recommends to use Windows authentication mode wherever it&#8217;s possible.</p>



<p>One more risk with Mixed mode is the encrypted SQL Server Authentication login password must be passed over the network at the time of the connection. Some applications that connect automatically will store the password at the client. These are additional attack points. </p>



<h2 class="wp-block-heading">Change Authentication Mode in SQL Server</h2>



<p>You can configure authentication mode in SQL Server during installing it to your system. SQL Server installation windows will allow you to choose any one of above given authentication modes. If you will choose mixed authentication mode then you need to provide sa password as per windows password policy. You can also change existing authentication mode setting to another one as per your business need.</p>



<p>Let&#8217;s assume you have installed SQL Server with Mixed authentication mode and now you have to change it to Windows Authentication mode. This section will explain step by step process to change SQL Server authentication mode.</p>



<p>We can set or change authentication mode in SQL Server either using SQL Server management studio or using T-SQL statements. </p>



<h3 class="wp-block-heading"><strong>Using SQL Server Management Studio</strong></h3>



<ol class="wp-block-list"><li>Launch SQL Server Management Studio, connect to your target SQL Server instance.</li><li>In SQL Server Management Studio Object Explorer, right-click the server, and then click&nbsp;<strong>Properties</strong>.</li><li>On the&nbsp;<strong>Security</strong>&nbsp;page, under&nbsp;<strong>Server authentication</strong>, you can see both authentication modes. Select any as per your need and then click&nbsp;<strong>OK</strong>.</li><li>This change will require SQL Server service restart. A popup window will appear to ask you to restart the service when you will click at OK button in above step. </li><li>In Object Explorer, right-click your server, and then click&nbsp;<strong>Restart</strong>. If SQL Server Agent is running, it must also be restarted.</li></ol>



<p>You have changed your authentication mode from Mixed mode to Windows using SQL Server Management Studio. </p>



<p>If you are changing authentication mode from Windows to Mixed mode then make sure to enable SQL Server login sa account. This account gets disabled during windows authentication mode to secure your SQL Server instance as sa is generic SQL Server login as it can be targeted by hackers to access your instance. Below are the steps to enable this account:</p>



<ol class="wp-block-list"><li>In Object Explorer, expand&nbsp;<strong>Security</strong>, expand Logins, right-click&nbsp;<strong>sa</strong>, and then click&nbsp;<strong>Properties</strong>.</li><li>On the&nbsp;<strong>General</strong>&nbsp;page, you might have to create and confirm a password for the&nbsp;<strong>sa</strong>&nbsp;login.</li><li>On the&nbsp;<strong>Status</strong>&nbsp;page, in the&nbsp;<strong>Login</strong>&nbsp;section, click&nbsp;<strong>Enabled</strong>, and then click&nbsp;<strong>OK</strong>.</li></ol>



<h3 class="wp-block-heading"><strong>Using T-SQL Statement</strong></h3>



<p>Microsoft has provided an extended stored procedure to chnage authenication mode in SQL Server using T-SQL statement. This extended stored procedure chnages windows registry entries so be careful while changing authentication mode in SQL Server using T-SQL statements. Make sure to take a backup of windows registry before executing this script.</p>



<p><code><strong>USE [master]<br>GO<br>EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',<br>N'Software\Microsoft\MSSQLServer\MSSQLServer',<br>N'LoginMode', REG_DWORD, 1<br>GO</strong></code></p>



<p>Above command has again changed authenticating mode from mixed to windows.</p>



<p>If you are doing other way around then make sure to enable sa login as i suggested above. You can also use below T-SQL statement to enable sa account.</p>



<p><code><strong>ALTER LOGIN sa ENABLE ;<br>GO<br>ALTER LOGIN sa WITH PASSWORD = 'STRONG-PASSWORD' ;<br>GO</strong></code></p>



<p>Here, i have explained how to change SQL Server authentication mode from Windows to Mixed mode or vice versa. Please comment us if you have any feedback on this article.</p>



<p class="has-text-color has-vivid-red-color"><strong>Related Articles:</strong></p>



<ul class="wp-block-list"><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/" target="_blank" rel="noreferrer noopener">Fix SQL Server Error 18456: Login failed for user ‘User_Name’.</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/change-sql-server-instance-name/" target="_blank" rel="noreferrer noopener">How to Change SQL Server Instance Name?</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/t-sql/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/" target="_blank" rel="noreferrer noopener">Create a Logon Trigger to Restrict sysadmin logins to connect to SQL Server for given Time Interval</a> </strong></li><li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/" target="_blank" rel="noreferrer noopener">Fix Error 18452: Login failed. The login is from an untrusted domain</a> </strong></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/change-authentication-mode-in-sql-server/">How to Change Authentication Mode 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-authentication-mode-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 802: There is insufficient memory available in the buffer pool.</title>
		<link>https://techyaz.com/sql-server/fix-sql-server-error-802-insufficient-memory-in-buffer-pool/</link>
					<comments>https://techyaz.com/sql-server/fix-sql-server-error-802-insufficient-memory-in-buffer-pool/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sat, 12 Jun 2021 09:37:54 +0000</pubDate>
				<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Memory Issues]]></category>
		<category><![CDATA[performance tuning]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2533</guid>

					<description><![CDATA[<p>We receive SQL Server error 802 when buffer pool of SQL Server instance is full and cannot grow further. Here, i will discuss about this error 802 insufficient memory available in the buffer pool in this article along with its&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/fix-sql-server-error-802-insufficient-memory-in-buffer-pool/">Fix SQL Server Error 802: There is insufficient memory available in the buffer pool.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We receive SQL Server error 802 when buffer pool of SQL Server instance is full and cannot grow further. Here, i will discuss about this <em>error 802 insufficient memory available in the buffer pool</em> in this article along with its possible solution to fix it. Below is the error text you might get on your SQL Server system. </p>



<p><span class="has-inline-color has-luminous-vivid-orange-color">SQLServer Error: 802, There is insufficient memory available in the buffer pool. [SQLSTATE 42000]</span></p>



<h2 class="wp-block-heading"><span style="color:#170ce9" class="has-inline-color">SQL Server Error 802 &#8211; Insufficient Memory Available in the Buffer Pool</span></h2>



<p>The main reason behind getting SQL Server error 802 is your SQL Server instance is under memory pressure and there is not enough memory available to allocate further to buffer pool or buffer pool is restricted to not use memory beyond a certain limit. This might be because of various reasons as i have stated in below section. One of the very easy and straight forward approach to fix this error is to increase more memory to SQL Server system and modify max server memory in SQL Server accordingly.</p>



<h2 class="wp-block-heading"><span style="color:#170ce9" class="has-inline-color">Analysis &amp; Solution</span></h2>



<p>I would suggest to go deeper in this issue before taking any decision to allocate more memory to the system where SQL Server is running. There could be multiple temporary reasons as well which can cause SQL Server to generate below error log:</p>



<p><em><strong>SQL Server Error: 802, There is insufficient memory available in the buffer pool. [SQLSTATE 42000]</strong></em></p>



<p>Let&#8217;s discuss this issue further and ensure to not forget below points before taking any decisions.</p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<ol class="wp-block-list"><li>Check system memory utilization and see if other application (not SQL Server) is not taking enough memory. Try to fix it why a particular application is taking more memory.</li><li>Make sure you have allocated enough memory in min server memory &amp; max server memory setting. You can get these setting by executing <em><strong>sp_configure</strong></em> stored procedure. Sometimes, our server has enough memory but we missed to allocate appropriate memory to SQL Server. Rule is to allocate 80% of server memory to SQL Server under max server memory setting.</li><li>Ensure to <a href="https://techyaz.com/sql-server/enable-lock-pages-in-memory-sql-server/" target="_blank" rel="noreferrer noopener"><strong>enabled Lock Pages in memory</strong></a> on your SQL Server Instance.</li><li>Validate SQL Server version and Ensure you haven&#8217;t exceeded SQL Server edition limits. Like suppose you are running with SQL Server 2012 standard edition which allows only 64 GB of RAM support and if you have allocated more than 64GB RAM then it will not be useful. Either reduce the max server memory setting to 64 or upgrade your SQL Server to leverage bigger chunk of memory utilization. </li><li>Observe your SQL Server workload. Are you getting this error during a specific time frame or operations? Or Are you getting this error when some job or number of adhoc transactions are increased? Gather these details with the help of memory clerks and DBCC MEMORYSTATUS T-SQL statements. Tune your quires and ensure to not run ad hoc queries in large numbers because their plan is not saved in cache and they have to generate sql plan every time you execute them.</li><li>Collect Memory related counters like SQL Server: Buffer Manager, SQL Server: Memory Manager, Page Life Expectancy etc. You can read attached article to understand <a href="https://techyaz.com/sql-server/performance-tuning/top-10-performance-counters-to-identify-sql-server-memory-pressure/" target="_blank" rel="noreferrer noopener"><strong>Top 10 counters to identify memory pressure</strong></a>.</li><li>Review another sp_configure setting min memory per query.</li><li>You can try clearing cache by running below DBCC commands:<ul><li>DBCC FREESYSTEMCACHE</li><li>DBCC FREESESSIONCACHE</li><li>DBCC FREEPROCCACHE</li></ul></li></ol>



<p>If you still have memory pressure after analyzing and implementing solutions given in above section then you have only two options left and this is given below:</p>



<ol class="wp-block-list"><li>Increase Server memory and accordingly increase max server memory in sp_configure</li><li>Reduce your workload on this SQL Server Instance by offloading or segregating the transactions during off peak hours.</li></ol>
</div></div>



<p>Please comment us about your issue experience and let me know how you have fixed your issue.</p>



<p><em><strong><span class="has-inline-color has-vivid-red-color">Related Articles</span></strong></em><strong><em><span class="has-inline-color has-vivid-red-color">:</span></em></strong></p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/performance-tuning/sql-server-error-701-there-is-insufficient-system-memory-to-run-this-query/" target="_blank" rel="noreferrer noopener">How to Fix SQL Server Error 701: There is insufficient system memory to run this query</a></li><li><a href="https://techyaz.com/sql-server/understanding-hybrid-buffer-pool-in-sql-server/" target="_blank" rel="noreferrer noopener">Understanding Hybrid Buffer Pool in SQL Server</a></li><li><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noreferrer noopener">SQL Server Interview Questions &amp; Answers</a></li></ul>
<p>The post <a href="https://techyaz.com/sql-server/fix-sql-server-error-802-insufficient-memory-in-buffer-pool/">Fix SQL Server Error 802: There is insufficient memory available in the buffer pool.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/fix-sql-server-error-802-insufficient-memory-in-buffer-pool/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Update Statistics Best Practices</title>
		<link>https://techyaz.com/sql-server/sql-server-update-statistics-best-practices/</link>
					<comments>https://techyaz.com/sql-server/sql-server-update-statistics-best-practices/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 15 Apr 2020 15:09:58 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Database maintenance]]></category>
		<category><![CDATA[update statistucs]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2510</guid>

					<description><![CDATA[<p>Update Statistics in SQL Server is very important maintenance activity to keep database&#8217;s statistics up to date. This helps SQL Server query optimizer to generate optimum query plan and improve database performance as well. Here, i will explain the best&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-update-statistics-best-practices/">SQL Server Update Statistics Best Practices</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Update Statistics in SQL Server is very important maintenance activity to keep database&#8217;s statistics up to date. This helps SQL Server query optimizer to generate optimum query plan and improve database performance as well. Here, i will explain the best practices to run SQL Server update statistics on very large tables or databases.</p>



<p> We should be very careful while running any of the database maintenance activities on production databases. It becomes more crucial if your database size is very very big or some critical business application is using this database. Yesterday i had similar experience in one of our SAP system. Application team had reported performance issue while accessing one of the SAP system. DBAs were involved and identified a long running query that was causing the performance issue. This long running query was executing update statistics SQL Server operation on one of the biggest table in the database.  This activity took very long time around 12 hours and never completed. Finally team has killed this transaction as advised by SAP support to improve the performance. </p>



<h2 class="wp-block-heading">Understanding Update Statistics in SQL Server</h2>



<p>SQL Server uses statistics to generate fastest query plan for any transaction so we should ensure all statistics must be up to date to get better query performance. As per MSDN <em>&#8220;Updating statistics ensures that queries compile with up-to-date statistics. However, updating statistics causes queries to recompile. We recommend not updating statistics too frequently because there is a performance tradeoff between improving query plans and the time it takes to recompile queries.&nbsp;&#8220;</em></p>



<p> Here, first i will explain one of my issue as case study and then will give you SQL update statistics best practices. There are multiple things that can lead to  longer duration of this execution, so first we should understand the issue before reaching on any conclusion.</p>



<p>After looking into SQL Server transactions, we found that SQL Server update statistics was being executed with FULLSCAN option. This was a potential reason behind taking it for longer duration. Avoid running update statistics with<strong> </strong>FULLSCAN option while running it on very big tables or databases because it scans each and every record in the table that will degrade the system performance and took more time to complete. Although, you should always rethink before making a decision to run update statistics on your database if auto update statistics has been set to ON. As it was SAP ECC database so we checked the SAP documentation as well and SAP also suggests to not run it regularly if auto update statistics is set to ON. This is SQL Server auto update statistics best practices for very large databases.</p>



<p>In some cases, if you still have to run the update stats then always Use it without mentioning FULLSCAN parameter or use sp_updatestats stored procedure. If you still need to run WITH FULLSCAN then do not run the UPDATE STATISTICS SQL Server command against the entire table. Identify the column or index statistic that needs the special treatment, and only update that one with FULLSCAN.</p>



<p>Sometimes, SQL Server update statistics command may take very long time even after following above measures. This could be because of the bug reported in <a href="https://support.microsoft.com/en-in/help/4527229/fix-update-statistics-takes-very-long-time-to-generate-maintenance-pla" target="_blank" rel="noreferrer noopener">attached link</a>. This has been fixed in below CU updates. Check your SQL Server version and apply them to fix this issue if applicable.</p>



<ul class="wp-block-list"><li><a href="https://support.microsoft.com/help/4536075">Cumulative Update 2 for SQL Server 2019</a></li><li><a href="https://support.microsoft.com/help/4527377">Cumulative Update 18 for SQL Server 2017</a></li><li><a href="https://support.microsoft.com/help/4527378">Cumulative Update 11 for SQL Server 2016 SP2</a></li></ul>



<h2 class="wp-block-heading">SQL Server Update Statistics Best Practices</h2>



<p>Below is the list of best practices i have mentioned to be considered while running update statistics in SQL Server. Have a look at them.</p>



<ol class="wp-block-list" type="1"><li>Running Update Statistics on very big tables or database can increase <a rel="noreferrer noopener" href="https://techyaz.com/sql-server/identify-disk-bottleneck-using-perfmon-counters/" target="_blank">huge IO pressure on your disk subsystem</a>. SQL Server has very good feature to keep running it in real time by setting value auto update statistics to ON. If auto update statistics is set to ON then <strong>it is strongly recommended to not run it regularly on any databases</strong>. We can run it only on those tables where this setting is set to OFF. </li><li>In some cases, if you still have to run the update stats then always <strong>Use it without mentioning FULLSCAN parameter or use sp_updatestats</strong> stored procedure. If you still need to run WITH FULLSCAN then<strong> Do not run the UPDATE STATISTICS command against the entire table</strong>. Identify the column or index statistic that needs the special treatment, and only update that one with FULLSCAN.</li><li>Always run such database maintenance activities during maintenance windows. It is not recommended to run during business hours.</li><li>If you are facing performance issue during update stats execution then you should check the possibilities of potential  bug reported in <a rel="noreferrer noopener" href="https://support.microsoft.com/en-in/help/4527229/fix-update-statistics-takes-very-long-time-to-generate-maintenance-pla" target="_blank">attached link</a>.</li><li>Never run Adhoc and manual Update stats on any of the very big tables if Auto Update Statistics is set to ON because Update stats is very costly operations in terms of heavy IO activities. It does acquire schema-stability locks so it can potentially be blocked by a DDL operation (like ALTER TABLE).</li><li>One way to find out whether you should run update stats or not is to check if your statistics are stale in the execution plans or not. If estimated rows greatly differ from your actual rows returned in execution plan then that is a good indication of potential update stats candidate.</li><li>Ask Migration team (In case recently migrated) whether they have executed rebuild index or update stats after migrating data to SQL Server as part of post upgrade activity? Ideally it is recommended to run update stats after massive data load because auto update stats does not automatically update all records.</li><li>If you’ve got tables with millions of rows, and you’ve found that statistics aren’t updating fast enough, you can consider:<ul><li>Turning on Trace Flag 2371 to make auto-update statistics run more frequently on tables with large amounts of rows.</li><li>Using a third party script to handle statistics maintenance along with your index maintenance</li></ul></li><li>One way to find out if your statistics are stale is to look at the execution plans and if you estimated rows greatly differ from your actual rows returned then that is a good indication that the interval needs to be upped. If you want to do update Statistics manually you should first know&nbsp;When Statistics are updated automatically.</li><li>If the SQL Server query optimizer requires statistics for a particular column in a table that has undergone substantial update activity since the last time the statistics were created or updated, SQL Server automatically updates the statistics by sampling the column values (by using auto update statistics).&nbsp;</li></ol>



<h2 class="wp-block-heading">Update Statistics on AlwaysON Secondary Replica</h2>



<p>Temporary statistics are an improvement added in SQL Server 2012 for read-only databases. When a database is read-only, queries can’t create statistics in the database– because those require writes. As of SQL Server 2012, temporary statistics can be created in tempdb to help optimization of queries.</p>



<p>This is incredibly useful for:</p>



<ul class="wp-block-list"><li>Readable secondaries in an AlwaysOn Availability Group</li><li>Readable logshipping secondary databases</li><li>A point in time database snapshot which is queried (whether against a database mirror or live database)</li><li>Any other read-only database that has queries run against it</li></ul>



<p>Prior to SQL Server 2012, if you use logshipping for reporting&nbsp;and the same workload does not run against the log shipping publisher, consider manually creating column level statistics. (Or upgrading SQL Server.)</p>



<p><strong><span class="has-inline-color has-vivid-red-color">Read More</span></strong>:</p>



<ul class="wp-block-list"><li><a rel="noreferrer noopener" href="https://techyaz.com/sql-server/performance-tuning/understanding-database-autogrowth-sql-server/" target="_blank">Understanding Database Autogrowth in SQL Server</a></li><li><a rel="noreferrer noopener" href="https://techyaz.com/sql-server/avoid-database-shrink-operation/" target="_blank">Understanding Database Shrink Operation</a></li><li><a rel="noreferrer noopener" href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-alwayson-interview-questions-answers/" target="_blank">SQL Server AlwaysON Interview Questions &amp; Answers</a></li></ul>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-update-statistics-best-practices/">SQL Server Update Statistics Best Practices</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/sql-server-update-statistics-best-practices/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding Hybrid Buffer Pool in SQL Server</title>
		<link>https://techyaz.com/sql-server/understanding-hybrid-buffer-pool-in-sql-server/</link>
					<comments>https://techyaz.com/sql-server/understanding-hybrid-buffer-pool-in-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sun, 30 Dec 2018 12:02:57 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[New features]]></category>
		<category><![CDATA[SQL Server 2019]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2454</guid>

					<description><![CDATA[<p>Microsoft introduces a new feature called<br />
Hybrid Buffer Pool in SQL Server 2019 CTP 2.1. Read this article to understand this feature.</p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-hybrid-buffer-pool-in-sql-server/">Understanding Hybrid Buffer Pool in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Microsoft introduces a new feature called Hybrid Buffer Pool in SQL Server 2019 CTP 2.1. This feature allows direct access of data pages in database files stored in persistent memory (PMEM) devices.</p>



<p>Before going ahead, you might be thinking what is Persistent Memory devices and how it is related to SQL Server. Let me first explain about persistent memory.</p>



<h4 class="wp-block-heading">What is Persistent Memory?</h4>



<p>Persistent memory generally termed as PMEM, is a solid-state high performance byte-addressable memory device that resides on the memory bus. It has many benefits over other storage devices.<br></p>



<p>The main advantages of persistent memory include: </p>



<ul class="wp-block-list"><li>It provides fast data access near real-time without any latency than flash SSDs for large data sets as well.</li><li>PMEM increases throughput more than flash storage.</li><li>Biggest benefit is its cost. It&#8217;s cheaper than DRAM. </li><li>PMEM is cacheable. This is a huge advantage over PCIe interconnect, which cannot be cached in the CPU.</li><li>It retains Data in memory after power interruption or shut off. </li></ul>



<p>Persistent memory can be used in a variety of ways to deliver lower latency for applications where you need fast data access with enormous amount of data such as IoT applications, Cyber threat analysis, financial trading etc.</p>



<h4 class="wp-block-heading">What is Hybrid Buffer Pool?</h4>



<p>In a traditional system, SQL Server caches data pages in the buffer pool. With Hybrid Buffer Pool, SQL Server skips performing a copy of the page into the DRAM-based portion of the buffer pool, and instead references the page directly on the database file that lives on a PMEM device. Access to data files in PMEM for Hybrid Buffer Pool is performed using memory-mapped I/O, also known as enlightenment.  This brings performance benefits from avoiding a copy of the page to DRAM, and from the avoidance of the I/O stack of the operating system to access the page on persistent storage.  </p>



<p>Only clean pages can be referenced directly on a PMEM device. When a page becomes dirty it is kept in DRAM, and then eventually written back to the PMEM device.</p>



<p>This feature will be available in both Windows and Linux version of SQL Server 2019.</p>



<h4 class="wp-block-heading" id="enable-hybrid-buffer-pool">How to Enable Hybrid Buffer Pool?</h4>



<p>We can enable  Hybrid Buffer Pool for SQL Server instance by enabling trace flag during SQL Server startup. As of now, the current process is, we must enable the startup trace flag 809 in order to use Hybrid Buffer Pool.</p>



<p>Microsoft suggests a best practice to keep in mind while enabling  <br>Hybrid Buffer Pool in SQL Server. We should use largest allocation size available for NTFS and ensure the device has been enabled for DAX (DirectAccess) while formatting the PMEM device on Windows.</p>



<p>I hope you liked this article. Please write your comments if you have any questions.</p>



<p class="has-text-color has-vivid-red-color"><strong><em>Read More:</em></strong></p>



<ul class="wp-block-list"><li><a href="https://techyaz.com/sql-server/10-new-features-sql-server-2017-database-engine/">SQL Server 2017 New Features</a></li><li><a href="https://techyaz.com/sql-server/t-sql/new-t-sql-functions-introduced-sql-server-2017/">New T-SQL Functions introduced in SQL Server 2017</a></li><li><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/sql-server-dba-interview-questions-answers/">SQL Server DBA Interview Questions &amp; Answers</a></li></ul>



<p></p>



<p></p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-hybrid-buffer-pool-in-sql-server/">Understanding Hybrid Buffer Pool 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/understanding-hybrid-buffer-pool-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix:VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217;</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 30 Aug 2018 10:52:28 +0000</pubDate>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2435</guid>

					<description><![CDATA[<p>Yesterday, one of the app user was complaining that he is not able to execute some of the queries and facing &#8220;VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217; . (Microsoft SQL Server, Error 300) &#8221; error while&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/">Fix:VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Yesterday, one of the app user was complaining that he is not able to execute some of the queries and facing &#8220;<em>VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217; . (Microsoft SQL Server, Error 300) &#8221; </em>error while executing the script. The screenshot of this error is given below.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2436" src="https://techyaz.com/wp-content/uploads/2018/08/1-error-300-min.jpg" alt="SQL Server Error 300" width="723" height="193" srcset="https://techyaz.com/wp-content/uploads/2018/08/1-error-300-min.jpg 723w, https://techyaz.com/wp-content/uploads/2018/08/1-error-300-min-300x80.jpg 300w" sizes="auto, (max-width: 723px) 100vw, 723px" /></p>
<h3><span style="color: #000000;">VIEW SERVER STATE Permission</span></h3>
<p>This is high level server-level privilege which must not be granted to everybody. Only administrators must have privilege to use view server state permission but we can assign this permission to some users who want to see server level state of your SQL Server instance. Once you will grant this access to any login, he can see result of all DMVs.</p>
<h2><span style="color: #000000;">Solution &#8211; ( Microsoft SQL Server, Error 300 )</span></h2>
<p>We got SQL Server error 300 ( VIEW SERVER STATE permission was denied ) because the login you are using to execute the script doesn&#8217;t have this permission. To fix this issue we will grant view server state permission to the login name. This section will explain how to grant view server state permission to a login.</p>
<h3>Grant VIEW SERVER STATE Permission</h3>
<p>We can assign this permission either using GUI in SQL Server Management Studio or we can simply execute a T-SQL command to get this done. I will explain both ways to assign this permission.</p>
<p><strong><span style="color: #993300;">Using GUI in SQL Server Management Studio</span></strong></p>
<p>Follow below steps to do it using GUI.</p>
<ol>
<li>Launch SQL Server Management Studio.</li>
<li>Connect to the SQL Server Instance.</li>
<li>Navigate to <strong>Security </strong>folder then expand<strong> Logins</strong></li>
<li>Right Click at your login name and choose <strong>Properties</strong></li>
<li>Click at <strong>Securables</strong> tab from left side pane.</li>
<li>In the bottom pane, scroll to the bottom and click at <strong>Grant</strong> option for <strong>View Server State </strong>value.</li>
<li>Now click on apply to close the window. You can now ask your user to test the script again. This time it will work.</li>
</ol>
<p><strong><span style="color: #993300;">Using T-SQL statement in SQL Server Management Studio</span></strong></p>
<ol>
<li>Launch SQL Server Management Studio. Connect to the SQL Server Instance.</li>
<li>Open <strong>New Query </strong>window</li>
<li>Run below T-SQL statement</li>
</ol>
<pre><em><strong><span style="color: #0000ff;">USE master</span></strong></em>
<em><strong><span style="color: #0000ff;">GO</span></strong></em>
<em><strong><span style="color: #0000ff;">GRANT VIEW SERVER STATE TO "LoginName"</span></strong></em></pre>
<p>Once you execute above command, you will have view server state permission on your login name. You can resolve <em><strong>SQL Server error 300</strong></em> <strong><em>VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master </em></strong>issue by following above steps given in this article.</p>
<h3>Revoke VIEW SERVER STATE Permission</h3>
<p>If you have identified anyone who must not have this permission then you can go ahead and revoke his access post getting proper approvals. Make sure that identified login does not have any business justification before revoking his access. Once you have decided to go ahead to remove view server state permission then you should run below T-SQL statement to get this done. Below steps will tell you how to revoke view server state permission of any login.</p>
<p><em><strong><span style="color: #0000ff;">USE master</span></strong></em></p>
<p><em><strong><span style="color: #0000ff;">REVOKE VIEW SERVER STATE TO &#8220;LoginName&#8221;</span></strong></em></p>
<p><em><strong><span style="color: #0000ff;">GO</span></strong></em></p>
<p>View SERVER STATE permission has been revoked for identified login post successful execution of above statement.</p>
<p>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><span style="color: #800000;"><strong>Read More:</strong></span></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server AlwaysON Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noopener">SQL Server DBA Interview Questions &amp; Answers</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/interview-questions/sql-server-interview-questions/replication-qa-part-1/" target="_blank" rel="noopener">SQL Server Replication Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/">Fix:VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Error 5184: Cannot use file &#8216;I:\Path\Techyaz.mdf’ for clustered server</title>
		<link>https://techyaz.com/sql-server/clustering/error-5184-level-16-state-2-line-1-cannot-use-file-for-clustered-server/</link>
					<comments>https://techyaz.com/sql-server/clustering/error-5184-level-16-state-2-line-1-cannot-use-file-for-clustered-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 29 Aug 2018 12:10:18 +0000</pubDate>
				<category><![CDATA[Clustering]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2425</guid>

					<description><![CDATA[<p>Today, one of my team mate was trying to attach a database on one of the clustered SQL Server instance. He got error 5184 while attaching the database. The details about error 5184 is given below. Msg 5184, Level 16,&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/clustering/error-5184-level-16-state-2-line-1-cannot-use-file-for-clustered-server/">SQL Server Error 5184: Cannot use file &#8216;I:\Path\Techyaz.mdf’ for clustered server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, one of my team mate was trying to attach a database on one of the clustered SQL Server instance. He got error 5184 while attaching the database. The details about error 5184 is given below.</p>
<p><em><span style="color: #ff0000;">Msg 5184, Level 16, State 2, Line 1</span></em><br />
<em><span style="color: #ff0000;">Cannot use file ‘I:\Path\Techyaz.mdf’ for clustered server. </span></em><br />
<em><span style="color: #ff0000;">Only formatted files on which the cluster resource of the server has a dependency can be used. </span></em><em><span style="color: #ff0000;">Either the disk resource containing the file is not present in the cluster group or the cluster resource of the Sql Server does not have a dependency on it.</span></em></p>
<p><em><span style="color: #ff0000;">Msg 1802, Level 16, State 1, Line 1</span></em><br />
<em><span style="color: #ff0000;">CREATE DATABASE failed. Some file names listed could not be created. Check related errors.</span></em></p>
<p>While troubleshooting this error we came to know that the storage or LUN on which we have placed the database files are not added to cluster group. It means disk is not visible in failover cluster manager.</p>
<h3><span style="color: #333399;">Solution &#8211; Error 5184</span></h3>
<p>We performed below steps to fix this issue.</p>
<ol>
<li>Added the storage on which databases files are placed as shared storage in the failover cluster manager.</li>
<li>Launch SQL Server properties window in Failover Cluster Manager.</li>
<li>Added all newly added disks in Dependencies tab.</li>
<li>Attached the database again.</li>
</ol>
<p>Here i will explain above steps in detail with screenshots.</p>
<ul>
<li>We were attaching a database using T-SQL statement on one of the SQL Server cluster instance. While executing the command we get error 5184. Error details are given in below screenshot.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2426" src="https://techyaz.com/wp-content/uploads/2018/08/1-Error-Msg-min-1024x178.jpg" alt="Fix SQL Server Error 5184" width="659" height="115" srcset="https://techyaz.com/wp-content/uploads/2018/08/1-Error-Msg-min-1024x178.jpg 1024w, https://techyaz.com/wp-content/uploads/2018/08/1-Error-Msg-min-300x52.jpg 300w, https://techyaz.com/wp-content/uploads/2018/08/1-Error-Msg-min-768x133.jpg 768w, https://techyaz.com/wp-content/uploads/2018/08/1-Error-Msg-min.jpg 1066w" sizes="auto, (max-width: 659px) 100vw, 659px" /></p>
<ul>
<li>As error suggests that <em>“Either the disk resource containing the file is not present in the cluster group”</em> so I checked cluster group for the disk and found that database files storage was not showing in failover cluster manager.</li>
<li>Next step was to add these storage disks to the cluster group. Launch <strong>failover cluster manager</strong>. Click at <strong>Roles</strong> tab from left side pane. You can see SQL Server as role in right side pane. Right click at the SQL Server role and click at “<strong>Add Storage</strong>” option. You can see this in below screenshot.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2427" src="https://techyaz.com/wp-content/uploads/2018/08/2-Add-Storage-min.jpg" alt="Add Storage to Cluster group" width="514" height="329" srcset="https://techyaz.com/wp-content/uploads/2018/08/2-Add-Storage-min.jpg 589w, https://techyaz.com/wp-content/uploads/2018/08/2-Add-Storage-min-300x192.jpg 300w" sizes="auto, (max-width: 514px) 100vw, 514px" /></p>
<ul>
<li>Once you will click at “<strong>Add Storage</strong>” option you will get below window to add the identified disks to cluster group. You can see I have selected all required disks in below screenshot. You can choose your disks where your database files are placed.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2428" src="https://techyaz.com/wp-content/uploads/2018/08/3-Add-Storage-min.jpg" alt="Add Storage to cluster group" width="680" height="511" srcset="https://techyaz.com/wp-content/uploads/2018/08/3-Add-Storage-min.jpg 815w, https://techyaz.com/wp-content/uploads/2018/08/3-Add-Storage-min-300x225.jpg 300w, https://techyaz.com/wp-content/uploads/2018/08/3-Add-Storage-min-768x577.jpg 768w" sizes="auto, (max-width: 680px) 100vw, 680px" /></p>
<ul>
<li>Once you click at OK button post selecting all respective check boxes in above step, you will see all your storage disks in failover cluster manager under storage tab.</li>
<li>Now again click at the SQL Server role and then go to “<strong>Resources</strong>” tab from down side pane where you can see SQL Server and all resources that are aligned for the SQL Server role. Here, right click at SQL Server and click at Properties tab as shown in below screenshot.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2429" src="https://techyaz.com/wp-content/uploads/2018/08/4-Add-Dependencies-min.jpg" alt="Add Disk Dependencies in FCM" width="589" height="182" srcset="https://techyaz.com/wp-content/uploads/2018/08/4-Add-Dependencies-min.jpg 589w, https://techyaz.com/wp-content/uploads/2018/08/4-Add-Dependencies-min-300x93.jpg 300w" sizes="auto, (max-width: 589px) 100vw, 589px" /></p>
<ul>
<li>Once you get SQL Server properties windows in failover cluster manager, next you should click at dependencies tab. Here, you need to insert one row for each disk system that you have added in above steps. Once you will insert dependencies for all newly added disks then it will look like below screenshot. Now click at OK button to apply this change.</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2430" src="https://techyaz.com/wp-content/uploads/2018/08/5-Add-Dependencies-min.jpg" alt="Add Disk Dependencies in FCM" width="405" height="493" srcset="https://techyaz.com/wp-content/uploads/2018/08/5-Add-Dependencies-min.jpg 405w, https://techyaz.com/wp-content/uploads/2018/08/5-Add-Dependencies-min-246x300.jpg 246w" sizes="auto, (max-width: 405px) 100vw, 405px" /></p>
<ul>
<li>Now again go to SQL Server query window and run the T-SQL command to  attach the database. This time you will successfully attach the database to the clustered SQL Server instance.</li>
</ul>
<p>Let me know if this article helped you to fix your issue. You can follow our <a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">facebook</a> page and <a href="https://twitter.com/Tech_yaz" target="_blank" rel="noopener">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/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/learning/prepare-for-job-interview/" target="_blank" rel="noopener">How to Prepare for a Job Interview?</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noopener">SQL Server DBA Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/clustering/error-5184-level-16-state-2-line-1-cannot-use-file-for-clustered-server/">SQL Server Error 5184: Cannot use file &#8216;I:\Path\Techyaz.mdf’ for clustered server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/clustering/error-5184-level-16-state-2-line-1-cannot-use-file-for-clustered-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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 Native Client Error 50000: A network error occurred while attempting to read from the file</title>
		<link>https://techyaz.com/sql-server/troubleshooting/a-network-error-occurred-while-attempting-to-read-from-the-file/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/a-network-error-occurred-while-attempting-to-read-from-the-file/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 25 Jun 2018 12:59:40 +0000</pubDate>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2410</guid>

					<description><![CDATA[<p>Yesterday i have received SQL Server Native Client Error 5000 while installing SQL Server Management Studio on one of the client machine. The description for this error code was given as &#8220;A network error occurred while attempting to read from&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/a-network-error-occurred-while-attempting-to-read-from-the-file/">SQL Server Native Client Error 50000: A network error occurred while attempting to read from the file</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Yesterday i have received SQL Server Native Client Error 5000 while installing SQL Server Management Studio on one of the client machine. The description for this error code was given as <em>&#8220;A network error occurred while attempting to read from the file &lt;Filename&gt;.&#8221; </em> Here i will describe and explain about SQL Server Error 50000 and it&#8217;s fix to make SQL Server installation successful.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-2411 alignright" src="https://techyaz.com/wp-content/uploads/2018/06/SQL-Native-Client-Error-50000.png" alt="SQL Server Native Client Error 50000" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/06/SQL-Native-Client-Error-50000.png 300w, https://techyaz.com/wp-content/uploads/2018/06/SQL-Native-Client-Error-50000-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/06/SQL-Native-Client-Error-50000-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/06/SQL-Native-Client-Error-50000-320x320.png 320w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<h3><span style="color: #333399;">SQL Server Native Client Error 50000</span></h3>
<p>Before explaining about SQL native client error 50000, i would like to describe about what is SQL Server native client. As per MSDN <em>&#8220;SQL Server Native Client, is a term that has been used interchangeably to refer to ODBC and OLE DB drivers for SQL Server.&#8221; </em></p>
<p>SQL Server Native Client is a technology that we can use to access data in a SQL Server database. There are several factors you should consider while deciding whether to use SQL Server Native client or some other data access technology. You can read attached article about <a href="https://docs.microsoft.com/en-us/sql/relational-databases/native-client/when-to-use-sql-server-native-client?view=sql-server-2016">when to use SQL Server Native Client.</a></p>
<p>Generally, we get SQL Server native client error 50000 while installing or updating native client software or a software component that uses SQL Server Native Client and your target machine already have this installed previously using some msi file.</p>
<p>You can also get this issue if SQL Server native client file <em>sqlncli.msi </em>has been renamed after its installation and later today when you are trying to update it, you will end up with this SQL error 50000 . If somehow native client installation file has been renamed on your machine, setup will not find its file to update SQL Server native client and through below error.</p>
<p><span style="color: #ff0000;"><em>A network error occurred while attempting to read from the file &lt;Filename&gt;.&#8221;</em></span></p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To fix this error, you should uninstall installed version of SQL Server native client from add/remove program and then you can try to install SQL Server or its component again. This time you will not get any error and your software or native client will be installed. To avoid further issue, you can reboot the machine post uninstalling the native client tool.</p>
<p>If you are installing only SQL Server native client and not SQL Server then you can download it from Microsoft website and then reinstall it again.</p>
<p>You can also prevent this error to not generate in future by not installing it using its msi file sqlncli.msi. If you had installed it using this file, make sure to never rename it as well.</p>
<p>Here, I have shown you how to fix SQL Server Native Client Error 50000, <em>&#8220;A network error occurred while attempting to read from the file &lt;Filename&gt;.&#8221; </em> 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/troubleshooting/fix-sql-server-error-5009/" target="_blank" rel="noopener">Fix 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-sql-server-error-attributes-not-match/" target="_blank" rel="noopener">Fix SQL Server Installation Error: Attributes do not match</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-sql-server-installation-error-1639/" target="_blank" rel="noopener">How to Fix SQL Server Installation Error 1639?</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noopener">SQL Server DBA Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/a-network-error-occurred-while-attempting-to-read-from-the-file/">SQL Server Native Client Error 50000: A network error occurred while attempting to read from the file</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/a-network-error-occurred-while-attempting-to-read-from-the-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Enhanced Database Failover and How to Enable it for Availability Group?</title>
		<link>https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/</link>
					<comments>https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 22 Jun 2018 13:12:20 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[availability group]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2404</guid>

					<description><![CDATA[<p>As we know Always on Availability Group is the set of user databases that are combined to failover if primary replica becomes inaccessible. Till SQL Server 2014, Alwayson Availability Group was not able to start failover operation if any individual&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/">What is Enhanced Database Failover and How to Enable it for Availability Group?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As we know Always on Availability Group is the set of user databases that are combined to failover if primary replica becomes inaccessible. Till SQL Server 2014, Alwayson Availability Group was not able to start failover operation if any individual database within AOAG become inaccessible. Microsoft introduced an option named <em>Enhanced Database Failover</em> in SQL Server 2016 to trigger the failover in case any database participating in Availability Group loses the ability to write transactions. We also call it <em>Database Level Health Detection</em> in Availability Group.</p>
<p><em>Enhanced Database Failover</em> option is not mandatory while configuring Always on Availability Group in SQL Server 2016. It’s optional and If you have enabled <em>Enhanced Database Failover</em> option for any Availability Group along with automatic failover configuration then this option will trigger failover to a synchronized secondary replica in case any database participating in that availability group is no longer able to write transactions.</p>
<p>You cannot set this option for specific databases within availability group. <em>Enhanced database failover</em> or <em>database level health detection</em> will be enabled at availability group level. Once you configure it, all databases participating in that availability group can use this feature to trigger failover if anything goes wrong with them.</p>
<h3><span style="color: #333399;">Configure Enhanced Database Failover to Availability Group</span></h3>
<p>We can set this option as per our choice or requirement either by using GUI Wizard or by using Transact-SQL. As of now, you cannot configure <em>Enhanced Database Failover</em> option using PowerShell cmdlets. Remember, by default, enhanced database failover option is disabled. If you want to use this feature, you need to enable it. Here, I will explain how to enable <em>Enhanced Database Failover</em> to an Availability Group while its creation and to the existing one.</p>
<p>If you want to check whether an availability group has <em>enhanced database failover</em> enabled or not then we can use dynamic management view <strong>sys.availability_groups</strong>. You will see a column named <strong>db_failover</strong> in this DMV. If the value of any availability group is showing zero then it means this feature is disabled and if value shows 1 then it means it’s enabled. You can execute below command to get the settings for all availability group.</p>
<pre><strong><span style="color: #0000ff;">select name, db_failover from sys.availability_groups</span></strong><strong> </strong></pre>
<h5><span style="color: #993300;">Enable Enhanced Database Failover using GUI in SSMS</span></h5>
<p>We can enable this option while configuring availability group or later to the existing availability groups that was already created without enabling this option. As we know there are two ways to create an availability group using GUI in SSMS. One is by using <em>New Availability Group</em> dialog box and another way is by using <em>Availability Group</em> wizard window. Enabling this option is quite same in both ways. To enable enhanced database failover, select its checkbox next to <em>Database Level Health Detection</em> as shown in below image.</p>
<p>You can get this window by following given steps. In SQL Server Management Studio, connect to your SQL Server database engine. Right click on the AlwaysOn High Availability node, and run the <strong>New Availability Group Wizard</strong>. Check the <strong>Database Level Health Detection</strong> checkbox on the Specify Name page. Then complete the rest of the pages in the wizard.</p>
<p><img loading="lazy" decoding="async" class=" wp-image-2405 aligncenter" src="https://techyaz.com/wp-content/uploads/2018/06/1-Enhanced-DB-Failover.jpg" alt="Enable Enhanced Database Failover" width="534" height="500" srcset="https://techyaz.com/wp-content/uploads/2018/06/1-Enhanced-DB-Failover.jpg 515w, https://techyaz.com/wp-content/uploads/2018/06/1-Enhanced-DB-Failover-300x281.jpg 300w" sizes="auto, (max-width: 534px) 100vw, 534px" /></p>
<p>Another way to enable this option for existing availability groups are given below. Launch <strong>Properties</strong> window of existing Availability Group in SQL Server Management Studio. Here, you can see this option as shown in below image. Check the option <strong>Database Level Health Detection</strong>, then click OK to apply the changes.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-2406 aligncenter" src="https://techyaz.com/wp-content/uploads/2018/06/2-enhanced-DB-Failover.jpg" alt="Enable Enhanced Database Failover" width="521" height="469" srcset="https://techyaz.com/wp-content/uploads/2018/06/2-enhanced-DB-Failover.jpg 521w, https://techyaz.com/wp-content/uploads/2018/06/2-enhanced-DB-Failover-300x270.jpg 300w" sizes="auto, (max-width: 521px) 100vw, 521px" /></p>
<h5><span style="color: #993300;">Enable Enhanced Database Failover using T-SQL</span></h5>
<p>We can enable enhanced database failover using T-SQL during availability group creation or after creation by running ALTER AVAILABILITY GROUP statement. To configure it during the creation of an availability group, we must set <em>DB_FAILOVER </em>to ON as showing in below command. I have highlighted this in green colour.</p>
<pre><strong><span style="color: #0000ff;">CREATE AVAILABILITY GROUP [AG_Techyaz]</span></strong>
<strong><span style="color: #0000ff;">WITH <span style="color: #008000;">(DB_FAILOVER = ON)</span></span></strong>
<strong><span style="color: #0000ff;">FOR DATABASE [Techyaz]</span></strong>
<strong><span style="color: #0000ff;">REPLICA ON</span></strong>
<strong><span style="color: #0000ff;">       'SQLInstance1' WITH (ENDPOINT_URL = 'ENDPOINT ADDRESS:PORT-Number', FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT),</span></strong>
<strong><span style="color: #0000ff;">   'SQLInstance2' WITH (ENDPOINT_URL = 'ENDPOINT ADDRESS:PORT-Number', FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT)</span></strong></pre>
<p>If you have already created availability group without enabling this option then we have also an option to add this behavior to existing availability groups by using ALTER AVAILABILITY GROUP command as given below.</p>
<pre><strong><span style="color: #0000ff;">ALTER AVAILABILITY GROUP [AG_Techyaz] SET (DB_FAILOVER = ON)</span></strong></pre>
<h5><span style="color: #993300;">Disable Enhanced Database Failover using T-SQL</span></h5>
<p>We can disable this option simply by running below command. We must set DB_FAILOVER value to OFF to disable this feature.</p>
<pre><strong><span style="color: #0000ff;">ALTER AVAILABILITY GROUP [Techyaz] SET (DB_FAILOVER = OFF)</span></strong></pre>
<p>You will see error message 41653 logged in SQL Server error log if an availability group has failed over due to the database level health detection checks.</p>
<h3><span style="color: #333399;">Cautions</span></h3>
<p>It is very important to understand how enhanced database failover or database level health detection works. This option does not monitor disk uptime or database file availability to trigger failover.</p>
<p>Suppose your database is idle with no active transactions, and with no physical writes occurring and some of the database files become inaccessible in between then this option will not trigger automatic failover. Later, when a database checkpoint occurs, or a physical read or write occurs for fulfilling a query, then SQL Server may then notice the file issue, and react by changing the database status, and subsequently the availability group with database level health detection set on would failover due to the database health change.</p>
<p>As another example, when the SQL Server database engine needs to read a data page to fulfill a query, if the data page is cached in the buffer pool memory, then no disk read with physical access may be required to fulfill the query request. Therefore, a missing or unavailable data file may not immediately trigger an automatic failover even when database health option is enabled.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">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="https://techyaz.com/sql-server/alwayson/upgrade-or-patch-sql-server-failover-cluster-instance-with-availability-group/" target="_blank" rel="noopener">How to Patch SQL Server Failover Cluster Instance Running with Always on Availability Group?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server Alwayson Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/sql-server-administration/understanding-sql-server-backup-databases-availability-group/" target="_blank" rel="noopener">Understanding Backup Preferences in Alwayson 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/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fixing Application connectivity Issue after AOAG automatic failover</a></strong></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/">What is Enhanced Database Failover and How to Enable it for Availability Group?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
