<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sql interview questions &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/sql-interview-questions/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>Thu, 03 May 2018 18:19:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.5</generator>
	<item>
		<title>SQL Server Interview: How to insert the data into Multiple Tables?</title>
		<link>https://www.dbrnd.com/2018/05/sql-server-interview-how-to-insert-the-data-into-multiple-tables/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 10 May 2018 16:16:19 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[sql interview questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7531</guid>

					<description><![CDATA[If you are a SQL Database Developer, the interviewer may ask this question. How to insert the data into Multiple tables, in addition, please do using a single query only. Look like a simple question, but it is not. There are no multiple options for this exercise because INSERT is a DML statement and it [&#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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" 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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" 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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" 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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" 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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" 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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" 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%2F2018%2F05%2Fsql-server-interview-how-to-insert-the-data-into-multiple-tables%2F&#038;title=SQL%20Server%20Interview%3A%20How%20to%20insert%20the%20data%20into%20Multiple%20Tables%3F" data-a2a-url="https://www.dbrnd.com/2018/05/sql-server-interview-how-to-insert-the-data-into-multiple-tables/" data-a2a-title="SQL Server Interview: How to insert the data into Multiple Tables?"></a></p><p>If you are a SQL Database Developer, the interviewer may ask this question.<br />
How to insert the data into Multiple tables, in addition, please do using a single query only. </p>
<p>Look like a simple question, but it is not. There are no multiple options for this exercise because INSERT is a DML statement and it has to run in transaction block at a time. </p>
<p><strong>Check few below options:</strong></p>
<p><strong>Create sample tables:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_A (ID INT)
CREATE TABLE tbl_B (ID INT)</pre> </p>
<p><strong>Approach 1:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_A  
OUTPUT INSERTED.ID
INTO tbl_B 
SELECT 1</pre> </p>
<p><strong>Approach 2:</strong><br />
 Using stored procedure, we should control this kind of request.</p>
<pre class="crayon-plain-tag">CREATE PROCEDURE usp_InsertAll (@ID INT)
AS
BEGIN
INSERT INTO tbl_A VALUES (@ID)
INSERT INTO tbl_B VALUES (@ID)
END
GO

EXEC usp_InsertALL 2
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: Is NULL = NULL valid condition?</title>
		<link>https://www.dbrnd.com/2018/05/sql-server-interview-is-null-null-valid-condition/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 07 May 2018 16:16:00 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[sql interview questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Interviews]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7533</guid>

					<description><![CDATA[If you are a SQL Database Developer, you might be writing some condition like WHERE 1=1 or WHERE 1=2. Here, I simply modified it and instead of WHERE 1=1 what do you think about WHERE NULL=NULL. Last year, I asked this question and most of the developers were confused. Actually, NULL = NULL returns nothing [&#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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&amp;linkname=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" 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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&amp;linkname=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" 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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&amp;linkname=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" 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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&amp;linkname=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" 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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&amp;linkname=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" 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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&amp;linkname=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" 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%2F2018%2F05%2Fsql-server-interview-is-null-null-valid-condition%2F&#038;title=SQL%20Server%20Interview%3A%20Is%20NULL%20%3D%20NULL%20valid%20condition%3F" data-a2a-url="https://www.dbrnd.com/2018/05/sql-server-interview-is-null-null-valid-condition/" data-a2a-title="SQL Server Interview: Is NULL = NULL valid condition?"></a></p><p>If you are a SQL Database Developer, you might be writing some condition like WHERE 1=1 or WHERE 1=2.<br />
Here, I simply modified it and instead of WHERE 1=1 what do you think about WHERE NULL=NULL. </p>
<p>Last year, I asked this question and most of the developers were confused. Actually, NULL = NULL returns nothing because NULL is not a real value. </p>
<p><strong>Check the below demonstration: </strong></p>
<p><strong>Create a table:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Employee (EmpID INT, EmpName VARCHAR(10), DOB DATE)

INSERT INTO tbl_Employee VALUES
(1,'Anvesh','19880126'),(2,'Jenny','19910409'),(3,'Alpesh','19930610')
,(4,'Roy','19910214'),(5,'Manish','19850505'),(6,'Nupur','19880808')</pre> </p>
<p><strong>Returns all records:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_Employee
WHERE 1=1</pre> </p>
<p><strong>Returns nothing:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM tbl_Employee
WHERE NULL=NULL</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
