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

<channel>
	<title>SQL Server Interview &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/category/sql-server-interview/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>Sat, 20 Apr 2019 18:41:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server Interview: How to remove New Line Character from a string?</title>
		<link>https://www.dbrnd.com/2019/04/sql-server-interview-how-to-remove-new-line-character-from-a-string/</link>
					<comments>https://www.dbrnd.com/2019/04/sql-server-interview-how-to-remove-new-line-character-from-a-string/#respond</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 29 Apr 2019 16:16:57 +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[Remove New Line character]]></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[String Operation]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7413</guid>

					<description><![CDATA[In this post, I am sharing a SQL Interview questions for Database Developer. If you are database fresher and working with SQL, you must prepare for string/date operations related questions and answers. One of the example questions is How to remove New Line Character from a string? Check the below sample code: [crayon-6a8f9e75c0d5d921949325/]]]></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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%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%2F2019%2F04%2Fsql-server-interview-how-to-remove-new-line-character-from-a-string%2F&#038;title=SQL%20Server%20Interview%3A%20How%20to%20remove%20New%20Line%20Character%20from%20a%20string%3F" data-a2a-url="https://www.dbrnd.com/2019/04/sql-server-interview-how-to-remove-new-line-character-from-a-string/" data-a2a-title="SQL Server Interview: How to remove New Line Character from a string?"></a></p><p>In this post, I am sharing a SQL Interview questions for Database Developer. If you are database fresher and working with SQL, you must prepare for string/date operations related questions and answers. </p>
<p>One of the example questions is How to remove New Line Character from a string?</p>
<p><strong>Check the below sample code:</strong></p><pre class="crayon-plain-tag">DECLARE @str VARCHAR(100)
SET @str = 'I am Database 
Engineer'

SELECT @str AS With_New_Line

With_New_Line
---------------------
I am Database 
Engineer

SELECT REPLACE(REPLACE(@str, CHAR(13), ''), CHAR(10), '') AS Without_New_Line

Without_New_Line
---------------------------
I am Database Engineer</pre><p> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2019/04/sql-server-interview-how-to-remove-new-line-character-from-a-string/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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>
		<item>
		<title>SQL Server Interview: What is the difference between TABLOCK and TABLOCKX?</title>
		<link>https://www.dbrnd.com/2018/03/sql-server-interview-what-is-the-difference-between-tablock-and-tablockx/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 21 Mar 2018 16:16:21 +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 lock]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></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[Table Lock]]></category>
		<category><![CDATA[TABLOCK]]></category>
		<category><![CDATA[TABLOCKX]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7253</guid>

					<description><![CDATA[Are you database developer? Are you looking for a job change or preparing for next interview? Then, You must know about the Database/Table lock related questions/practical solutions. SELECT *FROM Table_Name WITH (TABLOCK) VS SELECT *FROM Table_Name WITH (TABLOCKX) Sort answers like: TABLOCK means a shared lock (You can select the data anytime) TABLOCKX means an [&#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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&amp;linkname=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%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%2F03%2Fsql-server-interview-what-is-the-difference-between-tablock-and-tablockx%2F&#038;title=SQL%20Server%20Interview%3A%20What%20is%20the%20difference%20between%20TABLOCK%20and%20TABLOCKX%3F" data-a2a-url="https://www.dbrnd.com/2018/03/sql-server-interview-what-is-the-difference-between-tablock-and-tablockx/" data-a2a-title="SQL Server Interview: What is the difference between TABLOCK and TABLOCKX?"></a></p><p><em>Are you database developer?<br />
Are you looking for a job change or preparing for next interview?</em></p>
<p>Then, You must know about the Database/Table lock related questions/practical solutions. </p>
<p>SELECT *FROM Table_Name WITH (TABLOCK)<br />
VS<br />
SELECT *FROM Table_Name WITH (TABLOCKX)</p>
<p><strong>Sort answers like:</strong></p>
<blockquote><p>TABLOCK means a shared lock (You can select the data anytime)<br />
TABLOCKX means an exclusive lock (You can&#8217;t access the table until it finishes the execution)</p></blockquote>
<blockquote><p>TABLOCK is used for operations that do not change the data<br />
TABLOCKX is used for the data modification operations</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: Primary Key Column as Non Clustered Index, Non Primary Key Column as Clustered Index</title>
		<link>https://www.dbrnd.com/2018/03/sql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 10 Mar 2018 16:16:36 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[clustered index]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Nonclustered Index]]></category>
		<category><![CDATA[Primary key]]></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[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4236</guid>

					<description><![CDATA[In this post, I am sharing an important interview question for SQL Server Database Developer. The question is: Can we apply Non-clustered Index on Primary Key Column, Can we apply Clustered Index on Non-Primary key column? Last year we arranged a walk in interview for SQL Server Developer. I had taken around 19 f2f interviews [&#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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&amp;linkname=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" 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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&amp;linkname=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" 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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&amp;linkname=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" 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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&amp;linkname=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" 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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&amp;linkname=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" 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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&amp;linkname=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" 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%2F03%2Fsql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index%2F&#038;title=SQL%20Server%20Interview%3A%20Primary%20Key%20Column%20as%20Non%20Clustered%20Index%2C%20Non%20Primary%20Key%20Column%20as%20Clustered%20Index" data-a2a-url="https://www.dbrnd.com/2018/03/sql-server-interview-primary-key-column-as-non-clustered-index-non-primary-key-column-as-clustered-index/" data-a2a-title="SQL Server Interview: Primary Key Column as Non Clustered Index, Non Primary Key Column as Clustered Index"></a></p><p>In this post, I am sharing an important interview question for SQL Server Database Developer.</p>
<p><strong>The question is:</strong></p>
<blockquote><p><strong>Can we apply Non-clustered Index on Primary Key Column, Can we apply Clustered Index on Non-Primary key column?</strong></p></blockquote>
<blockquote><p>Last year we arranged a walk in interview for SQL Server Developer. I had taken around 19 f2f interviews and prepared list of questions for another 88 f2f interviews. </p></blockquote>
<blockquote><p>I asked this question to all 19 candidates and 16 candidates said, we cannot create a Non-clustered Index on Primary Key because Primary Key has a default Clustered Index.<br />
This is wrong, You can create Non-clustered Primary key and can apply Clustered Index on Non-Primary key column.</p></blockquote>
<p>The main reason for this confusion is, SQL Server creates default Clustered Index on the Primary Key column. </p>
<p><strong>Our answer should be like:</strong> <em>Yes, we can define Non-Clustered Primary key column and can define Clustered index on other Non-Primary Key column.</em></p>
<blockquote><p>But the best practice is to define a Primary Key as Clustered Index because Unique value + Physical Order of data returns good query performance.</p></blockquote>
<p>In most of the cases, we are joining data using our Primary Key column, but If we require our main joining on other Non-Primary column and also require records basis on that Non-Primary column data order, we should apply Clustered Index on that Non-Primary key column. </p>
<p><strong>T-SQL Script to create NonClustered Primary Key and Clustered Index Non-Primary key column:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_Students
(
	StudID INT 
	,StudName VARCHAR(20)
	,CONSTRAINT pk_tbl_Students_StudID PRIMARY KEY NONCLUSTERED (StudID)
)
GO

CREATE CLUSTERED INDEX idx_tbl_Students_StudName ON tbl_Students (StudName)
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: Difference between Sequence Object and Identity Column</title>
		<link>https://www.dbrnd.com/2018/03/sql-server-interview-difference-between-sequence-object-and-identity-column/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 08 Mar 2018 16:16:34 +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[IDENT_CURRENT]]></category>
		<category><![CDATA[Identity Column]]></category>
		<category><![CDATA[SCOPE_IDENTITY]]></category>
		<category><![CDATA[Sequence object]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4287</guid>

					<description><![CDATA[This is a common interview question for SQL Server Database Developer. SQL Database Developer must prepare for this. Sequence and identity, both used to generate an auto number, but the major difference is Identity is a table dependant and Sequence is independent of a table. A Sequence Object introduced in SQL Server 2012 and Identity [&#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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" 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%2F03%2Fsql-server-interview-difference-between-sequence-object-and-identity-column%2F&#038;title=SQL%20Server%20Interview%3A%20Difference%20between%20Sequence%20Object%20and%20Identity%20Column" data-a2a-url="https://www.dbrnd.com/2018/03/sql-server-interview-difference-between-sequence-object-and-identity-column/" data-a2a-title="SQL Server Interview: Difference between Sequence Object and Identity Column"></a></p><p>This is a common interview question for SQL Server Database Developer. SQL Database Developer must prepare for this.</p>
<p>Sequence and identity, both used to generate an auto number, but the major difference is Identity is a table dependant and Sequence is independent of a table.</p>
<blockquote><p>A Sequence Object introduced in SQL Server 2012 and Identity column introduced in SQL Server 6.0.</p></blockquote>
<blockquote><p>A Sequence is a User defined object and Identity column is a table property. </p></blockquote>
<blockquote><p> The same Sequence object can use with the multiple tables. The same Identity column cannot use with multiple tables, we can define identity column on each table individually. </p></blockquote>
<blockquote><p>If you define the same Sequence Object to multiple tables, it generates the sequence number database-wide and maintains a unique sequence number across the multiple tables. An Identity column generates a unique number at table only.</p></blockquote>
<blockquote><p>Sequence syntax (Start with 1 and Increment by 1):</p>
<pre class="crayon-plain-tag">CREATE SEQUENCE
  dbo.Sequence_Name AS INT
 START WITH 1
 INCREMENT BY 1
GO</pre> </p>
<p>Identity syntax (Start with 1 and Increment by 1):</p>
<pre class="crayon-plain-tag">CREATE TABLE dbo.Table_Name
( Id INT IDENTITY(1,1),
  Name VARCHAR(50) )
GO</pre>
</p></blockquote>
<blockquote><p>Check the next value of Sequence object:</p>
<pre class="crayon-plain-tag">SELECT (NEXT VALUE FOR dbo.Sequence_Name) AS SeqNextValue</pre> </p>
<p>Check the next value of Identity Column:</p>
<pre class="crayon-plain-tag">SELECT SCOPE_IDENTITY()</pre>
(write after use of Identity column)
</p></blockquote>
<blockquote><p>
Check the current value of Sequence Object:</p>
<pre class="crayon-plain-tag">SELECT Current_Value 
FROM Sys.Sequences 
WHERE name='Sequence_Name'</pre> </p>
<p>Check the current value of Identity Column:</p>
<pre class="crayon-plain-tag">SELECT IDENT_CURRENT('Table_Name') 
 AS 'IdentityCurrentValue'</pre>
</p></blockquote>
<blockquote><p>You can modify a Sequence object using ALTER Statement.</p>
<pre class="crayon-plain-tag">ALTER SEQUENCE dbo.Sequence_Name
RESTART WITH 100
INCREMENT BY 5
GO</pre> </p>
<p>You can only reset the value of an Identity column using DBCC CHECKIDENT().</p>
<pre class="crayon-plain-tag">DBCC CHECKIDENT('Table_Name', RESEED,100)</pre>
</p></blockquote>
<blockquote><p>In Sequence New values can be generated in an UPDATE statement, but in Identity new value cannot be generated in an UPDATE statement.</p></blockquote>
<blockquote><p>You can define a maximum value for Sequence Object (Using MAXVALUE). You cannot provide a maximum value to Identity Column.</p></blockquote>
<blockquote><p>Once your Sequence object reached to MAXVALUE, you can also define a CYCLE option to restart it from the beginning. You cannot restart an Identity column value.</p></blockquote>
<blockquote><p>You can also enable data CACHE for a Sequence Object. You cannot enable data CACHE for an Identity Column and it uses table related data cache. </p></blockquote>
<blockquote><p>A User must require an access permission for Sequence Object. For Identity column, User requires only table related permissions. </p></blockquote>
<blockquote><p>Performance wise, Identity column is 3x faster than Sequence object.</p></blockquote>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: Identify the main table name from SQL Queries</title>
		<link>https://www.dbrnd.com/2018/02/sql-server-interview-tell-me-the-main-table-name-from-sql-query/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 15 Feb 2018 16:16:15 +0000</pubDate>
				<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 Query]]></category>
		<category><![CDATA[SQL Server]]></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=7093</guid>

					<description><![CDATA[This interview post is for Database Fresher Candidates. Just check the below SQL Questions, you feel like this is very easy, and most of the DB Person already knew about it. I asked this simple question in one of the recent interviews, and I can&#8217;t explain those shocking answers in this post. I can tell [&#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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&amp;linkname=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" 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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&amp;linkname=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" 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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&amp;linkname=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" 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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&amp;linkname=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" 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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&amp;linkname=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" 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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&amp;linkname=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" 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%2F02%2Fsql-server-interview-tell-me-the-main-table-name-from-sql-query%2F&#038;title=SQL%20Server%20Interview%3A%20Identify%20the%20main%20table%20name%20from%20SQL%20Queries" data-a2a-url="https://www.dbrnd.com/2018/02/sql-server-interview-tell-me-the-main-table-name-from-sql-query/" data-a2a-title="SQL Server Interview: Identify the main table name from SQL Queries"></a></p><p>This interview post is for Database Fresher Candidates. </p>
<p>Just check the below SQL Questions, you feel like this is very easy, and most of the DB Person already knew about it. </p>
<p>I asked this simple question in one of the recent interviews, and I can&#8217;t explain those shocking answers in this post.<br />
I can tell you one thing is: In the database or SQL fundamentals, everything is a Table. </p>
<p><strong>Create a table with sample data:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_abc (id INT)
GO
INSERT INTO tbl_abc VALUES (1),(2)
GO</pre> </p>
<p><strong>SQL 1: Which is the table?</strong><br />
Ans: tbl_abc</p>
<pre class="crayon-plain-tag">SELECT *FROM tbl_abc
GO</pre> </p>
<p><strong>SQL 2: Which is the table?</strong><br />
Ans: T (derived table)</p>
<pre class="crayon-plain-tag">SELECT *
FROM
(
	SELECT *FROM tbl_abc
)AS T</pre> </p>
<p><strong>SQL 3: Which is the table?</strong><br />
Ans: T(a) (derived table)</p>
<pre class="crayon-plain-tag">SELECT *
FROM (
  VALUES(1),(2),(3)
) T(a)</pre> </p>
<p><strong>SQL 4: Which is the table?</strong><br />
Ans: T (derived table)</p>
<pre class="crayon-plain-tag">SELECT *
FROM (
	  SELECT * FROM tbl_abc 
	  WHERE ID = 1
  UNION ALL
	  SELECT * FROM tbl_abc
	  WHERE ID = 2
) T (derived table)</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: Revoke all permissions, Grant one Table to User</title>
		<link>https://www.dbrnd.com/2018/02/sql-server-interview-revoke-all-permissions-grant-one-table-to-user/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 12 Feb 2018 16:16:54 +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[GRANT]]></category>
		<category><![CDATA[REVOKE]]></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[Table Permission]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7079</guid>

					<description><![CDATA[How to revoke all permissions of a user and grant only one table to that user in SQL Server? If you are SQL DBA and planning for an interview, you should prepare for database security related interview questions. I already published, please check the below link. The Ultimate Page of the SQL Server Interview Questions [&#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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&amp;linkname=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" 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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&amp;linkname=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" 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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&amp;linkname=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" 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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&amp;linkname=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" 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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&amp;linkname=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" 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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&amp;linkname=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" 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%2F02%2Fsql-server-interview-revoke-all-permissions-grant-one-table-to-user%2F&#038;title=SQL%20Server%20Interview%3A%20Revoke%20all%20permissions%2C%20Grant%20one%20Table%20to%20User" data-a2a-url="https://www.dbrnd.com/2018/02/sql-server-interview-revoke-all-permissions-grant-one-table-to-user/" data-a2a-title="SQL Server Interview: Revoke all permissions, Grant one Table to User"></a></p><p><strong>How to revoke all permissions of a user and grant only one table to that user in SQL Server?</strong></p>
<p>If you are SQL DBA and planning for an interview, you should prepare for database security related interview questions. </p>
<p>I already published, please check the below link. </p>
<blockquote class="wp-embedded-content" data-secret="pSRYIoIsqV"><p><a href="https://www.dbrnd.com/sql-server-advance-important-interview-questions-answers-for-database-administrators-developers/">The Ultimate Page of the SQL Server Interview Questions &#038; Answers for Database Administrators and Developers</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/sql-server-advance-important-interview-questions-answers-for-database-administrators-developers/embed/#?secret=pSRYIoIsqV" data-secret="pSRYIoIsqV" width="600" height="338" title="&#8220;The Ultimate Page of the SQL Server Interview Questions &#038; Answers for Database Administrators and Developers&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>As a SQL DBA, operating with database permissions is a routine work like giving permission to ad-hoc users and modifying whenever it is required. </p>
<blockquote><p>Last year, I asked this question to a DBA, and I got an answer like &#8220;Remove the user and Create a new user with specific table permission.&#8221;<br />
What do you think? Is this correct answer? &#8211; Partially Yes&#8230; </p>
<p>Before removing a user, you should verify the created objects by that user and create a new user with the same old name.</p></blockquote>
<p><strong>But without doing this all, the answer can be the below script:</strong></p>
<p><strong>Stop access to all tables for a user:</strong></p>
<pre class="crayon-plain-tag">EXEC sp_msforeachtable "DENY ALL ON '?' TO [User_Name];"
GO</pre> </p>
<p><strong>Grant specific table permission:</strong></p>
<pre class="crayon-plain-tag">GRANT ALL ON [Schema_Name].[Table_Name] TO [User_Name]
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: Can we restore the only data file (.mdf file)?</title>
		<link>https://www.dbrnd.com/2018/01/sql-server-interview-can-we-restore-the-only-data-file-mdf-file/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 29 Jan 2018 16:16:49 +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[RESTORE FILE ONLY]]></category>
		<category><![CDATA[RESTORE MDF FILE]]></category>
		<category><![CDATA[SQL Backup]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Restore]]></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=7014</guid>

					<description><![CDATA[Sharing another interesting interview question in the category of SQL Server Database Backup and Restore. The question is: Can we restore the only data file (.mdf file) from the backup of SQL Server. The answer is: Yes, we can restore only .mdf file from the backup of SQL Server (.bak file) How? First get 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%2F2018%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&amp;linkname=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%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%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&amp;linkname=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%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%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&amp;linkname=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%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%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&amp;linkname=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%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%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&amp;linkname=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%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%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&amp;linkname=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%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%2F01%2Fsql-server-interview-can-we-restore-the-only-data-file-mdf-file%2F&#038;title=SQL%20Server%20Interview%3A%20Can%20we%20restore%20the%20only%20data%20file%20%28.mdf%20file%29%3F" data-a2a-url="https://www.dbrnd.com/2018/01/sql-server-interview-can-we-restore-the-only-data-file-mdf-file/" data-a2a-title="SQL Server Interview: Can we restore the only data file (.mdf file)?"></a></p><p>Sharing another interesting interview question in the category of SQL Server Database Backup and Restore.</p>
<blockquote><p><strong>The question is:</strong> Can we restore the only data file (.mdf file) from the backup of SQL Server.<br />
<strong>The answer is:</strong> Yes, we can restore only .mdf file from the backup of SQL Server (.bak file)</p></blockquote>
<p><strong>How?</strong></p>
<p><strong>First get the file id from the backup file:</strong><br />
execute below RESTORE and search fileID for the data file (.mdf file)<br />
In my case, fileID =1</p>
<pre class="crayon-plain-tag">RESTORE FILELISTONLY FROM DISK = 'D:\SQL Backup\TestBackup.bak'</pre> </p>
<p><strong>Use fileID for restoring only that file data file:</strong></p>
<pre class="crayon-plain-tag">RESTORE DATABASE TestBackupFROM DISK = 'D:\SQL Backup\TestBackup.bak'
WITH
       FILE = 1,
       RECOVERY</pre> </p>
<p><strong>Now, ready for Next Question:</strong></p>
<blockquote><p><strong>Question is:</strong> Can I bring the database into the ONLINE state without database log files?<br />
<strong>Answer is:</strong> No, not possible</p></blockquote>
<p>If you notice the above RESTORE DATABASE, I wrote RECOVERY which will force SQL Server to rebuild the transaction log and will bring the database in ONLINE state.</p>
<p><strong>All the best!</strong></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server Interview: How to get the User Name, who created Database Backup?</title>
		<link>https://www.dbrnd.com/2018/01/sql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 28 Jan 2018 16:16:16 +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 backup]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Database Restore]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[RESTORE HEADERONLY]]></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=6988</guid>

					<description><![CDATA[A typical interview question for SQL DBA is, How to get the User Name, who created Database Backup? Don&#8217;t prepare your self for the hard questions, I took many interviews, and most of the DBA doesn&#8217;t know about this basic info. (Including senior DBA) I already shared information about RESTORE HEADERONLY, but here I am [&#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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%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%2F01%2Fsql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly%2F&#038;title=SQL%20Server%20Interview%3A%20How%20to%20get%20the%20User%20Name%2C%20who%20created%20Database%20Backup%3F" data-a2a-url="https://www.dbrnd.com/2018/01/sql-server-interview-how-to-get-the-user-name-who-created-database-backup-restore-headeronly/" data-a2a-title="SQL Server Interview: How to get the User Name, who created Database Backup?"></a></p><p><strong>A typical interview question for SQL DBA is, How to get the User Name, who created Database Backup?</strong></p>
<p>Don&#8217;t prepare your self for the hard questions, I took many interviews, and most of the DBA doesn&#8217;t know about this basic info. (Including senior DBA)</p>
<p>I already shared information about RESTORE HEADERONLY, but here I am again sharing the direct question and answer which is useful for interviews. </p>
<p>If you want to know any information about database backup, without restoring the database you can get those details using RESTORE HEADERONLY. </p>
<p><strong>Check the below command:</strong><br />
This is my test backup path, in the result, you can get a column like a UserName which who created the database backup. </p>
<pre class="crayon-plain-tag">RESTORE HEADERONLY FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL13.DBRND\MSSQL\BACKUP\dbrnd.bak'</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
