<?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: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-8301166796291327612</id><updated>2012-01-20T07:31:54.715-08:00</updated><category term='indexes'/><category term='Database Normalization'/><category term='Types of database views'/><category term='Database tables normalization'/><category term='Database Triggers'/><category term='Types of Views'/><category term='sql server database back up'/><category term='Syntax of Triggers'/><category term='Sql joins'/><category term='order by'/><category term='SQL Introduction'/><category term='dbf'/><category term='Date conversions'/><category term='normalization'/><category term='SQL Stored Procedures'/><category term='repeat'/><category term='sql server database restore'/><category term='Cross Join'/><category term='SQL Server Views'/><category term='SQL Date Format functions'/><category term='SQL Basics'/><category term='SQL Performance'/><category term='firefox'/><category term='restore'/><category term='msssql'/><category term='SQL server 2008'/><category term='sqlserver'/><category term='Time formats'/><category term='Equi join'/><category term='Database Indexing'/><category term='reporting services'/><category term='Stored Procedure| Database Stored Procedures'/><category term='Types of Index'/><category term='DCL'/><category term='Outer Join'/><category term='Command Prompt'/><category term='Important Database Queries'/><category term='date functions'/><category term='sql server 2005'/><category term='safari'/><category term='backup'/><category term='database'/><category term='64 bit'/><category term='dbase'/><category term='replicate'/><category term='Full Outer Join'/><category term='Unable to import float data type values from excel to sql server'/><category term='SQL Keywords'/><category term='SSAS Reports'/><category term='DRL'/><category term='SQL Server Analysis Services'/><category term='Sql Normalization'/><category term='Syntax of Database Views'/><category term='sp_change_users_login'/><category term='specific order'/><category term='Self Join'/><category term='import data'/><category term='Types of Triggers'/><category term='DBCC DBREINDEX'/><category term='indexing'/><category term='mssql database restore'/><category term='sql server'/><category term='MSSQL database back up'/><category term='DDL'/><category term='DML'/><category term='SQL Date Functions'/><category term='The cube should be active to make a call on this method'/><category term='sql'/><category term='report viewer'/><category term='database views'/><category term='SSAS'/><category term='sql order by'/><category term='MSSQL Views'/><category term='index'/><category term='database joins'/><category term='Import Data from excel file to MSSQL database'/><category term='Database Tables'/><category term='Left outer Join'/><category term='ODBC'/><category term='Right Outer Join'/><category term='Important SQL Queries'/><category term='TCL'/><category term='SQL Views'/><category term='sp'/><category term='Installation'/><category term='Inner join'/><category term='MDB'/><title type='text'>Microsoft SQL Server</title><subtitle type='html'>This blog will give you useful information about SQL, SQL Server, Database Concepts</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-2656015423501377793</id><published>2011-02-08T23:24:00.000-08:00</published><updated>2011-02-08T23:54:19.607-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Date Format functions'/><category scheme='http://www.blogger.com/atom/ns#' term='date functions'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Date Functions'/><category scheme='http://www.blogger.com/atom/ns#' term='Date conversions'/><category scheme='http://www.blogger.com/atom/ns#' term='Time formats'/><title type='text'>SQL Date Format Functions|Date Conversions| 2 digit month or day values</title><content type='html'>&lt;table   style=";font-family:Arial;font-size:small;" border="1" cellpadding="3" cellspacing="0" width="500"&gt;&lt;tbody&gt;&lt;tr align="left" valign="top"&gt;&lt;td colspan="3" style=""&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;DATE FORMATS&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;Format #&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;Query&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:85%;"&gt; (current date: 12/30/2006) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;Sample&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;1 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 1) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;12/30/06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;2 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 2) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;06.12.30 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;3 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 3) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30/12/06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;4 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 4) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30.12.06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;5 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 5) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30-12-06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;6 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 6) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30 Dec 06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;7 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 7) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Dec 30, 06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;10 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 10) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;12-30-06 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;11 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 11) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;06/12/30 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;101 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 101) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;12/30/2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;102 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 102) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;2006.12.30 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;103 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 103) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30/12/2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;104 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 104) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30.12.2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;105 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 105) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30-12-2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;106 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 106) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;30 Dec 2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;107 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 107) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Dec 30, 2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;110 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 110) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;12-30-2006 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;111 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 111) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;2006/12/30 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td colspan="3"  style="color:gray;"&gt;&lt;span&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;TIME FORMATS&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;8 or 108 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 8) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;00:38:54 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;9 or 109 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 9) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;Dec 30 2006 12:38:54:840AM &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td align="middle"&gt;&lt;span style="font-size:85%;"&gt;14 or 114 &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;select convert(varchar, getdate(), 14) &lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;span style="font-size:85%;"&gt;00:38:54:840 &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How to get 2 digit day or month format?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solution:&lt;/span&gt; &lt;span style="font-family:monospace;"&gt;&lt;/span&gt;SELECT RIGHT('0' + RTRIM(MONTH(GETDATE())), 2);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-2656015423501377793?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/2656015423501377793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=2656015423501377793' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/2656015423501377793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/2656015423501377793'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2011/02/sql-date-format-functionsdate.html' title='SQL Date Format Functions|Date Conversions| 2 digit month or day values'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-6111991101017716918</id><published>2011-01-17T04:30:00.000-08:00</published><updated>2011-01-17T04:44:01.657-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Unable to import float data type values from excel to sql server'/><title type='text'>Unable to import float data type values from excel to sql server</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Issue: &lt;/span&gt;&lt;br /&gt;Unable to import float data type values from excel to sql server though the text in the column contains string values.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Description: &lt;/span&gt;&lt;br /&gt;The issue with JET Engine is that it guesses the datatype of the column based on the majority of the type of values in that column.&lt;br /&gt;After a long research i could come across a work around. Basically there is no direct solution as it seems that this is a bug with JET engine.&lt;br /&gt;Use OpenRowSet command with IMEX=1 in connection string, to import the data to sql server as it is in the excel.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Process below:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;First check if "Ad Hoc Distributed Queries" setting is enabled in sql server.&lt;br /&gt;Run &lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;sp_configure&lt;/span&gt; in query window and check the list of the configuration. If there are 14 list items and there is no Ad Hoc Distributed Queries then it should be enabled.&lt;br /&gt;&lt;br /&gt;To enable "Ad Hoc Distributed Queries" follow below steps:&lt;br /&gt;Run&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;sp_configure 'show advanced options', 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;reconfigure &lt;/span&gt;&lt;br /&gt;Then run&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;sp_configure 'Ad Hoc Distributed Queries', 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;reconfigure &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now run below query to get the result set from excel&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'Excel 8.0;Database=C:\Test.xls;IMEX=1;', 'SELECT * FROM [Sheet1$]')&lt;/span&gt;&lt;br /&gt;Most important is that you should give IMEX=1 in the connection string since this is the one setting that is going to help us solve the issue. This command tells JET not to guess the datatype of the columns in the excel.&lt;br /&gt;&lt;br /&gt;Now that you get proper data, you can insert the data into the required table using INSERT INTO ......... SELECT ...FROM format of sql&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-6111991101017716918?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/6111991101017716918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=6111991101017716918' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6111991101017716918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6111991101017716918'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2011/01/unable-to-import-float-data-type-values.html' title='Unable to import float data type values from excel to sql server'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-411687150233988968</id><published>2010-12-30T02:25:00.000-08:00</published><updated>2010-12-30T02:33:17.231-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Analysis Services'/><category scheme='http://www.blogger.com/atom/ns#' term='SSAS Reports'/><category scheme='http://www.blogger.com/atom/ns#' term='SSAS'/><category scheme='http://www.blogger.com/atom/ns#' term='The cube should be active to make a call on this method'/><title type='text'>The cube should be active to make a call on this method</title><content type='html'>Hi All!&lt;br /&gt;&lt;br /&gt;Recently came across an error "The cube should be active to make a call on this method" while using SQL Server Analysis Services (SSAS). I have set up the analysis services database and process it using visual studio. Everything was fine. Data was also available in the tables. But still unable to see the reports.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Here is the fix for the error:&lt;/span&gt;&lt;br /&gt;Go to SQL Server Analysis services&lt;br /&gt;Right Click on the Analysis Server and open Properties&lt;br /&gt;Go to Security Tab. There you will find Users and Groups.&lt;br /&gt;Click on Add and select ASPNET, IUSR, NETWORKSERVICE, NETWORK and Everyone and save.&lt;br /&gt;&lt;br /&gt;Now you wil be able to see the reports.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;Tags: SSAS, SQL Server Analysis Services, The cube should be active to make a call on this method, SSAS Reports, Cube Error, Cube Authentication Error&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-411687150233988968?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/411687150233988968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=411687150233988968' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/411687150233988968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/411687150233988968'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2010/12/cube-should-be-active-to-make-call-on.html' title='The cube should be active to make a call on this method'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-3125908607449560051</id><published>2010-12-20T04:08:00.000-08:00</published><updated>2010-12-20T04:11:59.503-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DBCC DBREINDEX'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Performance'/><title type='text'>Increase your sql performance with DBCC DBREINDEX</title><content type='html'>Recently i have come across an issue with page time out. There was stored procedure that performs updates and inserts to 3 database tables on save. Usually this worked fine but gives a time out expired error when there are any sql jobs running in the background at the time of action. It was quite clear that this is a performance issue and will get solved if the stored procedure was optimized. But the thing is stored procedure was already optimized and there was nothing else to optimize it. I researched for about 1 week but no luck. Then i found out about DBCC DBREINDEX in sql that solved the issue at last. :-)&lt;br /&gt;&lt;br /&gt;Those who are not aware of &lt;span style="font-weight: bold;"&gt;DBCC DBREINDEX&lt;/span&gt;, lets have some knowledge about it.&lt;br /&gt;&lt;br /&gt;When you perform any data modification operations (INSERT, UPDATE, or DELETE statements) table fragmentation can occur. When changes are made to the data that affect the index, index fragmentation can occur and the information in the index can get scattered in the database. Fragmented data can cause SQL Server to perform unnecessary data reads, so a queries performance against a heavy fragmented table can be very poor.&lt;br /&gt;&lt;br /&gt;Rebuilding an index is a more efficient way to reduce fragmentation in comparison with dropping and re-creating an index, this is because rebuilding an index is done by one statement.&lt;br /&gt;&lt;br /&gt;The DBCC DBREINDEX statement cannot automatically rebuild all of the indexes on all the tables in a database it can only work on one table at a time. You can write your own script to rebuild all the indexes on all the tables in a database&lt;br /&gt;&lt;br /&gt;TableName - Is the name of the table in your DataBase.&lt;br /&gt;Index_name - Is the name of the index to rebuild. (refer to image below)&lt;br /&gt;Fillfactor - Is the percentage of space on each index page to be used for storing data when the index is created or rebuilt. Default is 100.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Syntax&lt;/span&gt;&lt;br /&gt;DBCC DBREINDEX ('TableName','Index_Name',fillfactor)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example&lt;/span&gt;&lt;br /&gt;DBCC DBREINDEX ('Vendor')&lt;br /&gt;DBCC DBREINDEX ('Vendor','IX_Vendor',80)&lt;br /&gt;&lt;br /&gt;Believe me! this increases the performance of the actions that we perform on these tables.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-3125908607449560051?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/3125908607449560051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=3125908607449560051' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/3125908607449560051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/3125908607449560051'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2010/12/increase-your-sql-performance-with-dbcc.html' title='Increase your sql performance with DBCC DBREINDEX'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-8395597061219342618</id><published>2010-10-27T02:51:00.000-07:00</published><updated>2010-12-30T02:43:53.863-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='Command Prompt'/><category scheme='http://www.blogger.com/atom/ns#' term='Installation'/><title type='text'>The INSTALLSHAREDDIR command line value was not specified. This value must be specified when the INSTALLSHAREDWOWDIR value is specified.</title><content type='html'>When installing SQL Server 2008 Express on Windows 2008 64 bit server, you may encounter below error. I have got this error in godaddy's virtual server.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;Error: The INSTALLSHAREDDIR command line value was not specified. This value must be specified when the INSTALLSHAREDWOWDIR value is specified.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;To solve this issue, install sql server using command prompt. Here is how you can do it.&lt;br /&gt;&lt;br /&gt;Open command prompt, go to the folder where your installation exe file is located and give the command like below.&lt;br /&gt;SQLEXPRWT_x64_ENU.exe /ACTION=install /INSTANCEDIR=C:\SQLInstall\Microsoft SQL Server /INSTALLSQLDATADIR=C:\DATA /INSTALLSHAREDDIR=C:\SQLInstall\Microsoft SQL Server /INSTALLSHAREDWOWDIR=C:\SQLInstall\Microsoft SQL Server /FEATURES=SQL /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=NT AUTHORITY\Network Service/SQLSYSADMINACCOUNTS=BUILTIN\ADMINISTRATORS /AGTSVCACCOUNT=NT AUTHORITY\Network Service /IACCEPTSQLSERVERLICENSETERMS&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Note:&lt;/strong&gt; Modify the parameter values as per your system needs.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;One more step/ prerequisite which might be required in some cases:&lt;/span&gt;&lt;br /&gt;The system name and system login name should not be same which generally happens in some hosting servers. Renaming the server first and then installing sql server through command prompt will solve the issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-8395597061219342618?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/8395597061219342618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=8395597061219342618' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/8395597061219342618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/8395597061219342618'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2010/10/installshareddir-command-line-value-was.html' title='The INSTALLSHAREDDIR command line value was not specified. This value must be specified when the INSTALLSHAREDWOWDIR value is specified.'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-1207558992468605094</id><published>2010-10-20T05:01:00.000-07:00</published><updated>2010-10-20T05:10:14.209-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ODBC'/><category scheme='http://www.blogger.com/atom/ns#' term='MDB'/><category scheme='http://www.blogger.com/atom/ns#' term='64 bit'/><title type='text'>Windows 2008 server missing MDB Access ODBC drivers to create system DSN</title><content type='html'>When you open ODBC Sources to create a system DSN for MDB Access, then you see that there are no drivers for such an action. To view 32-bit version of ODBC Driver, you can use the C:\Windows\SysWOW64\odbcad32.exe instead.&lt;br /&gt;&lt;br /&gt;You can then create a desktop shortcut so that you dont need to type this command all the time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-1207558992468605094?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/1207558992468605094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=1207558992468605094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/1207558992468605094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/1207558992468605094'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2010/10/windows-2008-server-missing-mdb-access.html' title='Windows 2008 server missing MDB Access ODBC drivers to create system DSN'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-7520812720290189475</id><published>2009-07-22T00:26:00.000-07:00</published><updated>2009-07-22T00:44:55.140-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='reporting services'/><category scheme='http://www.blogger.com/atom/ns#' term='safari'/><category scheme='http://www.blogger.com/atom/ns#' term='report viewer'/><title type='text'>SQL Reports Report Viewer alignment issue in Firefox and Safari</title><content type='html'>&lt;span style="color:#333333;"&gt;Guys, i have faced an alignment issue with sql reporting services reports in Firefox and Safari browser. Below are the details of the issues and the solution that i could find. Hope this is helpful.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Issue in Firefox:&lt;/strong&gt; Report frame width and height is shrinked to the top left.&lt;br /&gt;&lt;strong&gt;Solution: &lt;/strong&gt;&lt;br /&gt;1. Go to Program Files → Microsoft SQL Server → MSSQL3 (Differs for different versions of sql server. Purpose is to locate "Reporting Services" folder) → Reporting Services → Report Server → Pages&lt;br /&gt;2. Open ReportViewer.aspx&lt;br /&gt;3. Modify as &lt;&gt; &lt;rs:reportviewerhost color="#ff0000"&gt;&lt;span color="#ff0000"&gt;style="display:table; margin: 0px; overflow: auto"&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#333333;"&gt;ID="ReportViewerControl" runat="server" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Issue in Safari:&lt;/strong&gt; Report body is compressed to the left.&lt;br /&gt;&lt;strong&gt;Solution: &lt;/strong&gt;&lt;br /&gt;This can be solved by placing a rectangle and including the tables / header elements present in the report in that rectangle.&lt;br /&gt;The report layout should be modified in such a way that&lt;br /&gt;1. all the header elements are included in a Rectangle.&lt;br /&gt;2. all tables are included in a Rectangle.&lt;br /&gt;There is no perfect solution for this. Hope microsoft fixes this in the latest versions.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/rs:reportviewerhost&gt;&lt;?xml:namespace prefix = rs /&gt;&lt;rs:reportviewerhost color="#ff0000"&gt;&lt;/rs:reportviewerhost&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-7520812720290189475?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/7520812720290189475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=7520812720290189475' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/7520812720290189475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/7520812720290189475'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2009/07/sql-reports-report-viewer-alignment.html' title='SQL Reports Report Viewer alignment issue in Firefox and Safari'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-1700293328422488792</id><published>2009-05-27T03:16:00.000-07:00</published><updated>2009-06-08T21:46:26.492-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='import data'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='dbf'/><category scheme='http://www.blogger.com/atom/ns#' term='dbase'/><title type='text'>Import dbf to sql server 2005</title><content type='html'>&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;dbf file or dbase file can be imported direclty in SQL Server 2000 by selecting the option in the wizard. But SQL Server 2005 does not provide such an option. There are few methods with which this task can be accomplished. For example, using SSIS (SQL Server Integration Services). Below is another method of doing it which i found to be simpler than using SSIS.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Steps to import dbase file (.dbf) to SQL Server 2005:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Create a System DSN&lt;br /&gt;&lt;br /&gt;2. Open SQL Server 2005 Import/Export Wizard&lt;br /&gt;&lt;br /&gt;3. Select ".Net Framework Data Provider for ODBC" in Data Source.&lt;br /&gt;&lt;br /&gt;4. Enter the DSN Name that you have created. Click Next&lt;br /&gt;&lt;br /&gt;5. Choose Destination database. Click Next&lt;br /&gt;&lt;br /&gt;6. You will given an option to write a query. Click Next. Here you should write the query to get the data from dbf file. For example: SELECT * FROM Test.dbf&lt;br /&gt;&lt;br /&gt;7. Click Next. Select the destination table or create a new one.&lt;br /&gt;&lt;br /&gt;8. Click Finish. The data is imported to the selected destination table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;How to create a system DSN?&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;1. Go to Control Panel&lt;br /&gt;2. Go to Administrative Tools&lt;br /&gt;3. Click Data Sources (ODBC)&lt;br /&gt;4. Select System DSN Tab.&lt;br /&gt;5. Click "Add"&lt;br /&gt;6. Select "Microsoft dbase driver (*.dbf)"&lt;br /&gt;7. Click Finish&lt;br /&gt;8. Enter name for the new system dsn created. (This name is used during importing in sql server)&lt;br /&gt;9. Select the directory where the .dbf file is located. (Deselect Current directory if the file is located else where and then browse the location)&lt;br /&gt;10. Click Ok. System DSN is created.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-1700293328422488792?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/1700293328422488792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=1700293328422488792' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/1700293328422488792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/1700293328422488792'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2009/05/import-dbf-to-sql-server-2005.html' title='Import dbf to sql server 2005'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-6801508614809286174</id><published>2008-09-04T03:09:00.000-07:00</published><updated>2010-12-30T04:16:25.149-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql order by'/><category scheme='http://www.blogger.com/atom/ns#' term='order by'/><category scheme='http://www.blogger.com/atom/ns#' term='specific order'/><title type='text'>SQL Order By our specific order</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Generally we can get the records in alphabetical or numeric order by default either in ascending or descending by specifying ORDER BY clause in the query. But sometimes in our applications, we may need to get the records in a specific order. For example, the order of names that we get from the database needs to be displayed in an order other than A to Z or Z to A. Here is the solution that i found.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br /&gt;Suppose that there is a query like below:&lt;br /&gt;select * from emp where empname in ('B1','A1','C1')&lt;br /&gt;You want the records to be displayed in the same order as above. Then change the query as below.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;select * from emp&lt;br /&gt;where empname in ('B1','A1','C1')&lt;br /&gt;order by CASE empname&lt;br /&gt;WHEN 'B1' THEN 1&lt;br /&gt;WHEN 'A1' THEN 2&lt;br /&gt;WHEN 'C1' THEN 3&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;END&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-6801508614809286174?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/6801508614809286174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=6801508614809286174' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6801508614809286174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6801508614809286174'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/09/order-by-our-specific-order.html' title='SQL Order By our specific order'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-3310405641292393804</id><published>2008-08-07T05:28:00.000-07:00</published><updated>2008-08-07T05:50:35.607-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='repeat'/><category scheme='http://www.blogger.com/atom/ns#' term='replicate'/><title type='text'>REPLICATE function</title><content type='html'>Repeats a string value a specified number of times.&lt;br /&gt;&lt;br /&gt;Syntax:&lt;br /&gt;REPLICATE ( string , integer)&lt;br /&gt;string - what should be repeated or added&lt;br /&gt;integer - how many times string value should be repeated&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;select REPLICATE('0',2)+[Product_Code] from Products&lt;br /&gt;&lt;br /&gt;The above query will return the product code value with 2 zeroes added at the first.&lt;br /&gt;If product code is PCT then the result will be 00PCT&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-3310405641292393804?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/3310405641292393804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=3310405641292393804' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/3310405641292393804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/3310405641292393804'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/08/replicate-function.html' title='REPLICATE function'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-4247599400264332848</id><published>2008-05-29T23:52:00.000-07:00</published><updated>2010-12-30T04:00:55.757-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Import Data from excel file to MSSQL database'/><title type='text'>Import Data from excel file to MSSQL database</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Steps to import data from excel to the database:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 1:&lt;/span&gt; Go to Sql Server Enterprise Manager &gt; Right click on local database server &gt; All Tasks &gt; Import Data&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5206062321100636546" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://2.bp.blogspot.com/_YHWJ_AsQquw/SD-mGR-_wYI/AAAAAAAAAGg/22q17bM9HQg/s400/11.PNG" border="0" /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 2: &lt;/span&gt;A screen appears like below. Click Next&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206060835041951986" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://4.bp.blogspot.com/_YHWJ_AsQquw/SD-kvx-_wPI/AAAAAAAAAFY/16_KKfBjwqE/s400/2.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 3:&lt;/span&gt; Select Microsoft Excel option in Data Source, Browse and select the file and clilck Next&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206060839336919298" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://1.bp.blogspot.com/_YHWJ_AsQquw/SD-kwB-_wQI/AAAAAAAAAFg/1fhhyTxoH4g/s400/3.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 4: &lt;/span&gt;Select the destination database name and click Next&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206061045495349618" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://1.bp.blogspot.com/_YHWJ_AsQquw/SD-k8B-_wXI/AAAAAAAAAGY/wU2_EjBi8T0/s400/selectdb.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 5:&lt;/span&gt; Select the database using check box which is provided and click Next.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);font-family:verdana;" &gt;Note: This process will automatically create a new table if the table does not exists.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);font-family:Verdana;" &gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206060839336919314" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://1.bp.blogspot.com/_YHWJ_AsQquw/SD-kwB-_wRI/AAAAAAAAAFo/WmwkonX7S34/s400/checktablename.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 6:&lt;/span&gt; A screen appears like below. Click Next.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206061041200382274" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://4.bp.blogspot.com/_YHWJ_AsQquw/SD-k7x-_wUI/AAAAAAAAAGA/dTpN_KCNkvs/s400/clicknext.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 7: &lt;/span&gt;Check Run immediately (default). Click Next.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206061041200382290" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://4.bp.blogspot.com/_YHWJ_AsQquw/SD-k7x-_wVI/AAAAAAAAAGI/1JDtCJbJ3cw/s400/clicknext1.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 8:&lt;/span&gt; An alert is given after succesfully copying the data. Click OK.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206061041200382306" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://4.bp.blogspot.com/_YHWJ_AsQquw/SD-k7x-_wWI/AAAAAAAAAGQ/nbqwD3CpQwA/s400/copied.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 9:&lt;/span&gt; Click Done&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5206060843631886626" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://2.bp.blogspot.com/_YHWJ_AsQquw/SD-kwR-_wSI/AAAAAAAAAFw/N-gvAzspPm8/s400/clickdone.PNG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold;"&gt;Step 10:&lt;/span&gt; Click Finish&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_YHWJ_AsQquw/SD-k7h-_wTI/AAAAAAAAAF4/akBZebuTzv0/s1600-h/clickfinish.PNG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5206061036905414962" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://3.bp.blogspot.com/_YHWJ_AsQquw/SD-k7h-_wTI/AAAAAAAAAF4/akBZebuTzv0/s400/clickfinish.PNG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;&lt;span style="font-weight: bold;"&gt;Tags: &lt;/span&gt;Import Data from excel file to MSSQL database, Excel Data to Sql server database, Export Data from sql server to excel file&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-4247599400264332848?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/4247599400264332848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=4247599400264332848' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/4247599400264332848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/4247599400264332848'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/import-data-from-excel-file-to-database.html' title='Import Data from excel file to MSSQL database'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_YHWJ_AsQquw/SD-mGR-_wYI/AAAAAAAAAGg/22q17bM9HQg/s72-c/11.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-594902841935009378</id><published>2008-05-20T09:28:00.000-07:00</published><updated>2010-12-30T03:57:49.912-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Important Database Queries'/><category scheme='http://www.blogger.com/atom/ns#' term='Important SQL Queries'/><title type='text'>Important SQL Queries, Important Database Queries</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;To find the nth row of a table&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;In oracle:&lt;br /&gt;Select * from emp where rowid = (select max(rowid) from emp where rownum &lt;= 4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;In Sql Server 2005:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;Select * from emp where rowid = (select max(rowid) from emp where row_number() &lt;= 4)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;To find duplicate rows&lt;/strong&gt;&lt;br /&gt;Select * from emp where rowid in (select max(rowid) from emp group by empno, ename, mgr, job, hiredate, comm, deptno, sal)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To delete duplicate rows&lt;/strong&gt;&lt;br /&gt;Delete emp where rowid in (select max(rowid) from emp group by empno,ename,mgr,job,hiredate,sal,comm,deptno)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To find the count of duplicate rows&lt;/strong&gt;&lt;br /&gt;Select ename, count(*) from emp group by ename having count(*) &gt;= 1&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To display alternative rows in a table&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;In oracle:&lt;br /&gt;select * from emp where (rowid,0) in (select rowid,mod(rownum,2) from emp)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Getting employee details of each department who is drawing maximum sal&lt;/strong&gt;&lt;br /&gt;select * from emp where (deptno,sal) in ( select deptno,max(sal) from emp group by deptno)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To get number of employees in each department, in which department is having more than 2500 employees&lt;/strong&gt;&lt;br /&gt;Select deptno,count(*) from emp group by deptno having count(*) &gt;2500&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To find nth maximum sal&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;In oracle:&lt;br /&gt;Select * from emp where sal in (select max(sal) from (select * from emp order by sal) where rownum &lt;= 5)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;If you have to give a flat hike to your EMPloyee using the Following CriteriaSalary b/w 2000 and 3000 then Hike is 200Salary b/w 3000 and 4000 then Hike is 300 Salary b/w 4000 and 5000 then Hike is 400 in EMPLOYEE Table&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Update EMPLOYEE Set Salary =&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Case when Salary between 2000 and 3000 then &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Salary = Salary+200&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Case when Salary between 3000 and 4000 then &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Salary = Salary+300&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Case when Salary between 3000 and 4000 then &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Salary = Salary+300&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;End&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-weight: bold; color: rgb(192, 192, 192);"&gt;Tags: &lt;/span&gt;&lt;span style="color: rgb(192, 192, 192);"&gt;Important SQL Queries, Important Database Queries, Most Common SQL Queries&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-594902841935009378?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/594902841935009378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=594902841935009378' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/594902841935009378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/594902841935009378'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/important-queries.html' title='Important SQL Queries, Important Database Queries'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-6657411360146145046</id><published>2008-05-05T04:18:00.000-07:00</published><updated>2010-12-30T03:53:33.084-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Syntax of Triggers'/><category scheme='http://www.blogger.com/atom/ns#' term='Database Triggers'/><category scheme='http://www.blogger.com/atom/ns#' term='Types of Triggers'/><title type='text'>Database Triggers, Types of Triggers, Syntax of Triggers</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Triggers are special types of Stored Procedures that are defined to execute automatically in place of or after data modifications.&lt;br /&gt;They can be executed automatically on the INSERT, DELETE and UPDATE triggering actions.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Types of triggers:&lt;/strong&gt;&lt;br /&gt;1. INSTEAD OF:&lt;br /&gt;A trigger that fires before the INSERT, UPDATE, or DELETE statement is conducted.&lt;br /&gt;CREATE TRIGGER &lt;em&gt;trigger name&lt;/em&gt;&lt;br /&gt;ON &lt;em&gt;table name&lt;/em&gt;&lt;br /&gt;INSTEAD OF &lt;em&gt;operation&lt;/em&gt; AS &lt;em&gt;DML statements&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;2. AFTER:&lt;br /&gt;&lt;/span&gt;&lt;table&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;AFTER triggers are executed after the action of the INSERT, UPDATE, or DELETE statement is performed.&lt;br /&gt;CREATE TRIGGER &lt;em&gt;trigger name&lt;/em&gt; ON &lt;em&gt;table name &lt;/em&gt;AFTER &lt;em&gt;operation&lt;/em&gt; AS &lt;em&gt;DML statements&lt;/em&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br /&gt;INSTEAD OF triggers may be defined on views where as AFTER cannot. &lt;/span&gt;&lt;/p&gt;&lt;tbody&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/tbody&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/table&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 153);"&gt;Tags: &lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;Database Triggers, Types of Triggers, Syntax of Triggers, Instead of trigger, After Trigger, Create Trigger&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-6657411360146145046?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/6657411360146145046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=6657411360146145046' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6657411360146145046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6657411360146145046'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/triggers.html' title='Database Triggers, Types of Triggers, Syntax of Triggers'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-876669238959218196</id><published>2008-05-05T04:15:00.000-07:00</published><updated>2010-12-30T03:51:32.665-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Stored Procedures'/><category scheme='http://www.blogger.com/atom/ns#' term='Stored Procedure| Database Stored Procedures'/><title type='text'>Stored Procedure| Database Stored Procedures| SQL Stored Procedures</title><content type='html'>&lt;span style="font-family:verdana;"&gt;A stored procedure is a set of SQL statements that can be stored in the server.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Benefits of Stored Procedures&lt;/strong&gt;&lt;br /&gt;1. Precompiled execution. SQL Server compiles each stored procedure once and then reutilizes the execution plan. This results in tremendous performance boosts when stored procedures are called repeatedly.&lt;br /&gt;&lt;br /&gt;2. Reduced client/server traffic. If network bandwidth is a concern in your environment, you'll be happy to learn that stored procedures can reduce long SQL queries to a single line that is transmitted over the wire.&lt;br /&gt;&lt;br /&gt;3. Efficient reuse of code and programming abstraction. Stored procedures can be used by multiple users and client programs. If you utilize them in a planned manner, you'll find the development cycle takes less time.&lt;br /&gt;&lt;br /&gt;4. Enhanced security controls. You can grant users permission to execute a stored procedure independently of underlying table permissions.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br /&gt;CREATE PROCEDURE [procedure name] (@parameter1 type, @parameter2 type) AS&lt;br /&gt;Sql statements………&lt;br /&gt;BEGIN&lt;br /&gt;END&lt;br /&gt;…………….&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To declare variables:&lt;/strong&gt;&lt;br /&gt;DECLARE&lt;br /&gt;Eg: DECLARE @temp int&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To assign values:&lt;/strong&gt;&lt;br /&gt;SET&lt;br /&gt;Eg: SET @temp = 0&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To return a value:&lt;/strong&gt;&lt;br /&gt;CREATE PROCEDURE [proc name] (@p1 type, @p2 type output) AS&lt;br /&gt;……&lt;br /&gt;GO&lt;br /&gt;Eg: Create Procedure GetAuthorsByLastName1 (@au_lname varchar(40), @RowCount int output) as select * from authors where au_lname like @au_lname; /* @@ROWCOUNT returns the number of rows that are affected by the last statement. */&lt;br /&gt;select @RowCount=@@ROWCOUNT&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Error Handling:&lt;/strong&gt;&lt;br /&gt;@@Error is used.&lt;br /&gt;&lt;br /&gt;Include the SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a Transact-SQL statement.This can reduce network traffic, because your client will not receive the message indicating the number of rows affected by a Transact-SQL statement.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To Execute in query analyzer:&lt;/strong&gt;&lt;br /&gt;Exec [procedure name] [parameters]&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;To call from ASP page:&lt;br /&gt;&lt;/strong&gt;Rs.Open "exec [procedure name] [parameters]", conn&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;To write comments:&lt;/strong&gt;&lt;br /&gt;/* */&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 153);"&gt;Tags:&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);"&gt; Stored Procedure, Database Stored Procedures, SQL Stored Procedures, Stored Procedure Syntax, Call a stored procedure from asp page, Execute a stored procedure, Error Handling in stored procedures&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-876669238959218196?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/876669238959218196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=876669238959218196' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/876669238959218196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/876669238959218196'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/stored-procedure-is-set-of-sql.html' title='Stored Procedure| Database Stored Procedures| SQL Stored Procedures'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-345716390308236422</id><published>2008-05-05T04:14:00.000-07:00</published><updated>2010-12-30T03:39:02.150-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='indexing'/><category scheme='http://www.blogger.com/atom/ns#' term='indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='index'/><category scheme='http://www.blogger.com/atom/ns#' term='Database Indexing'/><category scheme='http://www.blogger.com/atom/ns#' term='Types of Index'/><title type='text'>Database Indexing, Types of Index, Indexes</title><content type='html'>&lt;span style="font-family:verdana;"&gt;A database index is a copy of part of a table that is used to speed up data retrieval in a database.Indexes can be created using one or more columns, providing the basis for both rapid random lookups and efficient ordering of access to records.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Types of Index:&lt;/strong&gt;&lt;br /&gt;Clustered Index&lt;br /&gt;Non-Clustered Index&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Clustered Index:&lt;/strong&gt;&lt;br /&gt;A clustered index is a special type of index that reorders the&lt;span style="color: rgb(0, 0, 0);"&gt; way &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.coolinterview.com/interview/12441/" target="_top"&gt;&lt;span style="color: rgb(0, 0, 0);font-family:verdana;" &gt;records&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.&lt;br /&gt;A clustered index stores data similar to a phone directory where all people with the same last name are grouped together. SQL Server will quickly search a table with a clustered index while the index itself determines the sequence in which rows are stored in a table. Clustered indexes are useful for columns searched frequently for ranges of values, or are accessed in sorted order.&lt;br /&gt;&lt;br /&gt;CREATE UNIQUE CLUSTERED INDEX DummyTable2_EmpIndexON DummyTable2 (EmpID)GO&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Non-Clustered Index:&lt;/strong&gt;&lt;br /&gt;A non-clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non-clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.&lt;br /&gt;A non-clustered index stores data comparable to the index of a text book. The index is created in a different location than the actual data. The structure creates an index with a pointer that points to the actual location of the data. Non-clustered indexes should be created on columns where the selectivity of query ranges from highly selective to unique. These indexes are useful when providing multiple ways to search data is desired.&lt;br /&gt;&lt;br /&gt;CREATE UNIQUE NONCLUSTERED INDEX DummyTable1_empidON DummyTable1 (empid)GO&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 153);"&gt;Tags:&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);"&gt; index, indexes, indexing, Database Indexing, Types of Index, Clustured Index, Non-Clustered Index, Syntax of Index, Clustured index syntax, Non clustured index syntax&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-345716390308236422?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/345716390308236422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=345716390308236422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/345716390308236422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/345716390308236422'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/indexing.html' title='Database Indexing, Types of Index, Indexes'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-8480389774843427355</id><published>2008-05-05T04:11:00.000-07:00</published><updated>2010-12-30T03:35:02.934-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Views'/><category scheme='http://www.blogger.com/atom/ns#' term='Types of Views'/><category scheme='http://www.blogger.com/atom/ns#' term='Types of database views'/><category scheme='http://www.blogger.com/atom/ns#' term='Syntax of Database Views'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL Views'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Views'/><category scheme='http://www.blogger.com/atom/ns#' term='database views'/><title type='text'>Database Views| MSSQL Views| SQL Server Views| Syntax of Database Views| Types of Views</title><content type='html'>&lt;span style="font-family:verdana;"&gt;A view may be thought of as a virtual table, that is, a table that does not really exist in its own right but is instead derived from one or more underlying base table. In other words, there is no stored file that direct represents the view instead a definition of view is stored in data dictionary.&lt;br /&gt;Growth and restructuring of base tables is not reflected in views. Thus the view can insulate users from the effects of restructuring and growth in the database. Hence accounts for logical data independence.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Syntax&lt;br /&gt;&lt;/strong&gt;CREATE VIEW [&lt;&gt; . ] view_name [ ( column [ ,...n ] ) ] [ WITH &lt;&gt; [ ,...n ] ] AS select_statement [ WITH CHECK OPTION ]&lt;br /&gt;&lt;&gt; ::= { ENCRYPTION SCHEMABINDING VIEW_METADATA }&lt;br /&gt;Note: Column is for statements, which contain aggregate functions&lt;br /&gt;Encryption: Code View is encrypted by using this.&lt;br /&gt;Schemabinding: The view is binded with the underlying table structure. Suppose you drop a column of the base table, normally the view gives an error that there is no such column name But if you specify With Schemabinding, then we will not be able to drop the column as it is being accessed by other objects.&lt;br /&gt;View_MetaData: Returns the meta data information about the view.&lt;br /&gt;Check Option: Suppose we create a view with a query, which has where condition. For this view, if the user tries to insert the data that does not match the query then its of no use as that is not shown in the result. So that means, we should give access only to insert records which meets the query criteria. Hence WITH CHECK OPTION is used. The result would be an error for the situation above.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;A CREATE VIEW statement cannot:&lt;br /&gt;&lt;/strong&gt;Include ORDER BY clause, unless there is also a TOP clause (remember that a view is nothing else but a virtual table, why would we want to order it?)&lt;br /&gt;Include the INTO keyword.&lt;br /&gt;Include COMPUTE or COMPUTE BY clauses.&lt;br /&gt;Reference a temporary table or a table variable.&lt;br /&gt;Select statement can use multiple SELECT statements separated by UNION or UNION ALL.&lt;br /&gt;&lt;/span&gt;&lt;a name="Update"&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;Restrictions for updating &lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;data:&lt;/strong&gt;&lt;br /&gt;A view cannot modify more than one table. So if a view is based on two or more tables, and you try to run a DELETE statement, it will fail. If you run an UPDATE or INSERT statement, all columns referenced in the statement must belong to the same table.&lt;br /&gt;It’s not possible to update, insert or delete data in a view with a DISTINCT clause.&lt;br /&gt;You cannot update, insert or delete data in a view that is using GROUP BY.&lt;br /&gt;It’s not possible to update, insert or delete data in a view that contains calculated columns.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Types:&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Indexed Views:&lt;/strong&gt; Indexed views work best for queries that aggregate or compute columns in the table. The disadvantage of indexed views is that it will slow down a query that updates data in the underlying tables.&lt;br /&gt;&lt;strong&gt;Partitioned Views:&lt;/strong&gt; When you need to write a join query with tables that are in different databases, then we use partitioned views.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;&lt;span style="font-weight: bold;"&gt;Tags: &lt;/span&gt;Database Views, SQL Views, MSSQL Views, SQL Server Views, Syntax of Database Views, Types of Views, Types of database views&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-8480389774843427355?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/8480389774843427355/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=8480389774843427355' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/8480389774843427355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/8480389774843427355'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/views.html' title='Database Views| MSSQL Views| SQL Server Views| Syntax of Database Views| Types of Views'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-6547595495328984972</id><published>2008-05-05T04:08:00.000-07:00</published><updated>2010-12-30T03:32:54.448-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql joins'/><category scheme='http://www.blogger.com/atom/ns#' term='Cross Join'/><category scheme='http://www.blogger.com/atom/ns#' term='Inner join'/><category scheme='http://www.blogger.com/atom/ns#' term='Left outer Join'/><category scheme='http://www.blogger.com/atom/ns#' term='Equi join'/><category scheme='http://www.blogger.com/atom/ns#' term='database joins'/><category scheme='http://www.blogger.com/atom/ns#' term='Full Outer Join'/><category scheme='http://www.blogger.com/atom/ns#' term='Outer Join'/><category scheme='http://www.blogger.com/atom/ns#' term='Right Outer Join'/><category scheme='http://www.blogger.com/atom/ns#' term='Self Join'/><title type='text'>Database Joins| SQL Joins| Types of database Joins</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Join actually puts data from two or more tables into a single result set.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Types:&lt;br /&gt;&lt;/strong&gt;Inner join or Equi join&lt;br /&gt;Outer Join&lt;br /&gt;Left outer Join&lt;br /&gt;Right Outer Join&lt;br /&gt;Full Outer Join&lt;br /&gt;Cross Join&lt;br /&gt;Self Join&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Inner Join:&lt;/strong&gt; An inner join returns all rows that result in a match.&lt;br /&gt;Example: SELECT Employees.Name, Orders.ProductFROM EmployeesINNER JOIN OrdersON Employees.Employee_ID=Orders.Employee_ID&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Left Outer Join:&lt;/strong&gt; A Left join returns all rows of the left of the conditional even if there is no right column to match.&lt;br /&gt;Example:SELECT Employees.Name, Orders.ProductFROM EmployeesLEFT JOIN OrdersON Employees.Employee_ID=Orders.Employee_ID&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Right Outer Join:&lt;/strong&gt; A right join will display rows on the right side of the conditional that may or may not have a match.&lt;br /&gt;Example:SELECT Employees.Name, Orders.ProductFROM EmployeesRIGHT JOIN OrdersON Employees.Employee_ID=Orders.Employee_ID&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Full Outer Join:&lt;/strong&gt; Returns all the left, right (unmatched rows) and also matched rows.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Cross-Join:&lt;/strong&gt; A cross join (or Cartesian Product join) will return a result table where each row from the first table is combined with each row from the second table. The number of rows in the result table is the product of the number of rows in each table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Self-Join:&lt;/strong&gt; A self-join is a query in which a table is joined (compared) to itself. Self-joins are used to compare values in a column with other values in the same column in the same table.&lt;br /&gt;Example:&lt;br /&gt;SELECT DISTINCT c1.ContactName, c1.Address, c1.City, c1.Region&lt;br /&gt;FROM Customers AS c1, Customers AS c2&lt;br /&gt;WHERE c1.Region = c2.Region&lt;br /&gt;AND c1.ContactName &lt;&gt; c2.ContactName&lt;br /&gt;ORDER BY c1.Region, c1.ContactName;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 153);"&gt;Tags:&lt;/span&gt;&lt;span style="color: rgb(153, 153, 153);"&gt; Database Joins, Sql joins, &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;Inner join, Equi join, Outer Join, Left outer Join, Right Outer Join, Full Outer Join, Cross Join, Self Join, Types of Database Joins&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-6547595495328984972?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/6547595495328984972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=6547595495328984972' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6547595495328984972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/6547595495328984972'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/joins.html' title='Database Joins| SQL Joins| Types of database Joins'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-5275536424580101291</id><published>2008-05-05T04:00:00.000-07:00</published><updated>2010-12-30T03:31:01.335-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Normalization'/><category scheme='http://www.blogger.com/atom/ns#' term='Database tables normalization'/><category scheme='http://www.blogger.com/atom/ns#' term='Database Normalization'/><category scheme='http://www.blogger.com/atom/ns#' term='normalization'/><title type='text'>Database Normalization| SQL Normalization</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Normalization is the process of efficiently organizing data in a database. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Goals:&lt;/strong&gt; eliminating redundant data (for example, storing the same data in more than one table) ensuring data dependencies make sense (only storing related data in a table) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Levels:&lt;/strong&gt; 1 NF, 2NF, 3NF, BCNF (Boyce-Codd Normal Form), 4NF, 5 NF &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1 NF:&lt;/strong&gt; Eliminate duplicative columns from the same table. Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_YHWJ_AsQquw/SDrU4mpgZpI/AAAAAAAAAB8/zGD3kaQvVAc/s1600-h/NF1.GIF"&gt;&lt;img id="BLOGGER_PHOTO_ID_5204706388292429458" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://3.bp.blogspot.com/_YHWJ_AsQquw/SDrU4mpgZpI/AAAAAAAAAB8/zGD3kaQvVAc/s400/NF1.GIF" border="0" /&gt;&lt;/a&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;2 NF:&lt;/strong&gt; Meet all the requirements of the first normal form. Remove subsets of data that apply to multiple rows of a table and place them in separate tables. Create relationships between these new tables and their predecessors through the use of foreign keys.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://3.bp.blogspot.com/_YHWJ_AsQquw/SDrU4mpgZqI/AAAAAAAAACE/adOELhlg5QY/s1600-h/NF2.GIF"&gt;&lt;img id="BLOGGER_PHOTO_ID_5204706388292429474" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://3.bp.blogspot.com/_YHWJ_AsQquw/SDrU4mpgZqI/AAAAAAAAACE/adOELhlg5QY/s400/NF2.GIF" border="0" /&gt;&lt;/a&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;3 NF:&lt;/strong&gt; Meet all the requirements of the second normal form. Remove columns that are not dependent upon the primary key. Eg: total, average etc which can be calculated in sql query&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://4.bp.blogspot.com/_YHWJ_AsQquw/SDrU42pgZrI/AAAAAAAAACM/hcGEtBJTAk4/s1600-h/NF3.GIF"&gt;&lt;img id="BLOGGER_PHOTO_ID_5204706392587396786" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://4.bp.blogspot.com/_YHWJ_AsQquw/SDrU42pgZrI/AAAAAAAAACM/hcGEtBJTAk4/s400/NF3.GIF" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_YHWJ_AsQquw/SDrU5GpgZsI/AAAAAAAAACU/BkmAGpmHevg/s1600-h/NF3a.GIF"&gt;&lt;img id="BLOGGER_PHOTO_ID_5204706396882364098" style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://1.bp.blogspot.com/_YHWJ_AsQquw/SDrU5GpgZsI/AAAAAAAAACU/BkmAGpmHevg/s400/NF3a.GIF" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Boyce-Codd NF:&lt;/strong&gt;&lt;br /&gt;A relation is in Boyce-Codd Normal Form (BCNF) if every determinant is a candidate key.&lt;br /&gt;OR&lt;br /&gt;Key attribute should not depend on a non key attribute.&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Determinant:&lt;/span&gt; A determinant in a database table is any attribute that you can use to determine the values assigned to other attribute(s) in the same row.&lt;br /&gt;Examples: Consider a table with the attributes employee_id, first_name, last_name and date_of_birth. In this case, the field employee_id determines the remaining three fields. The name fields do not determine the employee_id because the firm may have more than one employee with the same first and/or last name. Similarly, the DOB field does not determine the employee_id or the name fields because more than one employee may share the same birthday.&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Candidate Key:&lt;/span&gt; A candidate key is a combination of attributes that can be uniquely used to identify a database record. Each table may have one or more candidate keys. One of these candidate keys is selected as the table primary key.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;4 NF:&lt;/strong&gt;&lt;br /&gt;Meet all the requirements of the third normal form and BCNF.&lt;br /&gt;A relation is in 4NF if it has no more than one multi-valued or multiple dependency.Consider these entities: employees, skills, and languages. An employee can have several skills and know several languages. There are two relationships, one between employees and skills, and one between employees and languages. A table is not in fourth normal form if it represents both relationships. Instead, the relationships should be represented in two tables. If, however, the attributes are interdependent (that is, the employee applies certain languages only to certain skills), the table should not be split.A good strategy when designing a database is to arrange all data in tables that are in fourth normal form, and then to decide whether the results give you an acceptable level of performance. If they do not, you can rearrange the data in tables that are in third normal form, and then re assess performance. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;5NF:&lt;br /&gt;&lt;/strong&gt;(join-projection normal form)JPNF&lt;br /&gt;It should be in 4NF.&lt;br /&gt;No multi valued dependency exists.&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-5275536424580101291?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/5275536424580101291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=5275536424580101291' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/5275536424580101291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/5275536424580101291'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/05/normalization.html' title='Database Normalization| SQL Normalization'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_YHWJ_AsQquw/SDrU4mpgZpI/AAAAAAAAAB8/zGD3kaQvVAc/s72-c/NF1.GIF' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-3831863172854818538</id><published>2008-04-25T23:34:00.000-07:00</published><updated>2010-12-30T03:24:06.342-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='restore'/><category scheme='http://www.blogger.com/atom/ns#' term='mssql database restore'/><category scheme='http://www.blogger.com/atom/ns#' term='backup'/><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL database back up'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server database restore'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server database back up'/><title type='text'>SQL Server Database Backup, SQL Server Database Restore</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;SQL Server BACKUP and RESTORE&lt;/strong&gt;&lt;br /&gt;Restoring a database backup re-creates the database and all of its associated files that were in the database when the backup was completed.&lt;br /&gt;However, any modifications made to the database after the backup was created are lost. To restore transactions made after the database backup was created, you must use transaction log backups or differential backups.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;br /&gt;1. Copies all of the data from the backup into the database.&lt;br /&gt;&lt;br /&gt;2. Rolls back any incomplete transactions in the database backup to ensure that the database is consistent.&lt;br /&gt;&lt;br /&gt;3. To prevent overwriting a database unintentionally, the restore operation performs safety checks automatically. The restore operation fails if: the database name in the restore operation does not match the database name recorded in the backup set.&lt;br /&gt;&lt;br /&gt;4. The database named in the restore operation already exists on the server but is not the same database contained in the database backup. For example, the database names are the same, but each database was created differently.&lt;br /&gt;&lt;br /&gt;5. One or more files need to be created automatically by the restore operation, but the file names already exist. These safety checks can be disabled if the intention is to overwrite another database.&lt;br /&gt;If you restore a database on a different instance of SQL Server than the one on which the backup was created, you may need to run sp_change_users_login to update user login information.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;Tags: backup, database, restore, sql server database back up, sql server database restore, MSSQL database back up, mssql database restore&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-3831863172854818538?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/3831863172854818538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=3831863172854818538' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/3831863172854818538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/3831863172854818538'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/04/backup-and-restore.html' title='SQL Server Database Backup, SQL Server Database Restore'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-4949190315050147887</id><published>2008-04-25T23:25:00.000-07:00</published><updated>2010-12-30T03:22:13.195-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='sp_change_users_login'/><category scheme='http://www.blogger.com/atom/ns#' term='msssql'/><category scheme='http://www.blogger.com/atom/ns#' term='sp'/><title type='text'>sp_change_users_login - Link users to corresponding logins</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Introduction:&lt;br /&gt;&lt;/strong&gt;Although the terms login and user are often used interchangeably, they are very different. A login is used for user authentication and a database user account is used for database access and permissions validation. Logins are associated to users by the security identifier (SID). A login is required for access to the SQL Server server. The process of verifying that a particular login is valid is called "authentication". This login must be associated to a SQL Server database user. You use the user account to control activities performed in the database. If no user account exists in a database for a specific login, the user that is using that login cannot access the database even though the user may be able to connect to the SQL Server server. The single exception to this situation is when the database contains the "guest" user account. A login that does not have an associated user account is mapped to the guest user. Conversely, if a database user exists but there is no login associated, the user is not able to log into SQL Server server.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Purpose:&lt;/strong&gt;&lt;br /&gt;The sp_change_users_login procedure has a specific purpose. It’s used to identify and correct users within a database which do not have a corresponding logins.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Scenario:&lt;br /&gt;&lt;/strong&gt;When a database is restored to a different server it contains a set of users and permissions but there may not be any corresponding logins or the logins may not be associated with the same users. A mismatch may occur between the security identification numbers (SIDs) of the logins in the master database and the users in the user database. An example of when this would happen is when you are restoring a database from Production to QA.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Syntax:&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;sp_change_users_login [ @Action = ] 'action' [ , [ @UserNamePattern = ] 'user' ] [ , [ @LoginName = ] 'login' ] [ , [ @Password = ] 'password' ]&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Action:&lt;/strong&gt; Describes the action to be performed.&lt;br /&gt;Can be one of these values:&lt;br /&gt;&lt;br /&gt;Value: &lt;strong&gt;Auto_Fix&lt;/strong&gt;&lt;br /&gt;Description: Links a user entry in the sysusers table in the current database to a login of the same name in sysxlogins. You should check the result from the Auto_Fix statement to confirm that the correct link is in fact made. Avoid using Auto_Fix in security-sensitive situations.&lt;br /&gt;When using Auto_Fix, you must specify user and password; login must be NULL. user must be a valid user in the current database.&lt;br /&gt;Value: &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Report&lt;br /&gt;&lt;/strong&gt;Description: Lists the users and corresponding security identifiers (SID) in the current database that are not linked to any login.&lt;br /&gt;user, login, and password must be NULL or not specified.&lt;br /&gt;Value: &lt;strong&gt;Update_One&lt;/strong&gt;&lt;br /&gt;Description: Links the specified user in the current database to login. login must already exist. user and login must be specified. password must be NULL or not specified.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;UserNamePattern:&lt;/strong&gt;&lt;br /&gt;It is the name of a SQL Server user in the current database.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;LoginName:&lt;/strong&gt;&lt;br /&gt;It is the name of a SQL Server login.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Password:&lt;br /&gt;&lt;/strong&gt;It is the password assigned to a new SQL Server login created by Auto_Fix. If a matching login already exists, the user and login are mapped and password is ignored. If a matching login does not exist, sp_change_users_login creates a new SQL Server login and assigns password as the password for the new login.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;How to test the scenario?&lt;br /&gt;&lt;/strong&gt;1.&lt;br /&gt;Add a login to the master database, and specify the default database as Northwind:&lt;br /&gt;Use master go sp_addlogin 'test', 'password', 'Northwind'&lt;br /&gt;2.&lt;br /&gt;Grant access to the user you just created:&lt;br /&gt;Use Northwind go sp_grantdbaccess 'test'&lt;br /&gt;3.&lt;br /&gt;Backup the database.&lt;br /&gt;BACKUP DATABASE Northwind TO DISK = 'C:\MSSQL\BACKUP\Northwind.bak'&lt;br /&gt;4.&lt;br /&gt;Restore the database to a different SQL Server server:&lt;br /&gt;RESTORE DATABASE Northwind FROM DISK = 'C:\MSSQL\BACKUP\Northwind.bak'&lt;br /&gt;The restored database contains a user named "test" without a corresponding login, which results in "test" being orphaned.&lt;br /&gt;5.&lt;br /&gt;Now, to detect orphaned users, run this code:&lt;br /&gt;Use Northwind go sp_change_users_login 'report'&lt;br /&gt;The output lists all the logins, which have a mismatch between the entries in the sysusers system table, of the Northwind database, and the sysxlogins system table in the master database.&lt;br /&gt;&lt;br /&gt;To re-link the user:&lt;br /&gt;Use Northwind go sp_change_users_login 'update_one', 'test', 'test'&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-4949190315050147887?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/4949190315050147887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=4949190315050147887' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/4949190315050147887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/4949190315050147887'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/04/spchangeuserslogin.html' title='sp_change_users_login - Link users to corresponding logins'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8301166796291327612.post-1161880473387114241</id><published>2008-04-22T21:49:00.000-07:00</published><updated>2011-06-24T00:39:29.213-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='Database Tables'/><category scheme='http://www.blogger.com/atom/ns#' term='DRL'/><category scheme='http://www.blogger.com/atom/ns#' term='DCL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Introduction'/><category scheme='http://www.blogger.com/atom/ns#' term='TCL'/><category scheme='http://www.blogger.com/atom/ns#' term='DDL'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><category scheme='http://www.blogger.com/atom/ns#' term='sqlserver'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Keywords'/><category scheme='http://www.blogger.com/atom/ns#' term='DML'/><title type='text'>SQL Basics (DDL,DML,DCL,TCL,SQL Keywords, SQL Syntax)</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;SQL - Structured Query Language&lt;/span&gt; &lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;strong&gt;INTRODUCTION&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;SQL is divided into the following:&lt;br /&gt;1) Data Definition Language (DDL)&lt;br /&gt;2) Data Manipulation Language (DML)&lt;br /&gt;3) Data Retrieval Language (DRL)&lt;br /&gt;4) Transaction Control Language (TCL)&lt;br /&gt;5) Data Control Language (DCL)&lt;br /&gt;&lt;br /&gt;DDL -- create, alter, drop, truncate, rename&lt;br /&gt;DML -- insert, update, delete&lt;br /&gt;DRL -- select&lt;br /&gt;TCL -- commit, rollback, savepoint&lt;br /&gt;DCL -- grant, revoke&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Create Table Syntax:&lt;/strong&gt;&lt;br /&gt;Create table table_name (col1 datatype1, col2 datatype2 …coln datatypen)&lt;br /&gt;&lt;strong&gt;Insert Syntax:&lt;/strong&gt;&lt;br /&gt;Case 1: insert into table_name values (value1, value2, value3 …. Valuen)&lt;br /&gt;Case 2:insert into table_name(col1, col2, col3 … Coln) values (value1, value2, value3.. Valuen)&lt;br /&gt;&lt;strong&gt;Select Syntax:&lt;/strong&gt;&lt;br /&gt;Select * from table_name -- here * indicates all columns&lt;br /&gt;or&lt;br /&gt;Select col1, col2, … coln from table_name&lt;br /&gt;&lt;strong&gt;Update Syntax:&lt;/strong&gt;&lt;br /&gt;Update table_name set col1 = value1, col2 = value2 where condition&lt;br /&gt;&lt;strong&gt;Delete Syntax:&lt;/strong&gt;&lt;br /&gt;Delete from table_name where condition&lt;br /&gt;&lt;strong&gt;Truncate Syntax:&lt;/strong&gt;&lt;br /&gt;truncate table table_name&lt;br /&gt;&lt;strong&gt;Drop Syntax:&lt;/strong&gt;&lt;br /&gt;Drop table table_name&lt;br /&gt;&lt;strong&gt;Rename Syntax:&lt;/strong&gt;&lt;br /&gt;rename old_table_name to new_table_name&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;CONDITIONAL SELECTIONS AND OPERATORS&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;We have two clauses used in this&lt;br /&gt;1. Where&lt;br /&gt;2. Order by&lt;br /&gt;&lt;strong&gt;1. Using Where:&lt;/strong&gt;&lt;br /&gt;select * from table_name where condition&lt;br /&gt;The following are the different types of operators used in where clause:&lt;br /&gt;a. Arithmetic operators&lt;br /&gt;b. Comparison operators&lt;br /&gt;c. Logical operators&lt;br /&gt;&lt;strong&gt;Arithmetic operators&lt;/strong&gt; -- highest precedence&lt;br /&gt;+, -, *, /&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Comparison operators&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;(1) =, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, &amp;lt;&amp;gt;&lt;br /&gt;(2) between, not between&lt;br /&gt;(3) in, not in&lt;br /&gt;(4) null, not null&lt;br /&gt;(5) like&lt;br /&gt;&lt;strong&gt;Logical operators&lt;/strong&gt;&lt;br /&gt;(1) And&lt;br /&gt;(2) Or -- lowest precedence&lt;br /&gt;(3) not&lt;br /&gt;&lt;strong&gt;Using NULL&lt;/strong&gt;&lt;br /&gt;This will gives the output based on the null values in the specified column.&lt;br /&gt;Syntax:&lt;br /&gt;Select * from table_name where col is null&lt;br /&gt;&lt;strong&gt;2. Using Order by:&lt;/strong&gt;&lt;br /&gt;This will be used to ordering the columns data (ascending or descending).&lt;br /&gt;Syntax:&lt;br /&gt;Select * from table_name order by col desc&lt;br /&gt;By default database server will use ascending order.&lt;br /&gt;If you want output in descending order you have to use desc keyword after the column.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;strong&gt;SUB QUERIES&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:verdana;"&gt;-- Nesting of queries, one within the other is termed as a subquery.&lt;br /&gt;-- A statement containing a subquery is called a parent query.&lt;br /&gt;-- Subqueries are used to retrieve data from tables that depend on the values in the table itself.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Types&lt;br /&gt;&lt;/strong&gt;1. Single row subqueries&lt;br /&gt;2. Multi row subqueries&lt;br /&gt;3. Multiple subqueries&lt;br /&gt;4. Correlated subqueries&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Single Row Sub Queries&lt;/strong&gt;&lt;br /&gt;In single row subquery, it will return one value.&lt;br /&gt;Ex: select * from emp where sal &amp;gt; (select sal from emp where empno = 7566)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;MultiRow Sub Queries&lt;/strong&gt;&lt;br /&gt;In multi row subquery, it will return more than one value. In such cases we should include operators like any, all, in or not in between the comparision operator and the subquery.&lt;br /&gt;Ex:&lt;br /&gt;select * from emp where sal &amp;gt; any (select sal from emp where sal between 2500 and 4000)&lt;br /&gt;select * from emp where sal &amp;gt; all (select sal from emp where sal between 2500 and 4000)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Multiple Sub Queries&lt;/strong&gt;&lt;br /&gt;There is no limit on the number of subqueries included in a where clause. It allows nesting of a query within a subquery.&lt;br /&gt;Ex:&lt;br /&gt;select * from emp where sal = (select max(sal) from emp where sal &amp;lt; (select max(sal) from emp))  &lt;strong&gt;Correlated Sub Queries&lt;/strong&gt;&lt;br /&gt;A subquery is evaluated once for the entire parent statement where as a correlated subquery is evaluated once for every row processed by the parent statement.&lt;br /&gt;Ex:&lt;br /&gt;select distinct deptno from emp e where 5 &amp;lt;= (select count(ename) from emp where e.deptno = deptno)  &lt;strong&gt;Using Exists:&lt;/strong&gt;&lt;br /&gt;Suppose we want to display the department numbers which has more than 4 employees,&lt;br /&gt;select deptno,ename from emp e1 where exists (select * from emp e2 where e1.deptno=e2.deptno group by e2.deptno having count(e2.ename) &amp;gt; 4) order by deptno,ename&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);font-family:verdana;"&gt;&lt;strong&gt;SET OPERATORS&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;Types&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;-- Union&lt;br /&gt;-- Union all&lt;br /&gt;-- Intersect&lt;br /&gt;-- Minus&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;UNION&lt;br /&gt;&lt;/strong&gt;This will combine the records of multiple tables having the same structure.&lt;br /&gt;Ex:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;select * from student1 union select * from student2&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;UNION ALL&lt;/strong&gt;&lt;br /&gt;This will combine the records of multiple tables having the same structure but including duplicates.&lt;br /&gt;Ex:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;select * from student1 union all select * from student2&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;INTERSECT&lt;/strong&gt;&lt;br /&gt;This will give the common records of multiple tables having the same structure.&lt;br /&gt;Ex:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;select * from student1 intersect select * from student2&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;MINUS&lt;/strong&gt;&lt;br /&gt;This will give the records of a table whose records are not in other tables having the same structure.&lt;br /&gt;Ex:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;select * from student1 minus select * from student2&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;Tags: SQL Basics, SQL Introduction, DDL, DML, DRL, DCL, TCL, Database Tables, SQL Keywords&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8301166796291327612-1161880473387114241?l=sqlfactor.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlfactor.blogspot.com/feeds/1161880473387114241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8301166796291327612&amp;postID=1161880473387114241' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/1161880473387114241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8301166796291327612/posts/default/1161880473387114241'/><link rel='alternate' type='text/html' href='http://sqlfactor.blogspot.com/2008/04/sql.html' title='SQL Basics (DDL,DML,DCL,TCL,SQL Keywords, SQL Syntax)'/><author><name>Sree</name><uri>http://www.blogger.com/profile/06403327332608212296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/-JpwkK6MUNu8/TxfBIqLMkwI/AAAAAAAAAM0/hqL5kgmnKkQ/s220/sf_cert_dev_rgb.png'/></author><thr:total>2</thr:total></entry></feed>
