<?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>Check Constraint &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/check-constraint/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 21 Nov 2017 05:41:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-4)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 15 Jun 2016 17:41:50 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Check Constraint]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[datetime functions]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[mathematical function]]></category>
		<category><![CDATA[null functions]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[sparse column]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3042</guid>

					<description><![CDATA[Do you know any type of mathematical function? CEILING():Returns the value representing the smallest integer that is greater-than or equal to the input_number. FLOOR ():Returns the value that represents the largest integer that is less-than or equal to the input_number. ROUND():Rounds a value to the number of decimal places specified in the second parameter. ABS():Returns [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-4%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-mathematical-aggregate-scalar-datetime-function-sparse-column-constraint-day-4/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-4)"></a></p><p><strong>Do you know any type of mathematical function?</strong></p>
<ul>
<li><strong>CEILING():</strong>Returns the value representing the smallest integer that is greater-than or equal to the input_number.</li>
<li><strong>FLOOR ():</strong>Returns the value that represents the largest integer that is less-than or equal to the input_number.</li>
<li><strong>ROUND():</strong>Rounds a value to the number of decimal places specified in the second parameter.</li>
<li><strong>ABS():</strong>Returns the absolute value of any number passed to it.</li>
<li><strong>POWER(X,Y) :</strong>Returns a number(x) raised to the power of a number (y).</li>
<li><strong>SQUARE():</strong>Returns the square of the given number</li>
</ul>
<p><strong>What are the most important aggregate functions, which we are using in day to day life?</strong></p>
<ul>
<li><strong>AVG() :</strong> Returns average of given column; The column must contain numeric values.</li>
<li><strong>MAX() :</strong> Returns Max-value from given column; The column can contain numeric, string, and date/time values. Ignore the NULL values.</li>
<li><strong>MIN() :</strong>  Returns Mininimum value from the given column; The column can contain numeric, string, and date/time values. Ignore the NULL values.</li>
<li><strong>SUM() :</strong>  Returns Sum of values avialable in a given column. The column must contain numeric values.</li>
<li><strong>COUNT() :</strong> Returns No. of rows or values in the given column; The only aggregate function not being applied to column is COUNT(*).</li>
</ul>
<p><strong>What is the difference between COUNT(1) and COUNT(*)?</strong></p>
<blockquote><p>It is a very common perception that the Count(1) performs better compared to Count(*), however it is not the case. If you test by looking at the execution plan, you will see the same action being performed by both the commands and same number of rows being scanned. The time taken may be slightly different in terms of CPU usage for count(*) , but is almost same as count(1).</p></blockquote>
<p><strong>We are calling some function using @@, what is this?</strong></p>
<ul>
<li>These are special types of functions that does not take any parameters and returns a single value</li>
<li>These are invocable as @@function name;</li>
<li>These are also called Global Variables.</li>
</ul>
<p><strong>What are the most important Global variables or Scalar function, which we are using in day to day life?</strong></p>
<blockquote><p><strong>@@VERSION:</strong></p>
<p>Returns version, processor architecture, build date, and operating system for the current installation of SQL Server.</p>
<p>Example: SELECT @@Version</p>
<p><strong>@@LANGUAGUE:</strong></p>
<p>Returns the name of the language currently being used.</p>
<p>Example: Select @@Language</p>
<p><strong>@@servername:</strong></p>
<p>Returns the name of the local server that is running SQL Server.</p>
<p>Example: Select @@Servername</p>
<p><strong>@@Max_connection:</strong></p>
<p>Returns the maximum number of simultaneous user connections allowed on an instance of SQL Server.</p>
<p>Example: Select @@Max_Connection</p></blockquote>
<p><strong>Which are the different functions available to work with NULL values?</strong></p>
<blockquote><p><strong>ISNULL():</strong> determines whether or not it is null.</p>
<p>Syntax: ISNULL(check_expression, replacement_value)</p></blockquote>
<blockquote><p><strong>NULLIF():</strong> Returns NULL if both values are equal, otherwise returns the first expression.</p>
<p>Syntax: NULLIF(exp1,exp2);</p>
<p><strong>COALESCE():</strong> Getting first not null value from list.; returns the first Non-NULL value in a list of expressions. It is equivalent to CASE expression but works with NULL values.</p>
<p>Syntax: COALESCE(expression1, expression2, &#8230; expressionN)</p></blockquote>
<p><strong>What are the different function to SELECT current date and time?</strong></p>
<ul>
<li>CURRENT_TIMESTAMP: Returns current date and time.</li>
<li>GETDATE(): Returns the current system date and time.</li>
<li>GETUTCDATE(): Returns GMT(Greenwich Mean Time) or Universal Time Coordinate(UTC) time.</li>
</ul>
<p><strong>How you can find the difference of date in the day format?</strong></p>
<ul>
<li>DATEDIFF(): It subtracts the first date from the second date.</li>
<li>Syntax: DATEDIFF(Datepart , Startdate , Enddate)</li>
<li>Using Day interval: SELECT (day,&#8217;2016-04-16&#8242;,&#8217;2016-05-10&#8242;)</li>
<li>Using Month interval: SELECT (month,&#8217;2015-01-26&#8242;, &#8216;2016-05-16&#8217;)</li>
<li>Using Year interval: SELECT (year,&#8217;2012-01-02&#8242;,&#8217;2016-05-16&#8242;)</li>
</ul>
<p><strong>What is the use DATEADD()?</strong></p>
<blockquote><p>It adds or subtracts a number of days, months, or years from a specific date.</p>
<p>SYNTAX: DATEADD(date_part, number, date)</p>
<p>Example: Select DATEADD(day,8, GETDATE())</p></blockquote>
<p><strong>When should I use SPARSE COLUMN?</strong></p>
<ul>
<li>Storing a null in a sparse column takes up no space at all.</li>
<li>To any external application the column will behave the same</li>
<li>Sparse columns work really well with filtered indexes as you will only want to create an index to deal with the non-empty attributes in the column.</li>
<li>You can create a column set over the sparse columns that returns an xml clip of all of the non-null data from columns covered by the set. The column set behaves like a column itself. Note: you can only have one column set per table.</li>
<li>Change Data Capture and Transactional replication both work, but not the column sets feature.</li>
</ul>
<p><strong>What are the disadvantages of SPARSE COLUMN?</strong></p>
<ul>
<li>SPARSE column does not have IDENTITY or ROWGUIDCOL property.</li>
<li>SPARSE column can not be applied on text, ntext, image, timestamp, geometry, geography or user defined datatypes.</li>
<li>SPARSE column can not have default value or rule or computed column.</li>
<li>Clustered index or a unique primary key index can not be applied SPARSE column. SPARSE column can not be part of clustered index key.</li>
<li>Table containing SPARSE column can have maximum size of 8018 bytes instead of regular 8060 bytes. A table operation which involves SPARSE column takes performance hit over regular column.</li>
</ul>
<p><strong>What is the Constraint in SQL Server?</strong></p>
<blockquote><p>Constraint let you define the way the Database Engine automatically enforces the integrity of a database. Constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing integrity.</p></blockquote>
<p><strong>What do you know about the CHECK constraint?</strong></p>
<blockquote><p>CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns. You can create a CHECK constraint with any logical (Boolean) expression that returns TRUE or FALSE based on the logical operators.</p>
<p>For example, the range of values for a salary column can be limited by creating a CHECK constraint that allows for only data that ranges from $15,000 through $100,000. This prevents salaries from being entered beyond the regular salary range.</p></blockquote>
<p><strong>What is the difference between column level and table level constraint?</strong></p>
<blockquote><p>Constraints can be column constraints or table constraints. A column constraint is specified as part of a column definition and applies only to that column. The constraints in the previous examples are column constraints. A table constraint is declared independently from a column definition and can apply to more than one column in a table. Table constraints must be used when more than one column must be included in a constraint.</p>
<p>For example, if a table has two or more columns as a composite primary key, you must use a table constraint to include both columns in the primary key.</p></blockquote>
<p><strong>How to find open transactions information in SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="eYDgxKuXTB"><p><a href="https://www.dbrnd.com/2015/08/open-transactions-in-sql-server/">Open transactions in SQL Server</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/08/open-transactions-in-sql-server/embed/#?secret=eYDgxKuXTB" data-secret="eYDgxKuXTB" width="600" height="338" title="&#8220;Open transactions in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What do you please write a script to list all Dates between two dates?</strong></p>
<blockquote class="wp-embedded-content" data-secret="ilrpMb1ZKT"><p><a href="https://www.dbrnd.com/2015/08/list-all-dates-between-two-dates-in-sql-server/">List all Dates between two dates in SQL Server</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/08/list-all-dates-between-two-dates-in-sql-server/embed/#?secret=ilrpMb1ZKT" data-secret="ilrpMb1ZKT" width="600" height="338" title="&#8220;List all Dates between two dates in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What do you please write sample script to delete all duplicates rows except one?</strong></p>
<blockquote class="wp-embedded-content" data-secret="eGf86o4Cpn"><p><a href="https://www.dbrnd.com/2015/09/delete-all-duplicates-rows-in-sql-server/">Delete all duplicates rows except one in SQL Server</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/09/delete-all-duplicates-rows-in-sql-server/embed/#?secret=eGf86o4Cpn" data-secret="eGf86o4Cpn" width="600" height="338" title="&#8220;Delete all duplicates rows except one in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Lock, Deadlock, Block and Isolation Interview Questions and   Answers (Day-1)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1/</link>
					<comments>https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 04 Jun 2016 17:52:40 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[acid]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[Check Constraint]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DeadLock]]></category>
		<category><![CDATA[default trace]]></category>
		<category><![CDATA[Dirty read]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[locking]]></category>
		<category><![CDATA[phantom read]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2916</guid>

					<description><![CDATA[What is the ACID Properties in the Database System? ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability) What is a Phantom read? A phantom read occurs when, in the course of a transaction, two identical queries are executed, and the collection of rows returned by the second query is different from the first. This [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1%2F&#038;title=SQL%20Server%3A%20Database%20Lock%2C%20Deadlock%2C%20Block%20and%20Isolation%20Interview%20Questions%20and%20%20%20Answers%20%28Day-1%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1/" data-a2a-title="SQL Server: Database Lock, Deadlock, Block and Isolation Interview Questions and   Answers (Day-1)"></a></p><p><strong>What is the ACID Properties in the Database System?</strong></p>
<blockquote data-secret="GZz3hgbH8E" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2015/05/acid-properties-in-database-system/">ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability)</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/acid-properties-in-database-system/embed/#?secret=GZz3hgbH8E" data-secret="GZz3hgbH8E" width="600" height="338" title="&#8220;ACID Properties in Database System (Atomicity, Consistency, Isolation, Durability)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is a Phantom read?</strong></p>
<blockquote><p>A phantom read occurs when, in the course of a transaction, two identical queries are executed, and the collection of rows returned by the second query is different from the first.</p>
<p>This can occur when range locks are not acquired on performing a SELECT &#8230; WHERE operation.</p></blockquote>
<p><strong>What is a Dirty read?</strong></p>
<blockquote><p>Dirty read—Dirty reads occur when one transaction reads data that has been written but not yet committed by another transaction. If the changes are later rolled back, the data obtained by the first transaction will be invalid.</p></blockquote>
<p><strong>What is Nonrepeatable read?</strong></p>
<blockquote><p>Nonrepeatable reads happen when a transaction performs the same query two or more times and each time the data is different. This is usually due to another concurrent transaction updating the data between the queries.</p></blockquote>
<p><strong>What is a lost update problem?</strong></p>
<blockquote><p>Lost updates occur when two or more transactions select the same row and then update the row based on the value originally selected. Each transaction is unaware of other transactions. The last update overwrites updates made by the other transactions, which results in lost data.</p></blockquote>
<p><strong>What is Timeout?</strong></p>
<blockquote data-secret="mv0SEDiAHt" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/04/database-theory-what-is-timeout-lock-block-and-deadlock-in-a-database-system/">Database Theory: What is Timeout, Lock, Block, and Deadlock in a Database System?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/database-theory-what-is-timeout-lock-block-and-deadlock-in-a-database-system/embed/#?secret=mv0SEDiAHt" data-secret="mv0SEDiAHt" width="600" height="338" title="&#8220;Database Theory: What is Timeout, Lock, Block, and Deadlock in a Database System?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is a Lock?</strong></p>
<blockquote><p>When one process is accessing an object, it can request for a lock for that particular object so that other processes cannot perform read or update on that object.</p>
<p>There are different types of lock like: Exclusive Lock, Non-exclusive Lock.</p></blockquote>
<p><strong>What is Blocking?</strong></p>
<blockquote><p>If two processes are accessing same resource so at that time one process has to wait until the other process release the occupied resource.</p>
<p>This is called blocking because one transaction is blocked by another transaction and all blocked processes kept in the waiting queue.</p>
<p>If the blocked transaction is waiting for a long time, it may generate a Database Timeout. If the long running blocked transaction requires a lock, it may generate a Database Deadlock.</p></blockquote>
<p><strong>What is a Deadlock?</strong></p>
<blockquote><p>One X blocked process is waiting to complete the transaction of the Y process and the same time, Y process is blocked because it is also waiting to complete the transaction of the X process.</p>
<p>This is called as Deadlock situation.</p>
<p>Deadlock is a next stage of the blocking situation so if you want to avoid Deadlock situation, you should first find the blocked transaction and tried to remove internal dependency of the transactions.</p></blockquote>
<p><strong>What is a Live lock?</strong></p>
<blockquote><p>A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.</p></blockquote>
<p><strong>What is Optimistic Locking and Pessimistic Locking?</strong></p>
<blockquote data-secret="i6i2DG1tfR" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/04/database-theory-what-is-optimistic-locking-and-pessimistic-locking/">Database Theory: What is Optimistic Locking and Pessimistic Locking?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/database-theory-what-is-optimistic-locking-and-pessimistic-locking/embed/#?secret=i6i2DG1tfR" data-secret="i6i2DG1tfR" width="600" height="338" title="&#8220;Database Theory: What is Optimistic Locking and Pessimistic Locking?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What are the different ways to detect a deadlock in the SQL Server?</strong></p>
<blockquote data-secret="vINK5fCe3u" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/04/sql-server-8-different-ways-to-detect-a-deadlock-in-a-database/">SQL Server: 8 different ways to Detect a DeadLock in a Database</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-server-8-different-ways-to-detect-a-deadlock-in-a-database/embed/#?secret=vINK5fCe3u" data-secret="vINK5fCe3u" width="600" height="338" title="&#8220;SQL Server: 8 different ways to Detect a DeadLock in a Database&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What happens after the Deadlock arise in the SQL Server?</strong></p>
<blockquote data-secret="Hkr0ZTvzXa" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/04/sql-server-what-happens-after-the-deadlock-arise/">SQL Server: What happens after the Deadlock arise?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/sql-server-what-happens-after-the-deadlock-arise/embed/#?secret=Hkr0ZTvzXa" data-secret="Hkr0ZTvzXa" width="600" height="338" title="&#8220;SQL Server: What happens after the Deadlock arise?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is your ultimate strategies to avoid a Deadlock?</strong></p>
<blockquote data-secret="xedNE0qwWw" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/04/database-design-the-ultimate-strategies-to-avoid-deadlock/">Database Design: The Ultimate Strategies to avoid Deadlock</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/04/database-design-the-ultimate-strategies-to-avoid-deadlock/embed/#?secret=xedNE0qwWw" data-secret="xedNE0qwWw" width="600" height="338" title="&#8220;Database Design: The Ultimate Strategies to avoid Deadlock&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the Database level Locking?</strong></p>
<blockquote><p>With database level locks, the entire database is locked – which means that only one database session can apply any updates to the database. This type of lock is not often used, because it obviously prevents all users except one from updating anything in the database.</p></blockquote>
<p><strong>What is the File level Locking?</strong></p>
<blockquote><p>With a file lock level, an entire database file is locked. What exactly is a file in a database? Well, a file can have a wide variety of data – inside a file there could be an entire table, a part of a table, or even parts of different tables. Because of the variety of data stored inside a file, this type of lock level is less favored.</p></blockquote>
<p><strong>What is the Column level Locking?</strong></p>
<blockquote><p>A column level lock just means that some columns within a given row in a given table are locked. This form of locking is not commonly used because it requires a lot of resources to enable and release locks at this level. Also, there is very little support for column level locking in most database vendors.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/06/sql-server-database-lock-deadlock-block-and-isolation-interview-questions-and-answers-day-1/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Script to Validate IP Address range in SQL Server</title>
		<link>https://www.dbrnd.com/2015/06/validate-ip-address-range-in-sql-server/</link>
					<comments>https://www.dbrnd.com/2015/06/validate-ip-address-range-in-sql-server/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 01 Jun 2015 17:24:14 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Check Constraint]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[ParseName]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[validation]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=226</guid>

					<description><![CDATA[In this post, I am sharing a demonstration on how to validate the range of IP Address in SQL Server. You can set CHECK CONSTRAINT for each part of IP Address for validating a proper range. For example, You require inserting IP Address between 10.20 range. This you can achieve using PARSENAME function of SQL [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&amp;linkname=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&amp;linkname=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&amp;linkname=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&amp;linkname=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&amp;linkname=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&amp;linkname=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F06%2Fvalidate-ip-address-range-in-sql-server%2F&#038;title=Script%20to%20Validate%20IP%20Address%20range%20in%20SQL%20Server" data-a2a-url="https://www.dbrnd.com/2015/06/validate-ip-address-range-in-sql-server/" data-a2a-title="Script to Validate IP Address range in SQL Server"></a></p><p>In this post, I am sharing a demonstration on how to validate the range of IP Address in SQL Server. </p>
<p>You can set CHECK CONSTRAINT for each part of IP Address for validating a proper range.</p>
<p>For example,<br />
You require inserting IP Address between 10.20 range. This you can achieve using PARSENAME function of SQL Server.</p>
<p><strong>Below is a full demo on this:</strong></p>
<p><b>Let&#8217;s first create one table and define CHECK Constraint using PARSENAME.  </b></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_IPAddress
(
 IPAddress VARCHAR(15)
)
GO

ALTER TABLE tbl_IPAddress ADD CONSTRAINT chk_tbl_IPAddress_IPAddress
CHECK 
(
 (ParseName(IPAddress, 4) = 12) 
 AND (ParseName(IPAddress, 3) = 4) 
 AND (ParseName(IPAddress, 2) BETWEEN 8 AND 26) 
 AND (ParseName(IPAddress, 1) BETWEEN 1 AND 255) 
)
GO</pre>
<p>You can see different four part validation ,</p>
<p>First two part validation is: only IP Address range start with 12.4</p>
<p>Last two part validation is: 8 to 26  and 1 to 255.</p>
<p><b>Means valid IP Address are :</b></p>
<p>12.4.8.125</p>
<p>12.4.15.241</p>
<p><b>Invalid IP Address are:</b></p>
<p>10.2.21.52</p>
<p>12.4.7.124</p>
<p>Now insert script for some valid IP Address:</p><pre class="crayon-plain-tag">INSERT INTO tbl_IPAddress  (IPAddress) 
VALUES 
        ('12.4.8.34')
        ,('12.4.16.125')
        ,('12.4.22.120')
        ,('12.4.22.120')
        ,('12.4.15.216')
GO</pre><p>
<blockquote><p><b><span style="color: #ff0000;">If you tried to insert out of range, then this will show you an error that you cannot violate check constraint.</span></b></p></blockquote>
<p><strong>Script to Select different part of stored IP Address:</strong></p>
<pre class="crayon-plain-tag">SELECT IPAddress
     ,ParseName(IPAddress, 4) As FirstPart
     ,ParseName(IPAddress, 3) As SecondPart
     ,ParseName(IPAddress, 2) As ThirdPart
     ,ParseName(IPAddress, 1) As FourthPart
FROM   tbl_IPAddress</pre>
<blockquote><p><b>My Suggestion:</b></p>
<p>In this demo, I stored IP Address into one VARCHAR(15) column which is not effective storage.<br />
Whenever you don&#8217;t require any analysis on IP Address, then you can store the IP Address into one column. Otherwise, <b><a href="https://www.dbrnd.com/2015/05/store-ip-address-into-database-system/">please visit this page on the effective storage of IP Addresses. </a></b></p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/06/validate-ip-address-range-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
