<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6862796996491954502</id><updated>2024-10-20T10:13:03.871+05:30</updated><title type='text'>SQL Server Answer</title><subtitle type='html'>SQL Server interview questions and answers were original published in this blog. This complete blog is combined in one article which is listed here in this article. &#xa;&#xa;Interview Questions and Answer contains questions from beginner to advance users.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-6136622932027682407</id><published>2010-04-15T14:36:00.000+05:30</published><updated>2010-04-15T14:36:37.716+05:30</updated><title type='text'>SQL Server 2005 Isolation Levels</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: arial,helvetica,sans-serif; font-size: 12px; text-align: left;&quot;&gt;1) Read Uncommited&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;2) Read&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;commited &lt;/span&gt;with locking&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;3) Read&lt;span class=&quot;Apple-converted-space&quot;&gt; commited &lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&lt;/span&gt;with snapshot&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;4) Repeatable Read&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;5) Snapshot&lt;br style=&quot;margin: 0px; padding: 0px;&quot; /&gt;6) Serializable&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/6136622932027682407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2010/04/sql-server-2005-isolation-levels.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/6136622932027682407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/6136622932027682407'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2010/04/sql-server-2005-isolation-levels.html' title='SQL Server 2005 Isolation Levels'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-2412439181682786943</id><published>2010-04-03T17:01:00.003+05:30</published><updated>2010-04-03T17:01:52.988+05:30</updated><title type='text'>Difference Between varchar and nvarchar</title><content type='html'>&lt;div class=&quot;ContentToDisplay&quot;&gt;&lt;span id=&quot;ctl00_ContentPlaceHolder1_lblDescription&quot; style=&quot;color: darkblue;&quot;&gt;Varchar means Variable-length Character string. Nvarchar will store Unicode characters. Both will be used all most for the same purpose but with little difference. Varchar will store the 8-bit data in database where as Nvarchar will be stored as 16-bit data in Database.&lt;br /&gt;
In Sql server 2005&lt;br /&gt;
&lt;br /&gt;
The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters. This in turn limits the maximum size of a VARCHAR to 8,000 bytes.&lt;br /&gt;
Varchar (MAX) and Nvarchar (MAX). Varchar (MAX) can hold max of 2,147,483,648 characters and NVARCHAR (MAX) can hold 1,073,741,823 characters. We use Varchar instead of TEXT and NTEXT which cannot be used to passed as variables in a stored procedure where as Varchar (MAX) or Nvarchar (MAX) cannot have such restriction.&lt;br /&gt;
If you&#39;re in the process of migrating an existing data design for SQL Server 2005, it might make sense to migrate some TEXT / NTEXT fields to VARCHAR (MAX) / NVARCHAR (MAX) types when appropriate.&lt;br /&gt;
&lt;br /&gt;
If you need Unicode support for a given data type, either now or soon enough, go with NVARCHAR. If you&#39;re sticking with 8-bit data for design or storage reasons, go with VARCHAR. Note that you can always migrate from VARCHAR to NVARCHAR at the cost of some room -- but you can&#39;t go the other way &#39;round. Also, because NVARCHAR involves fetching that much more data, it may prove to be slower depending on how many table pages must be retrieved for any given operation.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: darkblue;&quot;&gt;varchar uses 8 bits per character. nvarchar is UNICODE, a double-byte character set, requiring 16 bits to store each character. UNICODE can handle languages that are difficult to impossible with single-byte&lt;br /&gt;
character sets such as ASCII. If you must support many languages UNICODE is a very clean way to do it.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/2412439181682786943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2010/04/difference-between-varchar-and-nvarchar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/2412439181682786943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/2412439181682786943'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2010/04/difference-between-varchar-and-nvarchar.html' title='Difference Between varchar and nvarchar'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-7092703706815540517</id><published>2010-03-31T15:57:00.000+05:30</published><updated>2010-03-31T15:57:39.078+05:30</updated><title type='text'>How to Create a temporary table</title><content type='html'>Creating a temporary table is virtually the same as creating a normal    table. The main exception is the naming of the table. A hash (&#39;&lt;code&gt;#&lt;/code&gt;&#39;) character    as the first character in the table name denotes that it is a temporary    table.&lt;br /&gt;
There are two types of temporary tables, local and global.&lt;br /&gt;
A local temporary table has a single hash (&#39;&lt;code&gt;#&lt;/code&gt;&#39;) at the start    of its name. A local temporary table is visible only to the user who created    it and is destroyed automatically when that user disconnects.&lt;br /&gt;
A global temporary table is denoted by a name starting with two hashes    (i.e. &#39;&lt;code&gt;##&lt;/code&gt;&#39;). A global temporary table is visible to all users    and is deleted automatically when the last user who has referenced the table    disconnects.&lt;br /&gt;
An example of creating a local temporary table:&lt;br /&gt;
&lt;blockquote&gt;    &lt;code&gt;create table #foo&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CarIndex&amp;nbsp; smallint,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CarType&amp;nbsp;&amp;nbsp; varchar(20)&lt;br /&gt;
)&lt;/code&gt;&lt;br /&gt;
&lt;/blockquote&gt;An example of creating a global temporary table:&lt;br /&gt;
&lt;blockquote&gt;    &lt;code&gt;create table ##baz&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CarIndex&amp;nbsp; smallint,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CarType&amp;nbsp;&amp;nbsp; varchar(20)&lt;br /&gt;
)&lt;/code&gt;&lt;br /&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/7092703706815540517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2010/03/how-to-create-temporary-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/7092703706815540517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/7092703706815540517'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2010/03/how-to-create-temporary-table.html' title='How to Create a temporary table'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-7976396109250467148</id><published>2010-03-31T15:55:00.000+05:30</published><updated>2010-03-31T15:55:12.586+05:30</updated><title type='text'>INDEX in Sql Server 2005</title><content type='html'>Indexes may be either Clustered or Non-Clustered&lt;br /&gt;
&lt;h4&gt;Clustered Index&amp;nbsp;&lt;/h4&gt;Every table can have one and only Clustered Index because index is built on unique key columns and the key values in data rows is unique.&amp;nbsp;It stores the data rows in table based on its key values. Table having clustered index also called as clustered table.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Non-Clustered Index &lt;/h4&gt;It has structure different from the data rows. Key value of non clustered index is used for pointing data rows containing key values. This value is known as row locator. Type of storage of data pages determines the structure of this row Locator. Row locator becomes pointer if these data pages stored as a heap. As well as row locator becomes a clustered index key if data page is stored in clustered table.&lt;br /&gt;
&lt;br /&gt;
Both of these may be unique. Wherever we make changes to the data table, managing of indexes is done automatically.&lt;br /&gt;
&lt;br /&gt;
SQL Server allows us to add non-key column at the leaf node of the non clustered index by passing current index key limit and to execute fully covered index query.&lt;br /&gt;
&lt;br /&gt;
Automatic index is created wherever we create primary key, unique key constraints to table.&lt;br /&gt;
&lt;h3&gt;The Query Optimizer&lt;/h3&gt;Query Optimizer indexes to reduce operations of disk input-output and using of system resources when we fire query on data. Data manipulation Query statements (like SELECT, DELETE OR UPDATE) need indexes for maximization of the performance. When Query fires the most efficient method for retrieval of the data is evaluated among available methods. It uses table scans or index scans. &lt;br /&gt;
&lt;br /&gt;
Table scans uses many Input-output operations, it also uses large number of resources as all rows from the table are scanned. &lt;br /&gt;
&lt;br /&gt;
Index scan used for searching index key columns to find storage location. &lt;br /&gt;
The index containing fewer columns results in to faster query execution and vice-versa.&lt;br /&gt;
&lt;h3&gt;Creating an Index &lt;/h3&gt;1. Connect to Northwind database from Object Explorer, right click on the &lt;strong&gt;Customers&lt;/strong&gt; table to create an index and click on &lt;strong&gt;modify&lt;/strong&gt;.&lt;br /&gt;
&amp;nbsp;2. Click on &lt;strong&gt;Index/Keys&lt;/strong&gt; from &lt;strong&gt;Table Desinger&lt;/strong&gt; Menu on top or right click on any column and click on &lt;strong&gt;Index/Keys&lt;/strong&gt;.&lt;br /&gt;
3. Click on &lt;strong&gt;Add&lt;/strong&gt; from &lt;strong&gt;Indexes/Keys&lt;/strong&gt; dialog box.&lt;br /&gt;
4. From Selected &lt;strong&gt;Primary/Unique Key or Index list, &lt;/strong&gt;select the new index and set properties for the index in the grid on right hand side.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Now just specify other settings if any for the index and click &lt;strong&gt;Close&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;When we save the table, the index is created in the database. &lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;Creating Unique Index &lt;/h3&gt;SQL Server permits us to create Unique Indexes on columns which are unique to identify.&amp;nbsp;(like employee’s Reference ID, Email-id etc.) We use set of columns to create unique index.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Right-click on the Customers and click &lt;strong&gt;Modify&lt;/strong&gt; in &lt;strong&gt;Object Explorer&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;Now, click on &lt;strong&gt;Indexes/Keys&lt;/strong&gt; from &lt;strong&gt;Table Designer&lt;/strong&gt; menu and click on Click &lt;strong&gt;Add&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;The Selected Primary/Unique Key or Index list displays the automatically generated name of the new index.&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;In the grid, click on &lt;strong&gt;Type&lt;/strong&gt;, from the drop-down list, Choose &lt;strong&gt;Index&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;Under Column name,we can choose columns we want to index and click on OK. Maximum we can setup 16 columns. For optimum performance, it is recommended that we use one or two columns per index. For every column we values of these columns are arranged in ascending or descending order. &amp;nbsp;&lt;/li&gt;
&lt;li&gt;In the grid, click Is &lt;strong&gt;Unique&lt;/strong&gt; and select select &lt;strong&gt;Yes.&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Null is treated as duplicate values. So, it is not possible to create unique index on one column if it contains null in more than one row. Likewise index cannot be created on multiple columns if those columns contains null in same row.&lt;/li&gt;
&lt;li&gt;Now select Ignore duplicate keys option. If it is required to ignore new or updated data that will lead to creation of duplicate key in the index (with the INSERT or UPDATE statement). &lt;/li&gt;
&lt;li&gt;When we save the table, the index is created in the database.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Creating Clustered Index&lt;/h2&gt;table can have only one clustered index. In Clustered index logical order and physical order of the index key values is identical of rows in the table. &lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In the &lt;strong&gt;Object Explorer&lt;/strong&gt; click on the Northwind database, right click on the Customres to create an index and click on &lt;strong&gt;modify.&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Now we have &lt;strong&gt;Table Designer&lt;/strong&gt; for the table. &lt;/li&gt;
&lt;li&gt;From the Table Designer menu, click &lt;strong&gt;Indexes/Keys&lt;/strong&gt; and from Indexes/Keys dialog box, click Add.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Now from Selected &lt;strong&gt;Primary/Unique Key or Index list&lt;/strong&gt;, Select the new index&lt;/li&gt;
&lt;li&gt;In the grid, select Create as &lt;strong&gt;Clustered&lt;/strong&gt;, and choose Yes from the drop-down list to the right of the property.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;When we save the table, the index is created in the database.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/7976396109250467148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2010/03/index-in-sql-server-2005.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/7976396109250467148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/7976396109250467148'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2010/03/index-in-sql-server-2005.html' title='INDEX in Sql Server 2005'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-6014683783825364153</id><published>2009-12-01T17:38:00.002+05:30</published><updated>2009-12-01T17:39:07.963+05:30</updated><title type='text'>How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.&lt;br /&gt;One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.&lt;br /&gt;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.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/6014683783825364153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/how-to-implement-one-to-one-one-to-many.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/6014683783825364153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/6014683783825364153'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/how-to-implement-one-to-one-one-to-many.html' title='How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-8615707822898650612</id><published>2009-12-01T17:38:00.001+05:30</published><updated>2009-12-01T17:38:31.599+05:30</updated><title type='text'>What is cursors?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 0px; line-height: 1.6em; text-align: justify; &quot;&gt;Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 0px; line-height: 1.6em; text-align: justify; &quot;&gt;In order to work with a cursor we need to perform some steps in the following order:&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 40px; line-height: 1.6em; text-align: justify; &quot;&gt;Declare cursor&lt;br /&gt;Open cursor&lt;br /&gt;Fetch row from the cursor&lt;br /&gt;Process fetched row&lt;br /&gt;Close cursor&lt;br /&gt;Deallocate cursor&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/8615707822898650612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-cursors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8615707822898650612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8615707822898650612'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-cursors.html' title='What is cursors?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-4754945622605376382</id><published>2009-12-01T17:35:00.004+05:30</published><updated>2009-12-01T17:36:10.121+05:30</updated><title type='text'>What is Index?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 0px; line-height: 1.6em; text-align: justify; &quot;&gt;An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 0px; line-height: 1.6em; text-align: justify; &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: italic; &quot;&gt;Clustered indexes&lt;/span&gt; define the physical sorting of a database table’s rows in the storage media. For this reason, each database table may have only one clustered index.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: italic; &quot;&gt;Non-clustered indexes&lt;/span&gt; are created outside of the database table and contain a sorted list of references to the table itself.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/4754945622605376382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-index.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/4754945622605376382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/4754945622605376382'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-index.html' title='What is Index?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-3812514268620275452</id><published>2009-12-01T17:35:00.003+05:30</published><updated>2009-12-01T17:35:52.205+05:30</updated><title type='text'>What is View?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;&lt;span class=&quot;main&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table.&lt;/span&gt; The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/3812514268620275452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-view.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3812514268620275452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3812514268620275452'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-view.html' title='What is View?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-252629469811573205</id><published>2009-12-01T17:35:00.001+05:30</published><updated>2009-12-01T17:35:30.165+05:30</updated><title type='text'>What is Trigger?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS.Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-style: italic; &quot;&gt;Nested Trigger: &lt;/span&gt;A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/252629469811573205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-trigger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/252629469811573205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/252629469811573205'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-trigger.html' title='What is Trigger?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-7306877713586500039</id><published>2009-12-01T17:34:00.002+05:30</published><updated>2009-12-01T17:35:10.375+05:30</updated><title type='text'>What is Stored Procedure?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.&lt;br /&gt;e.g. sp_helpdb, sp_renamedb, sp_depends etc.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/7306877713586500039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-stored-procedure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/7306877713586500039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/7306877713586500039'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-stored-procedure.html' title='What is Stored Procedure?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-2973585322909169418</id><published>2009-12-01T17:34:00.001+05:30</published><updated>2009-12-01T17:34:51.377+05:30</updated><title type='text'>What are different normalization forms?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; color: rgb(51, 51, 51); line-height: 19px; &quot;&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 0px; line-height: 1.6em; text-align: justify; &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;1NF: Eliminate Repeating Groups&lt;/span&gt;&lt;br /&gt;Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;2NF: Eliminate Redundant Data&lt;/span&gt;&lt;br /&gt;If an attribute depends on only part of a multi-valued key, remove it to a separate table.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;3NF: Eliminate Columns Not Dependent On Key &lt;/span&gt;&lt;br /&gt;If attributes do not contribute to a description of the key, remove them to a separate table. &lt;/span&gt;All attributes must be directly dependent on the primary key&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;BCNF: Boyce-Codd Normal Form&lt;/span&gt;&lt;br /&gt;If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;4NF: Isolate Independent Multiple Relationships&lt;/span&gt;&lt;br /&gt;No table may contain two or more 1:n or n:m relationships that are not directly related.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;5NF: Isolate Semantically Related Multiple Relationships &lt;/span&gt;&lt;br /&gt;There may be practical constrains on information that justify separating logically related many-to-many relationships.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;ONF: Optimal Normal Form&lt;/span&gt;&lt;br /&gt;A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.&lt;br /&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-weight: bold; font-style: italic; &quot;&gt;DKNF: Domain-Key Normal Form&lt;/span&gt;&lt;br /&gt;A model free from all modification anomalies.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.7em; margin-right: 0px; margin-bottom: 0.7em; margin-left: 0px; line-height: 1.6em; text-align: justify; &quot;&gt;Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/2973585322909169418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-different-normalization-forms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/2973585322909169418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/2973585322909169418'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-different-normalization-forms.html' title='What are different normalization forms?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-8159970245051139189</id><published>2009-12-01T17:28:00.000+05:30</published><updated>2009-12-01T17:30:58.338+05:30</updated><title type='text'>What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;&quot;&gt;Cursors allow row-by-row prcessing of the resultsets.&lt;br /&gt;&lt;br /&gt;Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.&lt;br /&gt;&lt;br /&gt;Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.&lt;br /&gt;&lt;br /&gt;Most of the times, set based operations can be used instead of cursors. Here is an example:&lt;br /&gt;&lt;br /&gt;If you have to give a flat hike to your employees using the following criteria:&lt;br /&gt;&lt;br /&gt;Salary between 30000 and 40000 -- 5000 hike&lt;br /&gt;Salary between 40000 and 55000 -- 7000 hike&lt;br /&gt;Salary between 55000 and 65000 -- 9000 hike&lt;br /&gt;&lt;br /&gt;In this situation many developers tend to use a cursor, determine each employee&#39;s salary and update his salary according to the above formula. But the same can be achieved by multiple update statements or can be combined in a single UPDATE statement as shown below:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:Courier New;font-size:85%;color:#0000FF;&quot;&gt;UPDATE tbl_emp SET salary =&lt;br /&gt;CASE WHEN salary BETWEEN 30000 AND 40000 THEN salary + 5000&lt;br /&gt;WHEN salary BETWEEN 40000 AND 55000 THEN salary + 7000&lt;br /&gt;WHEN salary BETWEEN 55000 AND 65000 THEN salary + 10000&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;&quot;&gt;Another situation in which developers tend to use cursors: You need to call a stored procedure when a column in a particular row meets certain condition. You don&#39;t have to use cursors for this. This can be achieved using WHILE loop, as long as there is a unique key to identify each row. For examples of using WHILE loop for row by row processing, check out the &#39;&lt;/span&gt;&lt;a href=&quot;http://vyaskn.tripod.com/code.htm&quot; style=&quot;text-decoration: none; color: rgb(128, 128, 255); &quot;&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;color:#0000FF;&quot;&gt;My code library&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;&quot;&gt;&#39; section of my site or &lt;/span&gt;&lt;a href=&quot;http://vyaskn.tripod.com/search.htm&quot; style=&quot;text-decoration: none; color: rgb(128, 128, 255); &quot;&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;color:#0000FF;&quot;&gt;search&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;&quot;&gt; for WHILE.&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/8159970245051139189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-cursors-explain-different.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8159970245051139189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8159970245051139189'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-cursors-explain-different.html' title='What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-5655480753449601151</id><published>2009-12-01T17:27:00.001+05:30</published><updated>2009-12-01T17:27:58.682+05:30</updated><title type='text'>Explian different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about choosing a backup plan?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;Types of backups you can create in SQL Sever 7.0+ are Full database backup, differential database backup, transaction log backup, filegroup backup. Check out the BACKUP and RESTORE commands in SQL Server books online&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/5655480753449601151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/explian-different-types-of-backups.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5655480753449601151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5655480753449601151'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/explian-different-types-of-backups.html' title='Explian different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about choosing a backup plan?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-8639041674781259675</id><published>2009-12-01T17:26:00.000+05:30</published><updated>2009-12-01T17:27:11.409+05:30</updated><title type='text'>How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;SQL Server can be started from command line, using the SQLSERVR.EXE. This EXE has some very important parameters with which a DBA should be familiar with. -m is used for starting SQL Server in single user mode and -f is used to start the SQL Server in minimal confuguration mode. Check out SQL Server books online for more parameters and their explanations.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/8639041674781259675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/how-to-restart-sql-server-in-single.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8639041674781259675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8639041674781259675'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/how-to-restart-sql-server-in-single.html' title='How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-5126725366706261977</id><published>2009-12-01T17:25:00.002+05:30</published><updated>2009-12-01T17:26:15.413+05:30</updated><title type='text'>Explain CREATE DATABASE syntax</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;Many of us are used to craeting databases from the Enterprise Manager or by just issuing the command: CREATE DATABAE MyDB. But what if you have to create a database with two filegroups, one on drive C and the other on drive D with log on drive E with an initial size of 600 MB and with a growth factor of 15%? That&#39;s why being a DBA you should be familiar with the CREATE DATABASE syntax. Check out SQL Server books online for more information.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/5126725366706261977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/explain-create-database-syntax.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5126725366706261977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5126725366706261977'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/explain-create-database-syntax.html' title='Explain CREATE DATABASE syntax'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-1075628269951254462</id><published>2009-12-01T17:25:00.001+05:30</published><updated>2009-12-01T17:25:17.909+05:30</updated><title type='text'>What is a deadlock and what is a live lock? How will you go about resolving deadlocks?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other&#39;s piece. Each process  would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user&#39;s process.&lt;br /&gt;&lt;br /&gt;A livelock is one, where a  request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.&lt;br /&gt;&lt;br /&gt;Check out SET DEADLOCK_PRIORITY and &quot;Minimizing Deadlocks&quot;  in SQL Server books online. Also check out the article Q169960 from Microsoft knowledge base.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/1075628269951254462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-deadlock-and-what-is-live-lock.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/1075628269951254462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/1075628269951254462'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-deadlock-and-what-is-live-lock.html' title='What is a deadlock and what is a live lock? How will you go about resolving deadlocks?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-3540690888741116206</id><published>2009-12-01T17:24:00.001+05:30</published><updated>2009-12-01T17:24:29.628+05:30</updated><title type='text'>What are constraints? Explain different types of constraints.</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;Constraints enable the RDBMS enforce the integrity of the database automatically, without needing you to create triggers, rule or defaults.&lt;br /&gt;&lt;br /&gt;Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY&lt;br /&gt;&lt;br /&gt;For an explanation of these constraints see books online for the pages titled: &quot;Constraints&quot; and &quot;CREATE TABLE&quot;, &quot;ALTER TABLE&quot;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/3540690888741116206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-constraints-explain-different.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3540690888741116206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3540690888741116206'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-constraints-explain-different.html' title='What are constraints? Explain different types of constraints.'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-3099491554237417345</id><published>2009-12-01T17:23:00.000+05:30</published><updated>2009-12-01T17:24:03.950+05:30</updated><title type='text'>Whar is an index? What are the types of indexes? How many clustered indexes can be created on a table? I create a separate index on each column of a t</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.&lt;br /&gt;&lt;br /&gt;Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it&#39;s row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.&lt;br /&gt;&lt;br /&gt;If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/3099491554237417345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/whar-is-index-what-are-types-of-indexes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3099491554237417345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3099491554237417345'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/whar-is-index-what-are-types-of-indexes.html' title='Whar is an index? What are the types of indexes? How many clustered indexes can be created on a table? I create a separate index on each column of a t'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-877532739052778485</id><published>2009-12-01T17:22:00.001+05:30</published><updated>2009-12-01T17:22:46.235+05:30</updated><title type='text'>What&#39;s the difference between a primary key and a unique key?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn&#39;t allow NULLs, but unique key allows one NULL only.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/877532739052778485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/whats-difference-between-primary-key.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/877532739052778485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/877532739052778485'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/whats-difference-between-primary-key.html' title='What&#39;s the difference between a primary key and a unique key?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-5164513638354391164</id><published>2009-12-01T17:21:00.000+05:30</published><updated>2009-12-01T17:22:18.481+05:30</updated><title type='text'>How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;MS Serif&#39;; font-size: small; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; &quot;&gt;One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.&lt;br /&gt;One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.&lt;br /&gt;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.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/5164513638354391164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/how-do-you-implement-one-to-one-one-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5164513638354391164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5164513638354391164'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/how-do-you-implement-one-to-one-one-to.html' title='How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-451286509677697408</id><published>2009-12-01T17:16:00.001+05:30</published><updated>2009-12-01T17:16:25.175+05:30</updated><title type='text'>What are defaults? Is there a column to which a default can&#39;t be bound?</title><content type='html'>&lt;p align=&quot;left&quot;&gt;&lt;span style=&quot;font-family:MS Serif;font-size:85%;&quot;&gt;A default         is a value that will be used by a column, if no value is         supplied to that column while inserting data. IDENTITY columns and timestamp columns         can&#39;t have defaults bound to them. See CREATE DEFUALT in         books online.&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/451286509677697408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-defaults-is-there-column-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/451286509677697408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/451286509677697408'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-are-defaults-is-there-column-to.html' title='What are defaults? Is there a column to which a default can&#39;t be bound?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-4447435867577392583</id><published>2009-12-01T17:15:00.001+05:30</published><updated>2009-12-01T17:15:59.961+05:30</updated><title type='text'>Define candidate key, alternate key, composite key</title><content type='html'>&lt;span style=&quot;font-family:MS Serif;font-size:85%;&quot;&gt;A         candidate key is one that can identify each row of a         table uniquely. Generally a candidate key becomes the         primary key of the table. If the table has more than one         candidate key, one of them will become the primary key,         and the rest are called alternate keys.&lt;br /&gt;       &lt;br /&gt;        A key formed by combining at least two or more columns is         called composite key.&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/4447435867577392583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/define-candidate-key-alternate-key.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/4447435867577392583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/4447435867577392583'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/define-candidate-key-alternate-key.html' title='Define candidate key, alternate key, composite key'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-3729637221303012778</id><published>2009-12-01T17:10:00.001+05:30</published><updated>2009-12-01T17:10:54.028+05:30</updated><title type='text'>What is Replication? What is the need to have the replication? What are the enhancements made to SQL Server 2005 related to the replication?</title><content type='html'>&lt;p&gt;“Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency.” In short, replication is all about having multiple copies of the same database. We need replication when we need to distribute data to and from different locations. Generally we have a master copy of data. There will be multiple slaves (Clients) located at various locations which need to be replicated. We use replication for a variety of reasons. Load balancing is sharing the data among a number of servers and distributing the query load. Offline processing is one of the main reasons. In this scenario we need to modify the data on the database that is not connected to the network. The last reason may be to have a back-up to the database in case of failure to the existing database. Let us see the enhancements of SQL server 2005 database related to replication.&lt;/p&gt; &lt;p&gt;·         Database Mirroring – Database Mirroring is moving the transactions of database from one SQL Server database to another SQL server database on a different SQL Server.&lt;/p&gt; &lt;p&gt;·         Replication Management topology (RMO) – RMO is a new construct in SQL Server 2005. It is a .NET Framework library that provides a set of common language runtime classes for configuring, managing, and scripting replication, and for synchronizing Subscribers.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/3729637221303012778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-replication-what-is-need-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3729637221303012778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/3729637221303012778'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-replication-what-is-need-to.html' title='What is Replication? What is the need to have the replication? What are the enhancements made to SQL Server 2005 related to the replication?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-5446956445032091301</id><published>2009-12-01T17:09:00.000+05:30</published><updated>2009-12-01T17:10:18.974+05:30</updated><title type='text'>What is Database Partitioning in SQL Server 2005?</title><content type='html'>SQL Server 2005 provides a new capability for the partitioning of tables across file groups in a database. Partitioning a database improves performance and simplifies maintenance. By splitting a large table into smaller, individual tables, queries accessing only a fraction of the data can run faster because there is less data to scan.</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/5446956445032091301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-database-partitioning-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5446956445032091301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/5446956445032091301'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/what-is-database-partitioning-in-sql.html' title='What is Database Partitioning in SQL Server 2005?'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6862796996491954502.post-8121533997627666241</id><published>2009-12-01T17:08:00.000+05:30</published><updated>2009-12-01T17:09:35.480+05:30</updated><title type='text'>Explain the word “federated” in terms of database servers and databases</title><content type='html'>The word “federated” in terms of database servers means SQL Server 2005 shares the database processing load across a group of servers by horizontally partitioning the data in a SQL Server database. These servers are managed independently, but cooperate to process the database requests from the applications; such a cooperative group of servers is called a federation. In terms of databases it means the databases can achieve very high levels of performance only if the application sends each SQL statement to the member server that has most of the data required by the statement. This is referred to as collocating the SQL statement with the data required by the statement. Collocating SQL statements with the required data is not a requirement unique to federated servers.</content><link rel='replies' type='application/atom+xml' href='http://sqlanswer.blogspot.com/feeds/8121533997627666241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/explain-word-federated-in-terms-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8121533997627666241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6862796996491954502/posts/default/8121533997627666241'/><link rel='alternate' type='text/html' href='http://sqlanswer.blogspot.com/2009/12/explain-word-federated-in-terms-of.html' title='Explain the word “federated” in terms of database servers and databases'/><author><name>Manoj Sevda</name><uri>http://www.blogger.com/profile/00306066056375174810</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>