<?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>T-SQL &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/t-sql/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>Sun, 25 Sep 2016 20:01:26 +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: Script to find a Table which has more than 10 Indexes</title>
		<link>https://www.dbrnd.com/2016/10/sql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 29 Oct 2016 16:16:17 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[indexes]]></category>
		<category><![CDATA[SQL Developer]]></category>
		<category><![CDATA[SQL Query]]></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[SYS.INDEXES]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3422</guid>

					<description><![CDATA[In this post, I am sharing one T-SQL script to find a Table which has more than 10 Indexes in SQL Server. More Indexes on a Table, are creating a performance issue because Indexes also require dedicated CPU I/O for writing it into the Index Pages. More Indexes will slow down the insertion or any [&#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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" 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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" 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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" 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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" 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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" 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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&amp;linkname=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" 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%2F10%2Fsql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance%2F&#038;title=SQL%20Server%3A%20Script%20to%20find%20a%20Table%20which%20has%20more%20than%2010%20Indexes" data-a2a-url="https://www.dbrnd.com/2016/10/sql-server-script-to-find-a-table-which-has-more-than-10-indexes-improve-performance/" data-a2a-title="SQL Server: Script to find a Table which has more than 10 Indexes"></a></p><p>In this post, I am sharing one T-SQL script to find a Table which has more than 10 Indexes in SQL Server. </p>
<blockquote><p>More Indexes on a Table, are creating a performance issue because Indexes also require dedicated CPU I/O for writing it into the Index Pages.<br />
More Indexes will slow down the insertion or any other DML operation of that particular Table. </p></blockquote>
<p><strong>Below is a script to find out tables which are having more indexes:</strong><br />
You can change the value of @threshold.</p>
<pre class="crayon-plain-tag">DECLARE @threshold INT;
SET @threshold = 10;

SELECT
	[s].[name] + '.' + [t].[name] AS TableName
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
	ON [t].[schema_id] = [s].[schema_id]
WHERE EXISTS
(
	SELECT 1 FROM sys.indexes AS i
    WHERE [i].[object_id] = [t].[object_id]
    GROUP BY [i].[object_id]
    HAVING COUNT(*) &gt; @threshold
)
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-16)</title>
		<link>https://www.dbrnd.com/2016/06/ql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 27 Jun 2016 20:33:41 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[DBCC SHOWCONTIG]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[replace]]></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[stuff]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Tempdb storage]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[XML Operations]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3088</guid>

					<description><![CDATA[What are the useful DMVs for TempDB? dm_db_file_space_usage: Stores metadata about disk space usage statistics by “user object”, “internal objects” and “version store” dm_db_session_space_usage: Stores metadata about disk space usage, page allocation and deallocation statistics at user session level. dm_db_task_space_usage: Stores metadata about disk space usage, page allocation and deallocation statistics at session task level. [&#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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%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%2Fql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-16%29" data-a2a-url="https://www.dbrnd.com/2016/06/ql-server-database-developer-t-sql-interview-questions-and-answers-tempdb-storage-dbcc-showcontig-stuff-replace-day-16/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-16)"></a></p><p><strong>What are the useful DMVs for TempDB?</strong></p>
<ul>
<li>dm_db_file_space_usage: Stores metadata about disk space usage statistics by “user object”, “internal objects” and “version store”</li>
<li>dm_db_session_space_usage: Stores metadata about disk space usage, page allocation and deallocation statistics at user session level.</li>
<li>dm_db_task_space_usage: Stores metadata about disk space usage, page allocation and deallocation statistics at session task level.</li>
<li>dm_tran_active_snapshot_database_transactions: its returns a virtual table for all active transaction running in tempdb</li>
</ul>
<p><strong>What kind of different objects SQL Server stores in the TempDB?</strong></p>
<p><strong>User Objects:</strong></p>
<ul>
<li>Table variables</li>
<li>Table valued functions</li>
<li>Local and Global temporary variables</li>
<li>Local and Global Temporary Indexes</li>
<li>Temp Stored procedure</li>
<li>User defined table</li>
<li>User defined Index</li>
<li>Global table</li>
<li>System Index</li>
</ul>
<p><strong>Internal Objects:</strong></p>
<ul>
<li>Cursor’s worktable</li>
<li>Temporary Large object (LOB) storage</li>
<li>DISTINCT, ORDER BY, GROUP BY and UNION</li>
<li>Rebuilding Index with SORT_IN_TEMPDB options</li>
<li>HASH JOIN</li>
<li>Multiple active result set (MARS)</li>
</ul>
<p><strong>Database Engine spool:</strong></p>
<ul>
<li>Lazy Spool</li>
<li>Eager Spool</li>
<li>Index Spool</li>
<li>Table Spool</li>
<li>Row Count Spool</li>
<li>Window Spool</li>
</ul>
<p><strong>Version Store:</strong></p>
<ul>
<li>DML operation that use row versioning</li>
<li>Index rebuild that use row versioning</li>
</ul>
<p><strong>How to find minimum, maximum and average row size in each table in SQL server?</strong></p>
<blockquote><p>Using DBCC SHOWCONTIG, we can find minimum, maximum and average row size of table.</p>
<p><strong>Query to get result for all the table:</strong></p><pre class="crayon-plain-tag">DBCC SHOWCONTIG WITH TABLERESULTS</pre><p>
<strong>Query to get result for a specific table:</strong></p><pre class="crayon-plain-tag">DBCC SHOWCONTIG([dbo].[TableName]) with TABLERESULTS</pre><p>
</p></blockquote>
<p><strong>What are the new features introduced in SQL Server 2014?</strong></p>
<ul>
<li>Buffer pool extensions to SSD</li>
<li>In-memory OLTP</li>
<li>IN-memory DW</li>
<li>Delayed Durability</li>
<li>SQL Server datafile in window Azure</li>
<li>Clustered Columnstore Index</li>
<li>Better Statistics per partition</li>
<li>Parallel SELECT INTO</li>
<li>Rebuild Blob index ONLINE</li>
<li>Backup Encryption</li>
</ul>
<p><strong>What are the new features introduced in SQL Server 2012?</strong></p>
<p><strong>New Features related to database administration: </strong></p>
<ul>
<li>Always on features which is actually High availability and Disaster recovery solution</li>
<li>Always on SQL Failover Clustering (FCI) across multi domain</li>
<li>Always on Availability group</li>
<li>Contained database</li>
<li>Column store Index</li>
<li>User defined server role</li>
<li>Distributed replay</li>
<li>Statistical Semantic Search</li>
<li>Added few DMVs like sys.dm_os_volumn_stats, sys.dm_os_windows_info, sys.dm_server_memory_dumps, sys.dm_server_services and sys.dm_server_registry</li>
<li>15000 Partitioned table can be created now from previously 1000 limit.</li>
</ul>
<p><strong>New features related T-SQL:</strong></p>
<ul>
<li>Sequence Object</li>
<li>File table</li>
<li>Logical Function CHOOSE and IIF</li>
<li>Conversion function PARSE, TRY_CONVERT and TRY_PARSE</li>
<li>Date and Time function DATEFORMATS, DATETIME2FORMATS, DATETIMEFORMATS, DATETIMEOFFSETFORMATS, EOMONTHS, SMALLDATETIMEFORMATS and TIMEFROMPARTS</li>
<li>String functions CONCAT and FORMAT</li>
<li>Analytic Function CUME_DIST, FIRST_VALUE, LAST_VALUE, LAG, LEAD, PERCENTILE_CONT, PERCENTILE_DISC and PERCENT_RANK</li>
<li>OFFSET and FETCH key work introduced for SELECT statement</li>
<li>ONLINE rebuild option is available now for LOB column type too</li>
</ul>
<p><strong>How to get Only Hour, Minute and Second from the datetime column?</strong></p><pre class="crayon-plain-tag">select substring(convert(char(20),getdate(),109), 14, 7) as HourMinute</pre><p>
<strong>What is SET ANSI WARNING on?</strong></p>
<blockquote><p>When on it displays the warning if there Is any null value for operations such as group by, order by max etc. and also if there is an arithmetic over flow. When off its displays no warning and also truncates the data to fit in the size of the column.</p></blockquote>
<p><strong>What’s wrong in the following query?</strong></p>
<p><strong>SELECT subject_code, AVG (marks) FROM students WHERE AVG(marks) &gt; 88 GROUP BY subject_code;</strong></p>
<blockquote><p>The WHERE clause cannot be used to restrict groups. The HAVING clause should be used.</p></blockquote>
<p><strong>What’s wrong in the following query?</strong></p>
<p><strong>SELECT subject_code, count(name) FROM students;</strong></p>
<blockquote><p>It doesn’t have a GROUP BY clause. The subject_code should be in the GROUP BY clause.</p></blockquote>
<p><strong>What is the difference between SUBSTR and INSTR in the SQL Server?</strong></p>
<blockquote><p>The SUBSTR function is used to return specific portion of string in a given string. But, INSTR function gives character position in a given specified string.</p></blockquote>
<p><strong>What is the use of FOR Clause?</strong></p>
<blockquote><p>FOR clause is mainly used for XML and browser options. This clause is mainly used to display the query results in XML format or in browser.</p></blockquote>
<p><strong>What is the difference between COMMIT and ROLLBACK?</strong></p>
<blockquote><p>Every statement between BEGIN and COMMIT becomes persistent to database when the COMMIT is executed. Every statement between BEGIN and ROOLBACK are reverted to the state when the ROLLBACK was executed.</p></blockquote>
<p><strong>What is the difference between GETDATE and SYSDATETIME?</strong></p>
<blockquote><p>Both are same but GETDATE can give time till milliseconds and SYSDATETIME can give precision till nanoseconds. SYSDATE TIME is more accurate than GETDATE.</p></blockquote>
<p><strong>What is SQL injection?</strong></p>
<blockquote><p>SQL injection is an attack by malicious users in which malicious code can be inserted into strings that can be passed to an instance of SQL server for parsing and execution. All statements have to checked for vulnerabilities as it executes all syntactically valid queries that it receives.</p>
<p>Even parameters can be manipulated by the skilled and experienced attackers.</p></blockquote>
<p><strong>How to select unique records from a table?</strong></p>
<blockquote><p>Select unique records from a table by using DISTINCT keyword.</p>
<p>Select DISTINCT ColumnName from TableName;</p></blockquote>
<p><strong>How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?</strong></p>
<ul>
<li>One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.</li>
<li>One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.</li>
<li>Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.</li>
<li>It will be a good idea to read up a database designing fundamentals text book.</li>
</ul>
<p><strong>What is the STUFF Function and How Does it Differ from the REPLACE Function?</strong></p>
<blockquote><p>STUFF function is used to overwrite existing characters using this syntax: STUFF (string_expression, start, length, replacement_characters), where string_expression is the string that will have characters substituted, start is the starting position, length is the number of characters in the string that are substituted, and replacement_characters are the new characters interjected into the string.</p>
<p>REPLACE function is used to replace existing characters of all occurrences. Using the syntax REPLACE (string_expression, search_string, replacement_string), every incidence of search_string found in the string_expression will be replaced with replacement_string.</p></blockquote>
<p><strong>How to Enable/Disable Indexes?</strong></p><pre class="crayon-plain-tag">--Disable Index
ALTER INDEX [IndexName] ON TableName DISABLE
GO

--Enable Index
ALTER INDEX [IndexName] ON TableName REBUILD
GO</pre><p>
<strong>How do you solve performance problems with XML operations?</strong></p>
<blockquote><p>There are no ‘correct’ answers to generic performance questions. A proper solution can be suggested only after examining the specific use case and environment.  However, a few recommendations are as follows:</p>
<p>If you are dealing with UNTYPED XML, try to convert them to TYPED XML. When using TYPED XML values, SQL Server has got better understanding of the structure of the XML document, data types of elements and attributes etc.  This allows SQL Server to process the XML document more efficiently.</p>
<p>XML Indexes can be used to speed up queries that read information from XML data type columns.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-15)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 26 Jun 2016 19:58:39 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[contains]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[freetext]]></category>
		<category><![CDATA[Full text searching]]></category>
		<category><![CDATA[interview]]></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[T-SQL]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Universally Unique Identifier]]></category>
		<category><![CDATA[UUID Data type]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3082</guid>

					<description><![CDATA[What do you know about the Universally Unique Identifier &#8211; UUID data type? Database Theory: The truth about Universally Unique Identifier &#8211; UUID When we are declaring a variable using SET or SELECT, What is the performance different between SET and SELECT? SQL Server: Truth about assigning variables using SET versus SELECT What is the [&#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-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%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-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%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-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%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-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%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-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%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-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%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-uuid-data-type-encryption-full-text-search-day-15%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-15)"></a></p><p><strong>What do you know about the Universally Unique Identifier &#8211; UUID data type?</strong></p>
<blockquote class="wp-embedded-content" data-secret="SEzTGAfIgs"><p><a href="https://www.dbrnd.com/2016/03/database-theory-the-truth-about-universally-unique-identifier-uuid/">Database Theory: The truth about Universally Unique Identifier &#8211; UUID</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/database-theory-the-truth-about-universally-unique-identifier-uuid/embed/#?secret=SEzTGAfIgs" data-secret="SEzTGAfIgs" width="600" height="338" title="&#8220;Database Theory: The truth about Universally Unique Identifier &#8211; UUID&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>When we are declaring a variable using SET or SELECT, What is the performance different between SET and SELECT?</strong></p>
<blockquote class="wp-embedded-content" data-secret="LWlmYmIfBE"><p><a href="https://www.dbrnd.com/2016/03/sql-server-truth-about-assigning-variables-using-set-versus-select/">SQL Server: Truth about assigning variables using SET versus SELECT</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/sql-server-truth-about-assigning-variables-using-set-versus-select/embed/#?secret=LWlmYmIfBE" data-secret="LWlmYmIfBE" width="600" height="338" title="&#8220;SQL Server: Truth about assigning variables using SET versus SELECT&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the purpose of OPENXML clause SQL server stored procedure?</strong></p>
<blockquote><p>OPENXML parses the XML data in SQL Server in an efficient manner. It’s primary ability is to insert XML data to the RDB. It is also possible to query the data by using OpenXML. The path of the XML element needs to be specified by using ‘xpath’.</p></blockquote>
<p><strong>What is the use of @@CPU_BUSY statement?</strong></p>
<blockquote><p>It returns the time that SQL Server has spent working since it was last started.</p></blockquote>
<p><strong>Explain the use of keyword WITH ENCRYPTION. Create a Store Procedure with Encryption.</strong></p>
<blockquote><p>WITH ENCRYPTION indicates that SQL Server will convert the original text of CREATE PROCEDURE statement to an encrypted format. Users that do not have no access to system tables or database files cannot retrieve the encrypted text. However, the text will be available to privileged users.</p></blockquote>
<p><strong>If you need to script a table with data, how will you do that?</strong></p>
<blockquote><p>One way to achieve this by using  Generate Script Task in SSMS.</p>
<p>Right click on database and then go to Tasks and then go to Generate Scripts.</p></blockquote>
<p><strong>I have two tables with the same columns and data types. If I need toget distinct records from both of tables how can I do that?</strong></p>
<blockquote><p>We can use the UNION operators.</p></blockquote>
<p><strong>Can we send emails in HTML Format from SQL Server, How will you do that?</strong></p>
<blockquote><p>We can send email from SQL Server in HTML format by using dbo.sp_send_dbmail stored procedure. To send email in HTML format, we have to build the body of email with HTML Tags. The below code can be used to send basis HTML formatted email. If you want to loop through some results of table and send in HTML formatted email.</p></blockquote>
<p><strong>Can we create triggers on temp table?</strong></p>
<blockquote><p>No: we cannot create a trigger on temp table.</p></blockquote>
<p><strong>How would you get the size of a SQL Server Table?</strong></p>
<blockquote><p>EXEC sp_spaceused &#8216;TableName&#8217;</p></blockquote>
<p><strong>How would you determine if the expression is Numeric?</strong></p>
<blockquote><p><strong>ISNUMERIC( ):</strong> function is provided to us in SQL Server to check if the expression is valid numeric type or not. As per Microsoft it should work with Integers and Decimal data types and if data is valid integer or decimal, ISNumeric() should return us 1 else 0.</p>
<p><strong>Try_Convert( ):</strong> In SQL Server 2012. Microsoft introduced new function call Try_Convert( ). You can use try_convert function to convert to required data type and if it is not able to convert then it will return Null as output.</p></blockquote>
<p><strong>Which function is used to convert the integer value into spaces?</strong></p>
<blockquote><p>The SPACE function converts the specified integer value into spaces.</p><pre class="crayon-plain-tag">SELECT SPACE(8);</pre><p>
</p></blockquote>
<p><strong>What is constant folding?</strong></p>
<p><strong>SQL Server evaluates some constant expression early to improve the query performance. This is called constant folding.</strong></p>
<p><strong>What is a full text search in SQL Server?</strong></p>
<blockquote><p>Full text indexing is a great feature that solves a database problem, the searching of textual data columns for specific words and phrases in SQL Server databases.</p>
<p>Full Text Index can be used to search words, phrases and multiple forms of a word or phrase using FREETEXT () and CANTAINS () with “and” or “or” operators.</p></blockquote>
<p><strong>Can you execute full-text queries on a table without full-text index on that column?</strong></p>
<blockquote><p><strong>No: </strong>Before you can run full-text queries on a table, the database administrator must create a full-text index on the table. The full-text index includes one or more character-based columns in the table. These columns can have any of the following data types: char, varchar, nchar, nvarchar, text, ntext, image, xml, or varbinary(max) and FILESTREAM.</p></blockquote>
<p><strong>Are Full-text queries are case-sensitive?</strong></p>
<blockquote><p>Full-text queries are not case-sensitive. For example, searching for &#8220;DBRND&#8221; or &#8220;dbrnd&#8221; returns the same results.</p></blockquote>
<p><strong>What is the difference between LIKE and FULL-Text Search?</strong></p>
<blockquote><p>In contrast to full-text search, the LIKETransact-SQL predicate works on character patterns only. Also, you cannot use the LIKE predicate to query formatted binary data. Furthermore, a LIKE query against a large amount of unstructured text data is much slower than an equivalent full-text query against the same data.</p>
<p>A LIKE query against millions of rows of text data can take minutes to return; whereas a full-text query can take only seconds or less against the same data, depending on the number of rows that are returned.</p></blockquote>
<p><strong>What is a Full-Text Engine?</strong></p>
<blockquote><p>The Full-Text Engine in SQL Server is fully integrated with the query processor. The Full-Text Engine compiles and executes full-text queries. As part of query execution, the Full-Text Engine might receive input from the thesaurus and stoplist.</p></blockquote>
<p><strong>What is the internal process of Full-Text Querying?</strong></p>
<ul>
<li>The query processor passes the full-text portions of a query to the Full-Text Engine for processing. The Full-Text Engine performs word breaking and, optionally, thesaurus expansions, stemming, and stopword (noise-word) processing.</li>
<li>Then the full-text portions of the query are represented in the form of SQL operators, primarily as streaming table-valued functions (STVFs).</li>
<li>During query execution, these STVFs access the inverted index to retrieve the correct results. The results are either returned to the client at this point, or they are further processed before being returned to the client.</li>
</ul>
<p><strong>What is CONTAINS and FREETEXT of Full-Text predicates?</strong></p>
<blockquote><p>The CONTAINS and FREETEXT predicates return a TRUE or FALSE value. They can be used only to specify selection criteria for determining whether a given row matches the full-text query. Matching rows are returned in the result set. CONTAINS and FREETEXT are specified in the WHERE or HAVING clause of a SELECT statement. They can be combined with any of the other Transact-SQL predicates, such as LIKE and BETWEEN.</p>
<p>When using CONTAINS or FREETEXT, you can specify either a single column, a list of columns, or all columns in the table to be searched.</p></blockquote>
<p><strong>What it is not recommended to name the user defined Stored Procedures with sp_?</strong></p>
<blockquote><p>They are system defined and mostly resides under the master database so if we write a user defined stored procedure by the name sp_ the query engine will first search the Stored Procedure in the master database and if not found then it will search in the current session database.</p>
<p>This brings unnecessary round trip and reduce the overall performance of user defined stored procedures.</p></blockquote>
<p><strong>Can we use the PRINT statement in SQL Server Function?</strong></p>
<blockquote><p>No: We cannot use it.</p></blockquote>
<p><strong>If you are working on a SQL database and if suddenly a developer changes the code and your queries results start giving errors, how will you check using a T-SQL query (on system tables) that what has changed in the database.</strong><br />
<pre class="crayon-plain-tag">select o.name, o.object_id, o.modify_date, c.text
from sys.objects o
join sys.syscomments c
on o.object_id = c.id</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-14)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-null-notnull-merge-hash-nested-loop-join-day-14/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 25 Jun 2016 04:56:07 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[hash join]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[merge join]]></category>
		<category><![CDATA[nested loop join]]></category>
		<category><![CDATA[NOT NULL]]></category>
		<category><![CDATA[NULL]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[select]]></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=3078</guid>

					<description><![CDATA[Should we allow NULL or We should apply NOT NULL? Database Design: Should we allow NULL or We should apply NOT NULL ? &#8220;SELECT *&#8221; is good practice or bad practice in database system? SELECT all columns to be good or bad in database system What is Left Anti Semi Join Operator? The Left Anti [&#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-null-notnull-merge-hash-nested-loop-join-day-14%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%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-null-notnull-merge-hash-nested-loop-join-day-14%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%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-null-notnull-merge-hash-nested-loop-join-day-14%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%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-null-notnull-merge-hash-nested-loop-join-day-14%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%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-null-notnull-merge-hash-nested-loop-join-day-14%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%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-null-notnull-merge-hash-nested-loop-join-day-14%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%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-null-notnull-merge-hash-nested-loop-join-day-14%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-14%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-null-notnull-merge-hash-nested-loop-join-day-14/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-14)"></a></p><p><strong>Should we allow NULL or We should apply NOT NULL?</strong></p>
<blockquote class="wp-embedded-content" data-secret="nn6TWdIgPw"><p><a href="https://www.dbrnd.com/2016/01/database-design-should-we-allow-null-or-we-should-apply-not-null/">Database Design: Should we allow NULL or We should apply NOT NULL ?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/01/database-design-should-we-allow-null-or-we-should-apply-not-null/embed/#?secret=nn6TWdIgPw" data-secret="nn6TWdIgPw" width="600" height="338" title="&#8220;Database Design: Should we allow NULL or We should apply NOT NULL ?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>&#8220;SELECT *&#8221; is good practice or bad practice in database system?</strong></p>
<blockquote class="wp-embedded-content" data-secret="MbeaBBAPFG"><p><a href="https://www.dbrnd.com/2015/09/select-all-columns-to-be-good-or-bad-in-database-system/">SELECT all columns to be good or bad in database system</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/09/select-all-columns-to-be-good-or-bad-in-database-system/embed/#?secret=MbeaBBAPFG" data-secret="MbeaBBAPFG" width="600" height="338" title="&#8220;SELECT all columns to be good or bad in database system&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is Left Anti Semi Join Operator?</strong></p>
<p>The Left Anti Semi Join operator returns the result set for each row from the first (top) input when there is no matching row in the second (bottom) input. If no join predicate exists in the Argument column, each row is a matching row. Left Anti Semi Join is a logical operator.</p>
<p><strong>Why you should not use a cursor? What are its alternatives?</strong></p>
<blockquote><p>Microsoft requests us to avoid using cursors due to Memory and RAM overhead including comparatively more DISK IO. Alternatives: WHILE LOOP / CASE / Temprary Tables / Derived Tables / Sub Queries can be used in place of Cursors.</p></blockquote>
<p><strong>What are Dynamic Queries in T-SQL?</strong></p>
<blockquote><p>Dynamic T-SQL Queries are those queries designed on the fly / at run time using Variables or using CTE or other sources. We use SP_EXECUTESQL Stored Procedure or EXECUTE function to execute such queries.</p></blockquote>
<p><strong>How you can load large data in SQL Server?</strong></p>
<blockquote><p>IMPORT and EXPORT Wizard, BULK INSERT and BCP are the possible options. We need to set the RECOVERY MODEL to BULKLOGGED before we perform such activities.</p></blockquote>
<p><strong>What is Mutex error in Triggers?</strong></p>
<blockquote><p>The only use of &#8220;mutex&#8221; that I know of is for a mechanism for re-entrant code that can&#8217;t be simultaneously executed by multiple processes to force that code to be single threaded.  It&#8217;s not a typical SQL Server term.  If it were, it would apply as much to stored procedures as triggers.  Generally, in a well designed database with well written code, this would be handled by using standard data locking and transactions.</p></blockquote>
<p><strong>What is the use sp_refreshview?</strong></p>
<blockquote><p>It updates the metadata for the specified non-schema-bound view. Persistent metadata for a view can become outdated because of changes to the underlying objects upon which the view depends.</p>
<p>Syntax:</p>
<p>EXECUTE sp_refreshview &#8216;view_name&#8217;;</p></blockquote>
<p><strong>Can you create a Primary key without clustered index?</strong></p>
<blockquote><p>Yes, you can create a Primary Key with a Non Clustered Index. But by default creation of PK automatically creates a clustered index upon the table.</p></blockquote>
<p><strong>What are the virtual tables in Triggers?</strong></p>
<blockquote><p>Inserted &amp; Deleted are virtual tables in Triggers.</p></blockquote>
<p><strong>How will you know what indexes a particular table is using?</strong></p>
<blockquote><p>By checking the graphical Execution Plan.</p>
<p>By using sys.dm_db_index_usage_stats DMV.</p></blockquote>
<p><strong>How many types of internal joins are there in SQL Server?</strong></p>
<ul>
<li>Nested loop join</li>
<li>Merge join</li>
<li>Hash join</li>
</ul>
<p><strong>What are Join Operators?</strong></p>
<blockquote><p>A join operator is a type of an algorithm which the SQL Server Optimizer chooses in order to implement logical joins between two sets of data.</p>
<p>The SQL Server Optimizer may choose a different algorithm for different scenarios based on the requested query, available indexes, statistics and number of estimated rows in each data set.</p>
<p>It’s possible to find the operator which was used by looking at the execution plan that SQL Server has prepared for your query.</p></blockquote>
<p><strong>What are the Nested Loops Joins?</strong></p>
<blockquote><p>The nested loops join, also called nested iteration, uses one join input as the outer input table (shown as the top input in the graphical execution plan) and one as the inner (bottom) input table. The outer loop consumes the outer input table row by row. The inner loop, executed for each outer row, searches for matching rows in the inner input table.</p>
<p>In the simplest case, the search scans an entire table or index; this is called a naive nested loops join. If the search exploits an index, it is called an index nested loops join. If the index is built as part of the query plan (and destroyed upon completion of the query), it is called a temporary index nested loops join. All these variants are considered by the query optimizer.</p></blockquote>
<p><strong>What are the Merge Loops Joins?</strong></p>
<blockquote><p>The merge join requires both inputs to be sorted on the merge columns, which are defined by the equality (ON) clauses of the join predicate. The query optimizer typically scans an index, if one exists on the proper set of columns, or it places a sort operator below the merge join. In rare cases, there may be multiple equality clauses, but the merge columns are taken from only some of the available equality clauses.</p>
<p>Because each input is sorted, the Merge Join operator gets a row from each input and compares them. For example, for inner join operations, the rows are returned if they are equal. If they are not equal, the lower-value row is discarded and another row is obtained from that input. This process repeats until all rows have been processed.</p></blockquote>
<p><strong>What are the Hash Joins?</strong></p>
<blockquote><p>Hash joins are used for many types of set-matching operations: inner join; left, right, and full outer join; left and right semi-join; intersection; union; and difference. Moreover, a variant of the hash join can do duplicate removal and grouping, such as SUM(salary) GROUP BY department. These modifications use only one input for both the build and probe roles.</p></blockquote>
<p><strong>What is Logical Join and Physical Join?</strong></p>
<blockquote><p><strong>Logical Joins:</strong> These joins are simple joins that we apply in our SQL queries, like INNER JOIN, RIGHT/LEFT OUTER JOIN, CROSS JOIN, OUTER APPLY, etc.</p>
<p><strong>Physical Joins:</strong> These are the joins that users don’t use/write in their SQL queries. Instead these are implemented inside SQL Server engine as operators or algorithms to implement the Logical Joins. Their types are Nested Loop, Merge and Hash.</p></blockquote>
<p><strong>What is an In-Memory Hash Join?</strong></p>
<blockquote><p>The hash join first scans or computes the entire build input and then builds a hash table in memory. Each row is inserted into a hash bucket depending on the hash value computed for the hash key. If the entire build input is smaller than the available memory, all rows can be inserted into the hash table.</p>
<p>This build phase is followed by the probe phase. The entire probe input is scanned or computed one row at a time, and for each probe row, the hash key&#8217;s value is computed, the corresponding hash bucket is scanned, and the matches are produced.</p></blockquote>
<p><strong>What is a Grace Hash Join?</strong></p>
<blockquote><p>If the build input does not fit in memory, a hash join proceeds in several steps. This is known as a grace hash join. Each step has a build phase and probe phase. Initially, the entire build and probe inputs are consumed and partitioned (using a hash function on the hash keys) into multiple files.</p>
<p>Using the hash function on the hash keys guarantees that any two joining records must be in the same pair of files. Therefore, the task of joining two large inputs has been reduced to multiple, but smaller, instances of the same tasks. The hash join is then applied to each pair of partitioned files.</p></blockquote>
<p><strong>What is a Recursive Hash Join?</strong></p>
<blockquote><p>If the build input is so large that inputs for a standard external merge would require multiple merge levels, multiple partitioning steps and multiple partitioning levels are required. If only some of the partitions are large, additional partitioning steps are used for only those specific partitions. In order to make all partitioning steps as fast as possible, large, asynchronous I/O operations are used so that a single thread can keep multiple disk drives busy.</p>
<p>If the optimizer anticipates wrongly which of the two inputs is smaller and, therefore, should have been the build input, the build and probe roles are reversed dynamically. The hash join makes sure that it uses the smaller overflow file as build input. This technique is called role reversal. Role reversal occurs inside the hash join after at least one spill to the disk.</p></blockquote>
<p><strong>What is COMPUTE BY statement?</strong></p>
<blockquote><p>COMPUTE BY statement has both detail and summary rows within the SELECT statement. It calculates the summary values for subgroups, or a summary value for the entire result set.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-13)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-table-index-partitioning-partition-function-schema-day-13/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 24 Jun 2016 07:06:36 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[index partitioning]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[LAG]]></category>
		<category><![CDATA[LEAD]]></category>
		<category><![CDATA[partition function]]></category>
		<category><![CDATA[partition schema]]></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[T-SQL]]></category>
		<category><![CDATA[table partitioning]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3075</guid>

					<description><![CDATA[What is a Table and Index Partitioning in SQL Server? Partitioning makes large tables or indexes more manageable, because partitioning enables you to manage and access subsets of data quickly and efficiently, while maintaining the integrity of a data collection. By using partitioning, an operation such as loading data from an OLTP to an OLAP [&#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-table-index-partitioning-partition-function-schema-day-13%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%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-table-index-partitioning-partition-function-schema-day-13%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%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-table-index-partitioning-partition-function-schema-day-13%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%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-table-index-partitioning-partition-function-schema-day-13%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%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-table-index-partitioning-partition-function-schema-day-13%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%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-table-index-partitioning-partition-function-schema-day-13%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%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-table-index-partitioning-partition-function-schema-day-13%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-13%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-table-index-partitioning-partition-function-schema-day-13/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-13)"></a></p><p><strong>What is a Table and Index Partitioning in SQL Server?</strong></p>
<blockquote><p>Partitioning makes large tables or indexes more manageable, because partitioning enables you to manage and access subsets of data quickly and efficiently, while maintaining the integrity of a data collection. By using partitioning, an operation such as loading data from an OLTP to an OLAP system takes only seconds, instead of the minutes and hours.</p>
<p>Maintenance operations that are performed on subsets of data are also performed more efficiently because these operations target only the data that is required, instead of the whole table.</p>
<p>The data of partitioned tables and indexes is divided into units that can be spread across more than one filegroup in a database. The data is partitioned horizontally, so that groups of rows are mapped into individual partitions. The table or index is treated as a single logical entity when queries or updates are performed on the data. All partitions of a single index or table must reside in the same database.</p>
<p>Partitioned tables and indexes support all the properties and features associated with designing and querying standard tables and indexes, including constraints, defaults, identity and timestamp values, and triggers. Therefore, if you want to implement a partitioned view that is local to one server, you might want to implement a partitioned table instead.</p></blockquote>
<p><strong>Can you perform a table or index partitioning in SQL Server standard or web edition?</strong></p>
<blockquote><p>No: Partitioned tables and indexes are available only on the Enterprise, Developer, and Evaluation editions of SQL Server.</p></blockquote>
<p><strong>In which situation, we require to implement table or index partitioning?</strong></p>
<blockquote><p>Deciding whether to implement partitioning depends primarily on how large your table is or how large it will become, how it is being used, and how well it is performing against user queries and maintenance operations.</p>
<p>Generally, a large table might be appropriate for partitioning if both of the following are true:</p>
<p>The table contains, or is expected to contain, lots of data that are used in different ways.</p>
<p>Queries or updates against the table are not performing as intended, or maintenance costs exceed predefined maintenance periods.</p>
<p>For example, if a current month of data is primarily used for INSERT, UPDATE, DELETE, and MERGE operations while previous months are used primarily for SELECT queries, managing this table may be easier if it is partitioned by month.</p></blockquote>
<p><strong>Would you please describe the basic steps to implement partitioning on Table or Index?</strong></p>
<p>Creating a partitioned table or index typically happens in four parts:</p>
<ul>
<li>Create a filegroup or filegroups and corresponding files that will hold the partitions specified by the partition scheme.</li>
<li>Create a partition function that maps the rows of a table or index into partitions based on the values of a specified column.</li>
<li>Create a partition scheme that maps the partitions of a partitioned table or index to the new filegroups.</li>
<li>Create or modify a table or index and specify the partition scheme as the storage location.</li>
</ul>
<p><strong>What is a Partition Function?</strong></p>
<blockquote><p>A partition function defines how the rows of a table or index are mapped to a set of partitions based on the values of certain columns, called partitioning columns.</p></blockquote>
<p><strong>Do you know the syntax of PARTITION FUNCTION?</strong></p><pre class="crayon-plain-tag">CREATE PARTITION FUNCTION partition_function_name ( input_parameter_type )  
AS RANGE [ LEFT | RIGHT ]   
FOR VALUES ( [ boundary_value [ ,...n ] ] )   
[ ; ]</pre><p>
<strong>What is a Partition Scheme?</strong></p>
<blockquote><p>A partition scheme maps each partition specified by the partition function to a filegroup.</p></blockquote>
<p><strong>Do you know the syntax of PARTITION SCHEME?</strong></p><pre class="crayon-plain-tag">CREATE PARTITION SCHEME partition_scheme_name  
AS PARTITION partition_function_name  
[ ALL ] TO ( { file_group_name | [ PRIMARY ] } [ ,...n ] )  
[ ; ]</pre><p>
<strong>What are the limitations of Partitioning?</strong></p>
<blockquote><p>The scope of a partition function and scheme is limited to the database in which they have been created. Within the database, partition functions reside in a separate namespace from other functions.</p>
<p>If any rows within a partition function have partitioning columns with null values, these rows are allocated to the left-most partition.</p>
<p>However, if NULL is specified as a boundary value and RIGHT is indicated, the left-most partition remains empty and NULL values are placed in the second partition.</p></blockquote>
<p><strong>Which system table is used to find the information about the database partitions?</strong></p>
<blockquote><p>Using sys.partitions, It contains a row for each partition of all the tables and most types of indexes in the database.</p></blockquote>
<p><strong>Does it make sense to design a partitioned index separately?</strong></p>
<ul>
<li>Although partitioned indexes can be implemented independently from their base tables, it generally makes sense to design a partitioned table and then create an index on the table. When you do this, SQL Server automatically partitions the index by using the same partition scheme and partitioning column as the table.</li>
<li>As a result, the index is partitioned in essentially the same manner as the table. This makes the index aligned with the table.</li>
<li>SQL Server does not align the index with the table if you specify a different partition scheme or a separate filegroup on which to put the index at creation time.</li>
</ul>
<p><strong>When you should implement Index partitioning?</strong></p>
<p>Designing a partitioned index independently (unaligned) of the base table can be useful in the following cases:</p>
<ul>
<li>The base table has not been partitioned.</li>
<li>The index key is unique and it does not contain the partitioning column of the table.</li>
<li>You want the base table to participate in collocated joins with more tables using different join columns.</li>
</ul>
<p><strong>What do you know about the Functional Dependency?</strong></p>
<blockquote><p>Functional dependency (FD) is a set of constraints between two attributes in a relation. Functional dependency says that if two tuples have same values for attributes A1, A2,&#8230;, An, then those two tuples must have to have same values for attributes B1, B2, &#8230;, Bn.</p>
<p>Functional dependency is represented by an arrow sign (→) that is, X→Y, where X functionally determines Y. The left-hand side attributes determine the values of attributes on the right-hand side.</p></blockquote>
<p><strong>What is the difference between =,== and ===?</strong></p>
<ul>
<li>&#8216;=&#8217;: is for assigning one value to the other variable.</li>
<li>&#8216;==&#8217;: is for the comparison between string with number, number with number etc.</li>
<li>&#8216;===&#8217;: is for the comparison between only number with number and string with string.</li>
</ul>
<p><strong>What do you mean by the derived tables?</strong></p>
<blockquote><p>They are basically select statements in the from clause referred to by an alias name. The alias name creates a table in the result set that can then be referred to by some other Select statement.</p>
<p>It also called as Inline views.</p></blockquote>
<p><strong>What is a deterministic and nondeterministic function in SQL Server?</strong></p>
<ul>
<li>A deterministic function will return the same result when it is called with the same set of input parameters. Adding two numbers together is an example of a deterministic function.</li>
<li>A nondeterministic function, on the other hand, may return different results every time they are called with the same set of input values.</li>
</ul>
<p><strong>What do you know about LEAD() of SQL Server 2012?</strong></p>
<blockquote class="wp-embedded-content" data-secret="LMpySq95k2"><p><a href="https://www.dbrnd.com/2016/02/sql-server-2012-introduced-lead-function-the-best-alternative-of-self-join-to-compare-next-row/">SQL Server 2012: Introduced LEAD function, the best alternative of Self Join to compare Next Row</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/02/sql-server-2012-introduced-lead-function-the-best-alternative-of-self-join-to-compare-next-row/embed/#?secret=LMpySq95k2" data-secret="LMpySq95k2" width="600" height="338" title="&#8220;SQL Server 2012: Introduced LEAD function, the best alternative of Self Join to compare Next Row&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What do you know about LAG() of SQL Server 2012?</strong></p>
<blockquote class="wp-embedded-content" data-secret="hj18uS7T7x"><p><a href="https://www.dbrnd.com/2016/02/sql-server-2012-introduced-lag-function-the-best-alternative-of-self-join-to-compare-previous-row/">SQL Server 2012: Introduced LAG function, the best alternative of Self Join to compare Previous Row</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/02/sql-server-2012-introduced-lag-function-the-best-alternative-of-self-join-to-compare-previous-row/embed/#?secret=hj18uS7T7x" data-secret="hj18uS7T7x" width="600" height="338" title="&#8220;SQL Server 2012: Introduced LAG function, the best alternative of Self Join to compare Previous Row&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-12)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 23 Jun 2016 18:41:48 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[DATETIME]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[row level security]]></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[TIMESTAMP]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3069</guid>

					<description><![CDATA[What are the new development features of SQL Server2016? Native JSON Support Always Encrypted Query Store Live Query Statistics Row Level Security Temporal database support What does the Query Store do in SQL Server 2016? Store the history of query plans in the system. Capture the performance of each query plan over time. Identify queries [&#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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%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-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-12%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-2016-database-developer-t-sql-interview-questions-and-answers-json-query-store-row-level-secuity-day-12/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-12)"></a></p><p><strong>What are the new development features of SQL Server2016?</strong></p>
<ul>
<li>Native JSON Support</li>
<li>Always Encrypted</li>
<li>Query Store</li>
<li>Live Query Statistics</li>
<li>Row Level Security</li>
<li>Temporal database support</li>
</ul>
<p><strong>What does the Query Store do in SQL Server 2016?</strong></p>
<ul>
<li>Store the history of query plans in the system.</li>
<li>Capture the performance of each query plan over time.</li>
<li>Identify queries that have &#8220;gotten slower recently&#8221;.</li>
<li>Allow you to force plans quickly.</li>
</ul>
<p><strong>What do you know about Live Query Statistics of SQL Server 2016?</strong></p>
<blockquote><p>It is a new feature of SQL Server2016 that allows you to view what is happening during the query execution.</p>
<p>It lets you view a list of active queries and associated statistics such as current CPU/Memory usage, execution time, query progress, and so on.</p></blockquote>
<p><strong>What is a good alternative of XML data type in SQL Server 2016?</strong></p>
<blockquote><p>The newly introduced JSON data type is one of the best option and alternative of XML data type.</p></blockquote>
<p><strong>Why JSON is becoming more important than XML?</strong></p>
<blockquote><p>One of the biggest reasons JSON is becoming more important than XML is that XML has to be parsed with an XML parser, while JSON can be parsed by a standard JavaSript function and it is very light-weight.</p>
<p>This makes it easier and faster than working with XML.</p></blockquote>
<p><strong>What is Row-Level Security in SQL Server 2016?</strong></p>
<blockquote><p>Row-Level Security: RLS enables developers and DBAs to control access to rows in a database table. Using RLS, you can store data for different customers, departments, or tenants in the same table, while restricting access to rows based on a query&#8217;s execution context.</p></blockquote>
<p><strong>What are the two types of character data SQL Server supports?</strong></p>
<ul>
<li>Regular and Unicode.</li>
<li>Char and Varchar is Regular character data type.</li>
<li>NChar and NVarchar is Unicode character data type.</li>
</ul>
<p><strong>How are literal strings expressed with the Unicode character column?</strong></p>
<blockquote><p>It must start with N&#8217;text&#8217;.</p></blockquote>
<p><strong>What is the difference between Datetime and Timestamp data types?</strong></p>
<blockquote><p>Datetime is a data type.</p>
<p>Timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. Timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.</p>
<p>Timestamp is a synonym of the Rowversion data type.</p></blockquote>
<p><strong>What is SWITCHOFFSET function?</strong></p>
<blockquote><p>SWITCHOFFSET function is used to convert the time from one time zone to another time zone, and it will work for date time offset fields.</p></blockquote>
<p><strong>How to SELECT n Random records from a Table in the database?</strong></p><pre class="crayon-plain-tag">SELECT TOP 3 *FROM tbl_TableName ORDER BY NEWID();</pre><p>
<strong>Which stored procedure is used to send an email in SQL Server?</strong></p>
<blockquote><p>sp_send_dbmail: The msdb database stored procedure.</p></blockquote>
<p><strong>Which stored procedure is used to update a description of the column?</strong></p>
<blockquote><p>We can update column description using sp_updateextendedproperty.</p></blockquote>
<p><strong>How we can get the Database name using SQL Command?</strong></p><pre class="crayon-plain-tag">SELECT DB_NAME();</pre><p>
<strong>I want to concatenate NULL value with string and do not require output as NULL only.</strong><br />
<strong> How do you achieve this?</strong><br />
<strong> Using,</strong></p><pre class="crayon-plain-tag">SET CONCAT_NULL_YIELDS_NULL ON / OFF;

SET CONCAT_NULL_YIELDS_NULL ON:
PRINT 'dbrnd.com' + NULL;
Result is NULL.

SET CONCAT_NULL_YIELDS_NULL OFF:
PRINT 'dbrnd.com' + NULL;
Result is dbrnd.com</pre><p>
<strong>How can you insert multiple rows together in a single insert statement?</strong></p><pre class="crayon-plain-tag">INSERT INTO tbl_Tablename 
(id,name)
VALUES
(1,'abc'),(2,'xyz'),(3,'pqr');</pre><p>
<strong>How will you delete all records of table other then recently added 10 records?</strong></p><pre class="crayon-plain-tag">DELETE FROM table_name
WHERE id not in 
(
	SELECT TOP 10 ID FROM 
	table_name ORDER BY date DESC
);</pre><p>
<strong>What is the solution of below error?</strong></p>
<p><strong>Msg 7411, Level 16, State 1, Procedure , Line 3 Server &#8216;SERVERNAME\MSSQL2012&#8217; is not configured for DATA ACCESS.</strong></p>
<p>Require to enable DATA ACCESS on SQL Server Instance.</p><pre class="crayon-plain-tag">EXEC sp_serveroption 'SERVERNAME\MSSQL2012', 'DATA ACCESS', TRUE</pre><p>
<strong>Can you execute Stored Procedure in View?</strong></p>
<blockquote><p>Yes: Using OPENQUERY, we can execute stored procedure in view.</p></blockquote>
<p><strong>What is a @@FETCH_STATUS in T-SQL?</strong></p>
<blockquote><p>To know the status of the last cursor FETCH statement issued against any cursor currently opened by the connection.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-11)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 22 Jun 2016 19:18:03 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[fetch]]></category>
		<category><![CDATA[Hekaton]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[memory database]]></category>
		<category><![CDATA[memory table]]></category>
		<category><![CDATA[offset]]></category>
		<category><![CDATA[Pivot]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[schemabinding]]></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>
		<category><![CDATA[unpivot]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3066</guid>

					<description><![CDATA[What is In-memory Database? Database Theory: What is In-memory Database? What is Hekaton in SQL Server 2014? SQL Server 2014: What is Hekaton? How to create memory optimized table in SQL Server 2014? SQL Server 2014: Create Memory Optimized File Group and Table I want to turn the unique record from multiple rows to multiple [&#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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%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-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-11%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-memory-hekaton-offset-fetch-pivot-unpivot-with-schemabinding-day-11/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-11)"></a></p><p><strong>What is In-memory Database?</strong></p>
<blockquote class="wp-embedded-content" data-secret="20p6VsNGKF"><p><a href="https://www.dbrnd.com/2015/12/database-theory-what-is-in-memory-database/">Database Theory: What is In-memory Database?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/12/database-theory-what-is-in-memory-database/embed/#?secret=20p6VsNGKF" data-secret="20p6VsNGKF" width="600" height="338" title="&#8220;Database Theory: What is In-memory Database?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is Hekaton in SQL Server 2014?</strong></p>
<blockquote class="wp-embedded-content" data-secret="PGyhLLADrO"><p><a href="https://www.dbrnd.com/2016/01/sql-server-2014-what-is-hekaton/">SQL Server 2014: What is Hekaton?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/01/sql-server-2014-what-is-hekaton/embed/#?secret=PGyhLLADrO" data-secret="PGyhLLADrO" width="600" height="338" title="&#8220;SQL Server 2014: What is Hekaton?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How to create memory optimized table in SQL Server 2014?</strong></p>
<blockquote class="wp-embedded-content" data-secret="pMRG55kUs9"><p><a href="https://www.dbrnd.com/2016/01/sql-server-2014-create-memory-optimized-file-group-and-table/">SQL Server 2014: Create Memory Optimized File Group and Table</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/01/sql-server-2014-create-memory-optimized-file-group-and-table/embed/#?secret=pMRG55kUs9" data-secret="pMRG55kUs9" width="600" height="338" title="&#8220;SQL Server 2014: Create Memory Optimized File Group and Table&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>I want to turn the unique record from multiple rows to multiple column values. Is it possible in SQL Server?</strong></p>
<blockquote><p>Yes, We can do this task using PIVOT.</p>
<p>SQL Server has a PIVOT relational operator to turn the unique values of a specified column from multiple rows into multiple column values in the output (cross-tab), effectively rotating a table. It also allows performing aggregations, wherever required, for column values that are expected in the final output. The basic syntax for a PIVOT relational operator looks like this:</p></blockquote>
<blockquote><p>
</p><pre class="crayon-plain-tag">SELECT [ColumnNames] FROM [TableName]
PIVOT
(
AggregateFunction([ColumnToBeAggregated])
FOR PivotColumn IN ([PivotColumnValues])
) AS Alias</pre><p>
</p></blockquote>
<p><strong>Do you know about the UNPIVOT?</strong></p>
<blockquote><p>UNPIVOT is another relational operator in SQL Server that performs almost the reverse operation of PIVOT, by rotating column values into rows values.</p>
<p>Using UNPIVOT, Do you think that you can get all correct value which are pivoted using PIVOT?</p>
<p>If you refer back, I said UNPIVOT is almost the reverse of the PIVOT operator; this means it might or might not be exactly the same. The reason is, Pivot performs aggregation while rotating row values into column values and might merge possible multiple row values into single column value in the output.</p></blockquote>
<p><strong>What is the WITH CHECK OPTION clause for a view?</strong></p>
<blockquote><p>The WITH CHECK OPTION for a view prevents data modifications (to the data) that do not confirm to the WHERE clause of the view definition. This allows data to be updated via the view, but only if it belongs in the view.</p></blockquote>
<p><strong>How you are checking that record is exists in database or not?</strong></p>
<p><strong>Using EXISTS clause:</strong></p><pre class="crayon-plain-tag">IF EXISTS(SELECT 1 FROM dbo.Customer WITH(NOLOCK) WHERE CustId = @CustId)
    BEGIN
        PRINT 'Record Exists'
    END
ELSE
    BEGIN
        PRINT 'Record doesn''t Exists'
    END
END IF;</pre><p>
<strong>What is the meaning of the WITH SCHEMABINDING clause?</strong></p>
<ul>
<li>SCHEMABINDING binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition.</li>
<li>The view definition itself must first be modified or dropped to remove dependencies on the table that is to be modified.</li>
<li>All referenced objects must be in the same database. Views or tables that participate in a view created with the SCHEMABINDING clause cannot be dropped unless that view is dropped or changed so that it no longer has schema binding. Otherwise, the Database Engine raises an error.</li>
<li>Also, executing ALTER TABLE statements on tables that participate in views that have schema binding fail when these statements affect the view definition.</li>
<li>The implementation of SCHEMABINDING would increase stability and performance of the system, but also increase the amount of developers’ work.</li>
</ul>
<p><strong>Can we use WITH SCHEMABINDING in Stored Procedures?</strong></p>
<blockquote><p>No: We cannot use WITH SCHEMABINDING in stored procedures.</p></blockquote>
<p><strong>What are the main disadvantages of the WITH SCHEMABINDING clause?</strong></p>
<blockquote><p>It would take more time to make changes in tables’ structure. If I just want to change the size of one column, I will need to modify before and after several views.</p>
<p>The automated test of the application can catch all broken views and functions. This will not increase the amount of developers’ work.</p>
<p>You can not change the collation of a database with schemabound objects.</p></blockquote>
<p><strong>What do you know about the OFFSET FETCH clause of the SQL Server 2012?</strong></p>
<blockquote><p>The OFFSET-FETCH clause provides you with an option to fetch only a window or page of results from the result set. OFFSET-FETCH can be used only with the ORDER BY clause.</p>
<p><strong>OFFSET:</strong> Specifies the number of rows to skip, before starting to return rows from the query expression. The argument for the OFFSET clause can be an integer or expression that is greater than or equal to zero. You can use ROW and ROWS interchangeably.</p>
<p><strong>FETCH:</strong> Specifies the number of rows to return, after processing the OFFSET clause. The argument for the FETCH clause can be an integer or expression that is greater than or equal to one. You can use ROW and ROWS interchangeably. Similarly, FIRST and NEXT can be used interchangeably.</p></blockquote>
<p><strong>Please write a script or logic of custom paging using OFFSET and FETCH NEXT.</strong></p>
<blockquote class="wp-embedded-content" data-secret="ogXSF1WZTo"><p><a href="https://www.dbrnd.com/2016/01/sql-server-2012-custom-paging-using-offset-and-fetch-next/">SQL Server 2012: Custom paging using OFFSET and FETCH NEXT</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/01/sql-server-2012-custom-paging-using-offset-and-fetch-next/embed/#?secret=ogXSF1WZTo" data-secret="ogXSF1WZTo" width="600" height="338" title="&#8220;SQL Server 2012: Custom paging using OFFSET and FETCH NEXT&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What are the limitations of OFFSET and FETCH clause of the SQL Server 2012?</strong></p>
<ul>
<li>ORDER BY is mandatory to use OFFSET and FETCH clause.</li>
<li>OFFSET clause is mandatory with FETCH. You can never use, ORDER BY … FETCH.</li>
<li>TOP cannot be combined with OFFSET and FETCH in the same query expression.</li>
<li>The OFFSET/FETCH rowcount expression can be any arithmetic, constant, or parameter expression that will return an integer value. The rowcount expression does not support scalar sub-queries.</li>
</ul>
<p><strong>What is the maximum size of a VARCHAR(MAX) variable?</strong></p>
<blockquote><p>Maximum size of a VARCHAR(MAX) is 2GB.</p></blockquote>
<p><strong>What is BCP? When is it used?</strong></p>
<blockquote><p>It is a tool used to duplicate enormous quantity of information from tables and views. It does not facsimile the structures same as foundation to target. BULK INSERT command helps to bring in a data folder into a record, table or view in a user-specific arrangement.</p></blockquote>
<p><strong>When is the Explicit Cursor Used ?</strong></p>
<blockquote><p>If the developer needs to perform the row by row operations for the result set containing more than one row, then he unambiguously declares a pointer with a name. They are managed by OPEN, FETCH and CLOSE.</p>
<p>%FOUND, %NOFOUND, %ROWCOUNT and %ISOPEN characteristics are used in all types of pointers.</p></blockquote>
<p><strong>How can a SQL Developer prevent T-SQL code from running on a production SQL Server?</strong></p>
<blockquote><p>Use IF logic with the @@SERVERNAME function compared against a string with a RETURN command before any other logic.</p></blockquote>
<p><strong>Can you create foreign key constraints on temporary tables?</strong></p>
<blockquote><p>No: You cannot create a foreign key constraint on temporary tables.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-10)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 21 Jun 2016 19:51:08 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[char]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[NVARCHAR]]></category>
		<category><![CDATA[Parameter Sniffing]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[raiseerror]]></category>
		<category><![CDATA[smallint]]></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[sql_variant]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[throw]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[VARCHAR]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3063</guid>

					<description><![CDATA[What is the difference between Varchar and NVarchar data type? varchar: Variable-length, non-Unicode character data. The database collation determines which code page the data is stored using. nvarchar: Variable-length Unicode character data. Dependent on the database collation for comparisons. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use [&#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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%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-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-10%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-msdtc-parameter-sniffing-sql_variant-throw-raiseerror-day-10/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-10)"></a></p><p><strong>What is the difference between Varchar and NVarchar data type?</strong></p>
<blockquote><p>varchar: Variable-length, non-Unicode character data. The database collation determines which code page the data is stored using.</p>
<p>nvarchar: Variable-length Unicode character data. Dependent on the database collation for comparisons.</p>
<p>Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols.</p>
<p>The key difference between the two data types is how they&#8217;re stored.</p></blockquote>
<p><strong>What is the difference between Varchar(max) and TEXT data type?</strong></p>
<blockquote><p>The VARCHAR(MAX) type is a replacement for TEXT. The basic difference is that a TEXT type will always store the data in a blob whereas the VARCHAR(MAX) type will attempt to store the data directly in the row unless it exceeds the 8k limitation and at that point it stores it in a blob.</p>
<p>The legacy types (TEXT, NTEXT, IMAGE) are deprecated and support for them will be dropped in a future version of SQL Server.</p></blockquote>
<p><strong>What is the difference between CHAR and VARCHAR?</strong></p>
<blockquote><p>CHAR Data Type is a Fixed Length Data Type. For example if you declare a variable/column of CHAR (10) data type, then it will always take 10 bytes irrespective of whether you are storing 1 character or 10 character in this variable or column.</p>
<p>On the other hand VARCHAR is a variable length Data Type. For example if you declare a variable/column of VARCHAR (10) data type, it will take the no. of bytes equal to the number of characters stored in this column. So, in this variable/column if you are storing only one character then it will take only one byte and if we are storing 10 characters then it will take 10 bytes.</p></blockquote>
<p><strong>What is the difference between Datetime and Datetime2?</strong></p>
<p>DateTime2 is the new Data Type introduced in SQL Server 2008 for storing Date and Time value. Microsoft Suggests to use this new Data Type instead of DateTime that is mainly available for backwards compatibility.</p>
<p><strong>Min and Max values:</strong></p>
<ul>
<li>DateTime: BETWEEN ‘1753-01-01 00:00:00’ AND ‘’9999-12-31 23:59:59.997’</li>
<li>DateTime2: BETWEEN ‘0001-01-01 00:00:00’ AND ‘9999-12-31 23:59:59.9999999’</li>
</ul>
<p><strong>Storage Size:</strong></p>
<ul>
<li>DateTime: 8 Bytes</li>
<li>DateTime2(n): 6 to 8 bytes</li>
</ul>
<p><strong>Precision:</strong></p>
<ul>
<li>DateTime – only allows for precision up to every 3rd milisecond which essentially means that you can get rounding issues for times that are in fact different. The rounding is to increments of .000, .003, or .007 seconds.</li>
<li>DateTime2(n) – The precision scale is 0 to 7 digits, with an accuracy of 100 nanoseconds . The default precision is 7 digits.</li>
</ul>
<p><strong>What is the difference between HAVING and WHERE Clause?</strong></p>
<ul>
<li>HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.</li>
<li>HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause.</li>
<li>A query can contain both a WHERE clause and a HAVING clause. The WHERE clause is applied first to the individual rows in the tables . Only the rows that meet the conditions in the WHERE clause are grouped. The HAVING clause, then applied to the rows in the result set. Only the groups that meet the HAVING conditions appear in the query output.</li>
</ul>
<p><strong>What is the difference Between GETDATE and SYSDATETIME?</strong></p>
<p>In case of GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds.</p>
<p>&nbsp;</p>
<p><strong>What is the difference between THROW and RAISERROR?</strong></p>
<blockquote><p>When using RAISERROR function, it just returns the last (single) error message and its details, but the previous error message details are not returned by this function.</p>
<p>With the new THROW clause you won’t see any issue of omitting the previous errors. And it returns all error details as thrown by the SQL statement itself.</p></blockquote>
<p><strong>What is bit data type?</strong></p>
<blockquote><p>Bit datatype is used to store boolean information like 1 or 0 (true or false).</p>
<p>Bit datatype can represent a Null state.</p></blockquote>
<p><strong>What is the difference between SMALLINT and TINYINT?</strong></p>
<blockquote><p>The storage of TinyINT is 1 byte and can store range from 0 to 255.</p>
<p>The storage of SmallINT is 2 bytes and can store range from -32768 to 32767.</p></blockquote>
<p><strong>What is the Difference Between Cast and Convert?</strong></p>
<ul>
<li>CAST and CONVERT are both used to convert data from one data type to another.</li>
<li>CAST is part of the ANSI-SQL specification; whereas, CONVERT is not.  In fact, CONVERT is SQL implementation specific.</li>
<li>CONVERT differences lie in that it accepts an optional style parameter which is used for formatting.</li>
<li>For example, when converting a DateTime datatype to Varchar, you can specify the resulting date’s format, such as YYYY/MM/DD or MM/DD/YYYY.</li>
<li>SELECT CONVERT(VARCHAR,GETDATE(),101) as MMDDYYYY, CONVERT(VARCHAR,GETDATE(),111) as YYYYMMDD</li>
</ul>
<p>&nbsp;</p>
<p><strong>Have you ever stored XML type of data into SQL Server?</strong></p>
<blockquote><p>Yes: Using XML Data type, we can store XML formatted data into SQL Server.</p>
<p>XML is a good choice if you want a platform-independent model in order to ensure portability of the data by using structural and semantic markup.</p></blockquote>
<p><strong>What is MSDTC?</strong></p>
<blockquote><p>The Microsoft Distributed Transaction Coordinator is a transaction manager that allows client applications to include several different sources of data in one transaction.</p>
<p>MSDTC coordinates committing the distributed transaction across all the servers enlisted in the transaction.</p></blockquote>
<p><strong>What is Distributed Queries in SQL Server?</strong></p>
<blockquote><p>Distributed query access data from multiple heterogeneous data sources. These data sources can be stored on either the same or different computers. It supports distributed queries by using OLEDB.</p></blockquote>
<p><strong>What is a Two-Phase Commit?</strong></p>
<blockquote><p>In transaction processing, databases, and computer networking, the two-phase commit protocol (2PC) is a type of atomic commitment protocol (ACP). It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort (roll back) the transaction.</p>
<p>Two Phase commit is used in distributed data base systems. This is useful to maintain the integrity of the database so that all the users see the same values. It contains DML statements or Remote Procedural calls that reference a remote object. There are basically 2 phases in a 2 phase commit.</p></blockquote>
<blockquote><p>Prepare Phase : Global coordinator asks participants to prepare</p>
<p>Commit Phase : Commit all participants to coordinator to Prepared, Read only or abort Reply.</p></blockquote>
<p><strong>What do you know about the SQL Server parameter sniffing?</strong></p>
<blockquote class="wp-embedded-content" data-secret="L45xWCklUM"><p><a href="https://www.dbrnd.com/2015/05/sql-server-parameter-sniffing/">SQL Server Parameter Sniffing</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/sql-server-parameter-sniffing/embed/#?secret=L45xWCklUM" data-secret="L45xWCklUM" width="600" height="338" title="&#8220;SQL Server Parameter Sniffing&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How do we recompile a stored procedure at run time?</strong></p>
<blockquote><p>Using WITH RECOMPILE hint option, we can recompile stored procedure at run time.</p></blockquote>
<p><strong>What is a SQL_VARIANT?</strong></p>
<ul>
<li>It is a data type that stores values of various SQL Server-supported data types.</li>
<li>sql_variant can be used in columns, parameters, variables, and the return values of user-defined functions. sql_variant enables these database objects to support values of other data types.</li>
<li>A column of type sql_variant may contain rows of different data types. For example, a column defined as sql_variant can store int, binary, and char values.</li>
<li>sql_variant can have a maximum length of 8016 bytes.</li>
</ul>
<p><strong>What kind of data types which are not supported by SQL_VARIANT?</strong></p>
<ul>
<li>varchar(max)</li>
<li>varbinary(max)</li>
<li>nvarchar(max)</li>
<li>xml</li>
<li>text</li>
<li>ntext</li>
<li>image</li>
<li>rowversion (timestamp)</li>
<li>sql_variant</li>
<li>geography</li>
<li>hierarchyid</li>
<li>geometry</li>
<li>User-defined types</li>
<li>datetimeoffset</li>
</ul>
<p><strong>Would you please explain the logic to split a comma separated values?</strong></p>
<blockquote class="wp-embedded-content" data-secret="x028VWWRz4"><p><a href="https://www.dbrnd.com/2015/12/sql-serverfunction-to-split-string-value-using-different-delimiters/">SQL Server:Function to Split String Value Using Different Delimiters</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/12/sql-serverfunction-to-split-string-value-using-different-delimiters/embed/#?secret=x028VWWRz4" data-secret="x028VWWRz4" width="600" height="338" title="&#8220;SQL Server:Function to Split String Value Using Different Delimiters&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-9)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-indentity-column-sequence-object-scope_identity-openxml-day-9/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 20 Jun 2016 18:37:57 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[case statement]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[sequence]]></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=3060</guid>

					<description><![CDATA[What is an IDENTITY? You can use IDENTITY for auto increment value. We can create an identity column in a table. This property is used with the CREATE TABLE and ALTER TABLE Transact-SQL statements. We must specify both the seed and increment or neither. If neither is specified, the default is (1,1). What are differences [&#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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%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-indentity-column-sequence-object-scope_identity-openxml-day-9%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-9%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-indentity-column-sequence-object-scope_identity-openxml-day-9/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-9)"></a></p><p><strong>What is an IDENTITY?</strong></p>
<ul>
<li>You can use IDENTITY for auto increment value.</li>
<li>We can create an identity column in a table.</li>
<li>This property is used with the CREATE TABLE and ALTER TABLE Transact-SQL statements.</li>
<li>We must specify both the seed and increment or neither. If neither is specified, the default is (1,1).</li>
</ul>
<p><strong>What are differences between @@IDENTITY, SCOPE_IDENTITY() and IDENT_CURRENT?</strong></p>
<blockquote><p><strong>SELECT @@IDENTITY:</strong></p>
<p>It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value.</p>
<p>@@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it.</p>
<p><strong>SELECT SCOPE_IDENTITY():</strong></p>
<p>It returns the last IDENTITY value produced on a connection and by a statement in the same scope, regardless of the table that produced the value.</p>
<p>SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than any identity that was created by a trigger or a user defined function.</p>
<p><strong>SELECT IDENT_CURRENT(‘tablename’):</strong></p>
<p>It returns the last IDENTITY value produced in a table, regardless of the connection that created the value, and regardless of the scope of the statement that produced the value.</p>
<p>IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope.</p></blockquote>
<p><strong>How you can reset the value of IDENTITY?</strong></p>
<blockquote class="wp-embedded-content" data-secret="fgbcAk0QXJ"><p><a href="https://www.dbrnd.com/2015/10/sql-server-script-to-reset-table-identity-using-dbcc-checkident/">SQL Server: Script to reset Table Identity using DBCC CHECKIDENT</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/sql-server-script-to-reset-table-identity-using-dbcc-checkident/embed/#?secret=fgbcAk0QXJ" data-secret="fgbcAk0QXJ" width="600" height="338" title="&#8220;SQL Server: Script to reset Table Identity using DBCC CHECKIDENT&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How to find all identity columns of a Database?</strong></p>
<blockquote class="wp-embedded-content" data-secret="XLSca8zNYy"><p><a href="https://www.dbrnd.com/2015/12/sql-server-script-to-find-identity-column-of-a-database/">SQL Server: Script to find Identity Column of a Database</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/12/sql-server-script-to-find-identity-column-of-a-database/embed/#?secret=XLSca8zNYy" data-secret="XLSca8zNYy" width="600" height="338" title="&#8220;SQL Server: Script to find Identity Column of a Database&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the solution of below error?</strong></p>
<p><strong>Cannot insert explicit value for identity column in table &#8216;IdentityTable&#8217; when IDENTITY_INSERT is set to OFF.</strong></p>
<blockquote><p>Yes, When IDENTITY_INSERT is OFF, we cannot insert a data into an identity column of a table.</p>
<p>SET IDENTITY_INSERT table_name ON option, allows explicit values to be inserted into the identity column of a table.</p>
<p>If the value inserted is larger than the current identity value for the table, SQL Server automatically uses the new inserted value as the current identity value.</p>
<p>The setting of SET IDENTITY_INSERT is set at execute or run time and not at parse time.</p></blockquote>
<p><strong>What do you know about the Sequence object of SQL Server 2012?</strong></p>
<blockquote><p>A sequence is a user-defined schema bound object that generates a sequence of numeric values according to the specification with which the sequence was created. The sequence of numeric values is generated in an ascending or descending order at a defined interval and can be configured to restart (cycle) when exhausted.</p>
<p>Sequences, unlike identity columns, are not associated with specific tables. User applications can reference a sequence object and coordinate the values across multiple rows and tables.</p></blockquote>
<p><strong>Would you please explain the important arguments of the Sequence object?</strong></p>
<blockquote><p><strong>START WITH [constant]:</strong></p>
<p>The first value returned by the sequence object. The START value must be a value less than or equal to the maximum and greater than or equal to the minimum value of the sequence object.</p>
<p><strong>INCREMENT BY [constant]:</strong></p>
<p>Value used to increment (or decrement if negative) the value of the sequence object for each call to the NEXT VALUE FOR function. If the increment is a negative value, the sequence object is descending; otherwise, it is ascending.</p>
<p><strong>MINVALUE [constant] | [NO MINVALUE]:</strong></p>
<p>Specifies the bounds for the sequence object. The default minimum value for a new sequence object is the minimum value of the data type of the sequence object.</p>
<p><strong>MAXVALUE [constant] | [NO MAXVALUE]:</strong></p>
<p>Specifies the bounds for the sequence object. The default maximum value for a new sequence object is the maximum value of the data type of the sequence object.</p>
<p><strong>CYCLE | NO CYCLE :</strong></p>
<p>Property that specifies whether the sequence object should restart from the minimum value (or maximum for descending sequence objects) or throw an exception when its minimum or maximum value is exceeded. The default cycle option for new sequence objects is NO CYCLE.</p></blockquote>
<p><strong>How you assign the sequence object permission to the user?</strong></p>
<blockquote><p>
</p><pre class="crayon-plain-tag">GRANT CREATE SEQUENCE ON SCHEMA::Test TO [User]</pre><p>
Ownership of a sequence object can be transferred by using the ALTER AUTHORIZATION statement.</p></blockquote>
<p><strong>T-SQL Script to find the NEXT Value of the Sequence object?</strong></p><pre class="crayon-plain-tag">SELECT NEXT VALUE FOR db_name.seq_name;</pre><p>
<strong>T-SQL script to reset the value of Sequence object.</strong></p><pre class="crayon-plain-tag">ALTER SEQUENCE Sequence_Name RESTART WITH 1;</pre><p>
<strong>What is an execution plan? When would you use it? How would you view the execution plan?</strong></p>
<blockquote><p>An execution plan is basically a road map that graphically or textually shows the data retrieval methods chosen by the SQL server’s query optimizer for a stored procedure or ad hoc query. Execution plans are very useful for helping a developer understand and analyze the performance characteristics of a query or stored procedure, since the plan is used to execute the query or stored procedure.</p>
<p>In many SQL systems, a textual execution plan can be obtained using a keyword such as EXPLAIN, and visual representations can often be obtained as well. In Microsoft SQL Server, the Query Analyzer has an option called “Show Execution Plan” (located on the Query drop down menu). If this option is turned on, it will display query execution plans in a separate window when a query is run.</p></blockquote>
<p><strong>What are the NVL and the NVL2 functions in SQL? How do they differ?</strong></p>
<ul>
<li>Both the NVL(exp1, exp2) and NVL2(exp1, exp2, exp3) functions check the value exp1 to see if it is null.</li>
<li>With the NVL(exp1, exp2) function, if exp1 is not null, then the value of exp1 is returned; otherwise, the value of exp2 is returned, but case to the same data type as that of exp1.</li>
<li>With the NVL2(exp1, exp2, exp3) function, if exp1 is not null, then exp2 is returned; otherwise, the value of exp3 is returned.</li>
</ul>
<p><strong>Can a stored procedure call itself or recursive stored procedure? How much level SP nesting is possible?</strong></p>
<blockquote><p>Yes. Because Transact-SQL supports recursion, you can write stored procedures that call themselves. Recursion can be defined as a method of problem solving wherein the solution is arrived at by repetitively applying it to subsets of the problem. A common application of recursive logic is to perform numeric computations that lend themselves to repetitive evaluation by the same processing steps.</p>
<p>Stored procedures are nested when one stored procedure calls another or executes managed code by referencing a CLR routine, type, or aggregate. You can nest stored procedures and managed code references up to 32 levels.</p></blockquote>
<p><strong>How many columns can be created in a single table?</strong></p>
<blockquote><p>A normal table, can contain 1024 columns and wide table can contain 30,000 columns per table.</p></blockquote>
<p><strong>What is OPENXML in SQL Server?</strong></p>
<blockquote><p>OPENXML can parse the xml data in SQL SERVER very efficiently in SQL Server. OPENXML primarily gives the ability to insert XML data to the relational database, however we can query the data too using OpenXML. We need to specify the path of the xml element using xpath.</p></blockquote>
<p><strong>What do you know about the SQL Case statement?</strong></p>
<blockquote><p>The CASE Statement (more commonly known as the CASE Expression) allows you execute parts of a SQL statement conditionally. So, for example, you can use the CASE statement to format the results of the query conditionally – based on the values in another column.</p>
<p><strong>SQL CASE Syntax:</strong></p><pre class="crayon-plain-tag">CASE input_expression
WHEN conditional_expression1 THEN result_expression1
WHEN conditional_expression2 THEN result_expression2
ELSE result_expression
END;</pre><p>
</p></blockquote>
<p><strong>How you can copy unique records from one table to another in SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="urWhyevtw5"><p><a href="https://www.dbrnd.com/2015/06/copy-unique-records-from-one-table-to-another-sql-server/">Copy unique records from one table to another in SQL Server</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/06/copy-unique-records-from-one-table-to-another-sql-server/embed/#?secret=urWhyevtw5" data-secret="urWhyevtw5" width="600" height="338" title="&#8220;Copy unique records from one table to another in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Would you please provide me script to find all column default value information?</strong></p>
<blockquote class="wp-embedded-content" data-secret="irTqJ8UcLX"><p><a href="https://www.dbrnd.com/2015/10/sql-server-script-to-find-all-default-values-with-columns/">SQL Server: Script to find all Default values with Columns</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/sql-server-script-to-find-all-default-values-with-columns/embed/#?secret=irTqJ8UcLX" data-secret="irTqJ8UcLX" width="600" height="338" title="&#8220;SQL Server: Script to find all Default values with Columns&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-8)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-union-all-except-intersect-filestream-sub-co-related-query-day-8/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 19 Jun 2016 18:32:29 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[co-related query]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[EXCEPT]]></category>
		<category><![CDATA[intersect]]></category>
		<category><![CDATA[Interviews]]></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[sub queries]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[union]]></category>
		<category><![CDATA[union all]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3057</guid>

					<description><![CDATA[What type of bitwise operators available in SQL Server? &#38; (Bitwise AND) ~ (Bitwise NOT) &#124; (Bitwise OR) ^ (Bitwise Exclusive OR) What is the difference between UNION and UNION ALL? UNION: The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command [&#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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%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-union-all-except-intersect-filestream-sub-co-related-query-day-8%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-8%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-union-all-except-intersect-filestream-sub-co-related-query-day-8/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-8)"></a></p><p><strong>What type of bitwise operators available in SQL Server?</strong></p>
<ul>
<li>&amp; (Bitwise AND)</li>
<li>~ (Bitwise NOT)</li>
<li>| (Bitwise OR)</li>
<li>^ (Bitwise Exclusive OR)</li>
</ul>
<p><strong>What is the difference between UNION and UNION ALL?</strong></p>
<blockquote><p><strong>UNION:</strong></p>
<p>The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.</p>
<p><strong>UNION ALL:</strong></p>
<p>The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.</p>
<p>The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.</p></blockquote>
<p><strong>What is the use of EXCEPT Operator?</strong></p>
<blockquote><p>Use the EXCEPT Operator to return only rows found in the left query.  It returns unique rows from the left query that aren’t in the right query’s results.  This query is useful when you’re looking to find rows that are in one set but not another.</p></blockquote>
<p><strong>What is the use of INTERSECT Operator?</strong></p>
<blockquote><p>Use an intersect operator to returns rows that are in common between two tables; it returns unique rows from both the left and right query.  This query is useful when you want to find results that are in common between two queries.</p></blockquote>
<p><strong>Can you use LEN() function to calculate the length of TEXT, NText and other Binary data type?</strong></p>
<blockquote><p>No, we cannot use LEN() function for TEXT, Ntext, BLOB.</p>
<p>We should use DATALENGTH() for calculating length of TEXT, NText, BLOB.</p></blockquote>
<p><strong>Is it possible to import data directly from T-SQL commands without using SQL Server Integration Services?</strong></p>
<blockquote><p>Yes &#8211; Six commands are available to import data directly in the T-SQL language.</p>
<ul>
<li>BCP</li>
<li>Bulk Insert</li>
<li>OpenRowSet</li>
<li>OPENDATASOURCE</li>
<li>OPENQUERY</li>
<li>Linked Servers</li>
</ul>
</blockquote>
<p><strong>T-SQL Script to find object dependency in SQL Server.</strong></p>
<blockquote class="wp-embedded-content" data-secret="dKiT5heccZ"><p><a href="https://www.dbrnd.com/2015/06/sql-script-to-find-object-dependency-in-sql-server/">SQL Script to find Object Dependency in SQL Server</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/06/sql-script-to-find-object-dependency-in-sql-server/embed/#?secret=dKiT5heccZ" data-secret="dKiT5heccZ" width="600" height="338" title="&#8220;SQL Script to find Object Dependency in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>T-SQL Script to find cross database object dependency in SQL Server.</strong></p>
<blockquote class="wp-embedded-content" data-secret="CwYopGHa2w"><p><a href="https://www.dbrnd.com/2015/06/sql-script-to-find-cross-database-object-dependency-in-sql-server/">SQL Script to find Cross Database Object Dependency in SQL Server</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/06/sql-script-to-find-cross-database-object-dependency-in-sql-server/embed/#?secret=CwYopGHa2w" data-secret="CwYopGHa2w" width="600" height="338" title="&#8220;SQL Script to find Cross Database Object Dependency in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the FILESTREAM in SQL Server?</strong></p>
<blockquote><p>FILESTREAM enables SQL Server-based applications to store unstructured data, such as documents and images, on the file system. Applications can leverage the rich streaming APIs and performance of the file system and at the same time maintain transactional consistency between the unstructured data and corresponding structured data.</p>
<p>FILESTREAM integrates the SQL Server Database Engine with an NTFS file system by storing varbinary(max) binary large object (BLOB) data as files on the file system. Transact-SQL statements can insert, update, query, search, and back up FILESTREAM data.</p></blockquote>
<p><strong>What is the difference between a derived table and a subquery?</strong></p>
<blockquote><p>A subquery is a SELECT statement that is nested within another statement – that’s why it’s called a subquery, because it’s like having a query within another query . Subqueries are usually used in the WHERE clause as a way to filter out certain rows returned in the result set of the outer query.</p>
<p>A derived table is basically a subquery, except it is always in the FROM clause of a SQL statement. The reason it is called a derived table is because it essentially functions as a table as far as the entire query is concerned.</p></blockquote>
<p><strong>What is the co-related sub query?</strong></p>
<blockquote><p>The two queries, in other words the outer and the inner query, are dependent or linked to each other, to generate the final result set.</p>
<p>In a SQL database query, a correlated subquery also known as a synchronized subquery that uses values from the outer query. Because the subquery is evaluated once for each row processed by the outer query, it can be inefficient.</p></blockquote>
<p><strong>How query executed using co-related sub query?</strong></p>
<ul>
<li>First Outer query executes and submit values to the inner query.</li>
<li>Then, Inner query executes by using value returned by outer-query.</li>
<li>The condition applied on outer query checked.</li>
</ul>
<p><strong>What is the difference between a Nested Sub query and Co-related sub query?</strong></p>
<blockquote><p>Technical difference between Normal Sub-query and Co-related sub-query are:</p>
<p><strong>Looping:</strong></p>
<p>Co-related sub-query loop under main-query; whereas normal sub-query; therefore correlated Subquery executes on each iteration of main query. Whereas in case of Nested-query; Subquery executes first then outer query executes next. Hence, the maximum no. of executes are NXM for correlated subquery and N+M for subquery.</p>
<p><strong>Execution:</strong></p>
<p>Correlated uses feedback from outer query for execution whereas Nested Subquery provides feedback to Outerquery for execution. Hence, Correlated Subquery depends on outer query whereas Nested Sub-query does not.</p>
<p><strong>Performance:</strong></p>
<p>Using Co-related sub-query performance decreases, since, it performs NXM iterations instead of N+M iterations. ¨ Co-related Sub-query Execution.</p></blockquote>
<p><strong>What are the restrictions of SUB Query?</strong></p>
<ul>
<li>A Sub-Query cannot use DISTINCT key if it includes GROUP-BY</li>
<li>A Sub-Query cannot use COMPUTE and INTO clauses</li>
<li>A Sub-query can use ORDER-BY if it also have TOP()</li>
<li>A Sub-query generated view is cannot be Updated.</li>
<li>A Sub-query cannot includes the columns of type: NTEXT, TEXT, and IMAGE.</li>
<li>A Sub-query should be compared with using:</li>
<li>ANY, SOME, or ALL EXISTS or NOT EXISTS</li>
</ul>
<p><strong>What is the cardinality in SQL?</strong></p>
<blockquote><p>In SQL (Structured Query Language), the term cardinality refers to the uniqueness of data values contained in a particular column (attribute) of a database table. The lower the cardinality, the more duplicated elements in a column. Thus, a column with the lowest possible cardinality would have the same value for every row. SQL databases use cardinality to help determine the optimal query plan for a given query.</p></blockquote>
<p>&nbsp;</p>
<p><strong>Why are the selectivity and cardinality used in databases?</strong></p>
<blockquote><p>The selectivity basically is a measure of how much variety there is in the values of a given table column in relation to the total number of rows in a given table.</p>
<p>The cardinality is just part of the formula that is used to calculate the selectivity. Query optimizers use the selectivity to figure out if it is actually worth using an index to find certain rows in a table.</p>
<p>A general principle that is followed is that it is best to use an index when the number of rows that need to be selected is small in relation to the total number of rows. That is what the selectivity helps measure.</p></blockquote>
<p><strong>What is QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF?</strong></p>
<blockquote class="wp-embedded-content" data-secret="0aYiFUns2h"><p><a href="https://www.dbrnd.com/2015/10/sql-server-what-is-quoted_identifier-onoff-and-ansi_null-onoff/">SQL SERVER: What is QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/sql-server-what-is-quoted_identifier-onoff-and-ansi_null-onoff/embed/#?secret=0aYiFUns2h" data-secret="0aYiFUns2h" width="600" height="338" title="&#8220;SQL SERVER: What is QUOTED_IDENTIFIER ON/OFF and ANSI_NULL ON/OFF&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How you can clean buffer or cache for stored procedure?</strong></p>
<blockquote class="wp-embedded-content" data-secret="O5lJyI7KeV"><p><a href="https://www.dbrnd.com/2015/10/sql-server-dbcc-command-clean-cache-buffer-for-stored-procedure/">SQL Server: DBCC to Clean Cache and Clean Buffer for Stored Procedure</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/sql-server-dbcc-command-clean-cache-buffer-for-stored-procedure/embed/#?secret=O5lJyI7KeV" data-secret="O5lJyI7KeV" width="600" height="338" title="&#8220;SQL Server: DBCC to Clean Cache and Clean Buffer for Stored Procedure&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Do you know, how to create system stored procedure for make available to all Database?</strong></p>
<blockquote class="wp-embedded-content" data-secret="YExFzgr2DR"><p><a href="https://www.dbrnd.com/2016/02/sql-server-make-a-system-stored-procedure-for-available-to-all-databases/">SQL Server: Make a System Stored Procedure for Available to all Databases</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/02/sql-server-make-a-system-stored-procedure-for-available-to-all-databases/embed/#?secret=YExFzgr2DR" data-secret="YExFzgr2DR" width="600" height="338" title="&#8220;SQL Server: Make a System Stored Procedure for Available to all Databases&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
