<?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-7210653247696739168</id><updated>2011-11-28T05:27:37.535+05:30</updated><category term='AWR of SQL Server'/><category term='SQL Server performance monitoring'/><title type='text'>Database Centre</title><subtitle type='html'>This blog is to share and exchange information related to databases</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-1554238675669843186</id><published>2011-07-14T16:19:00.002+05:30</published><updated>2011-07-14T16:25:42.064+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server performance monitoring'/><category scheme='http://www.blogger.com/atom/ns#' term='AWR of SQL Server'/><title type='text'>SQL Server 2008 Performance Data Collector</title><content type='html'>Performance Tuning in SQL Server is still tricky. SQL Server had provided various tools to monitor performance like Profiler, PerfMon, Management Studio’s, DMVs (Dynamic Management Views) and so on. Some of these tools collects database logs and generate report in order to help DBA’s to identify problems areas themselves and take necessary steps. But still getting a consolidated report which helps to identify which process is taking lot of time is a problem and not very straight forward.&lt;br /&gt;&lt;br /&gt;SQL Server 2008 introduced Performance Data collector to overcome some of these limitations. Here we will see what exactly performance Data collector is and what it does.&lt;br /&gt;&lt;br /&gt;Performance Data Collector is performance tools introduced in SQL Server 2008. It can collect data from single or multiple SQL Server instances and diagnostically analyze this information to generate reports. The activities of Performance Data Collected can be broadly classified into three categories.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Collects Data:&lt;br /&gt;&lt;/strong&gt;SQL Server 2008 comes with three built-in Data Collection Sets: one is to collect Disk Usage information; another is used to collect Query Statistics, and the third is used to collect a wide variety of Server Activities. According to Microsoft, these three Data Collection Sets collect the essential data needed to identify and troubleshoot most common SQL Server performance problems. If you don’t think the data that is collected is enough, you can create your own custom Data Collection Sets.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Central Repository:&lt;br /&gt;&lt;/strong&gt;All data collected by Data Collection Sets are stored in a centralized location called Management Data Warehouse (MDW). MDW can store data from single or multiple SQL Server Instances. While currently the focus of MDW is to store only performance related data, but in future version of SQL Server this will store virtually any data you want to collect from SQL Server, such as Extended Events, Audit data etc. The MDW is extensible, so if you are up to the task, you can store your own data in the MDW.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Performance Reports:&lt;br /&gt;&lt;/strong&gt;Data collected in MDW are diagnostically analyzed and reports are generated. SQL Server 2008 includes three built-in reports; Disk Usage Summary, Query Statistics History, and Server Activity History.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-1554238675669843186?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/1554238675669843186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/1554238675669843186'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2011/07/sql-server-2008-performance-data.html' title='SQL Server 2008 Performance Data Collector'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-1861201500582416240</id><published>2010-06-18T17:02:00.003+05:30</published><updated>2010-06-18T17:25:13.851+05:30</updated><title type='text'>Sorting version numbers</title><content type='html'>We already know that every product has some version numbers usually in combination of dots eg. 1.1 or 1.2.1 etc . If we have these number stored in a table, then we can not simply sort them by issuing ORDER BY Clause. Here we will see how to sort them in ascending or descending order.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CREATE TABLE version_list&lt;br /&gt;(&lt;br /&gt;ID NUMBER(10),&lt;br /&gt;VERSION VARCHAR2(30)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INSERT INTO version_list VALUES&lt;br /&gt;(1, ‘10.2.3’);&lt;br /&gt;&lt;br /&gt;INSERT INTO version_list VALUES&lt;br /&gt;(2, ‘9.1.2’);&lt;br /&gt;&lt;br /&gt;INSERT INTO version_list VALUES&lt;br /&gt;(3, ‘10.1.2’);&lt;br /&gt;&lt;br /&gt;SELECT * &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;FROM version_list &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ORDER BY version;&lt;br /&gt;10.2.3&lt;br /&gt;9.1.2&lt;br /&gt;10.1.2&lt;br /&gt;You can see that the output is not sorted.&lt;br /&gt;&lt;br /&gt;SELECT *&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;FROM version_list&lt;br /&gt;ORDER BY TO_NUMBER(REPLACE(version, '', ''));&lt;br /&gt;9.1.2&lt;br /&gt;10.1.2&lt;br /&gt;10.2.3&lt;br /&gt;&lt;/span&gt;Now you can see that the output is sorted. We had strip all dots from the version_list and then issued ORDER BY and it worked.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-1861201500582416240?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/1861201500582416240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=1861201500582416240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/1861201500582416240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/1861201500582416240'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2010/06/sorting-version-numbers.html' title='Sorting version numbers'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-79516160685293111</id><published>2010-06-13T17:48:00.018+05:30</published><updated>2011-02-22T17:57:54.173+05:30</updated><title type='text'>Introduction to Data warehousing</title><content type='html'>&lt;strong&gt;Summary&lt;/strong&gt;&lt;br /&gt;In this article we will learn what is a Data warehouse? Why do we need a data warehouse? What are the characteristics of a Data warehouse? And finally go through some of the popular approaches for designing a Data warehouse.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is Data Warehousing?&lt;/strong&gt;&lt;br /&gt;Ralph Kimball states that a data warehouse is a “Copy of transaction data specifically structured for query and analysis”&lt;br /&gt;&lt;br /&gt;In other words; data is extracted periodically from production databases and copied onto special repository database. There it is validated, reformatted, reorganized, summarized, restructured, and merged with data from other sources. The resulted database is used to generate various summarized and ad-hoc reports, which in turn help in identifying future trends and decision making.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Why do we need a Data warehouse?&lt;/strong&gt;&lt;br /&gt;In today’s challenging times and cut-throat competition, there is a need to identify current trends, predict future trends and takes appropriate decision accordingly. Good decision can be taken only when we have all the relevant data available. Here the need of a good Data warehouse comes. A Data warehouse collects data from disparate sources and integrates them into a single source. Analysis is done using this centralized source.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a name="_Toc260411011"&gt;&lt;strong&gt;Advantages and Disadvantages of a Data warehouse&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;br /&gt;- Large quantify of information consolidate into one location from disparate sources is available for analysis.&lt;br /&gt;- Data warehouses facilitate decision support system applications such as trend reports (e.g., the items with the most sales in a particular area within the last two years), exception reports, and reports that show actual performance versus goals.&lt;br /&gt;- Prior to loading data into data warehouse all data inconsistencies are identified and removed. This greatly simplifies reporting and analysis.&lt;br /&gt;- Since Data warehouse is separate from operational system, they do not affect or slow down the operational system.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;br /&gt;- Data warehouse system is complex in nature and they require skilled technical peoples and project managers.&lt;br /&gt;- Setting up a Data warehouse is very expensive and time consuming.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc260411012"&gt;&lt;strong&gt;Characteristics of a Data warehouse&lt;/strong&gt;&lt;/a&gt;:&lt;strong&gt; &lt;/strong&gt;&lt;br /&gt;According to Bill Inmon "A warehouse is a subject-oriented, integrated, time-variant and non-volatile collection of data in support of management's decision making process"&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Characteristics of a Data warehouse are explained below:&lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;Subject-oriented:&lt;/strong&gt; Information is present based on specific subject. Data is organized in such a way that data related to all real word elements are linked together. E.g. in operational database data will be grouped based on Loans, Savings, Demat etc. where as in warehouse data will be grouped based on subject like Customer, Vendor, Product etc.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Non-volatile:&lt;/strong&gt; Data once entered is never updated or deleted. It is remains static and read-only for future reference.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Integrated:&lt;/strong&gt; Data warehouse contains data from different operational data sources (OLTP) into a single integrated database.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Time Variant:&lt;/strong&gt; Data warehouses are time variant in the sense that they maintain both historical and (nearly) current data.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Accessible:&lt;/strong&gt; The primary purpose of a data warehouse is to provide readily available information to the en-users.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc260411013"&gt;&lt;strong&gt;Implementation Methods&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;These are broadly two main approaches for designing a warehouse.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc260411014"&gt;&lt;strong&gt;Top-down Approach&lt;/strong&gt;&lt;/a&gt; &lt;a href="http://1.bp.blogspot.com/_4ubN5QTiZfU/TBTPk4pvbCI/AAAAAAAABi8/-9XGPqxW92s/s1600/TopDownApproach.jpg"&gt;&lt;img style="MARGIN: 0px 0px 10px 10px; WIDTH: 293px; FLOAT: right; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5482234879006436386" border="0" alt="" src="http://1.bp.blogspot.com/_4ubN5QTiZfU/TBTPk4pvbCI/AAAAAAAABi8/-9XGPqxW92s/s320/TopDownApproach.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;This is a Bill Inmon’s approach. In this approach data is extracted from operational system and loaded into staging area. Here the data is cleansed, consolidated and validated to ensure its accuracy and then transferred to Enterprise Data warehouse (EDW). The Data in EDW is usually in normalized form to avoid redundancy and have a detailed and true version of data. After EDW is in place, subject area specific data-marts are created which have data in de-normalized form and in a summary format.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Top-down approach should be used when:&lt;br /&gt;&lt;/strong&gt;We have complete clarity of Business requirements related to all verticals.&lt;br /&gt;We are ready to invest considerable time and money.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc260411015"&gt;&lt;strong&gt;Bottom-up Approach&lt;/strong&gt;&lt;/a&gt;: &lt;a href="http://3.bp.blogspot.com/_4ubN5QTiZfU/TBTRGjai7oI/AAAAAAAABjE/H4mzVUn7QnA/s1600/BottomUpApproach.jpg"&gt;&lt;img style="MARGIN: 0px 0px 10px 10px; WIDTH: 281px; FLOAT: right; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5482236556932738690" border="0" alt="" src="http://3.bp.blogspot.com/_4ubN5QTiZfU/TBTRGjai7oI/AAAAAAAABjE/H4mzVUn7QnA/s320/BottomUpApproach.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;This is a Ralph Kimball’s approach. In this approach data marts are build first and then gradually the final Enterprise Data Warehouse (EDW) is build by integrating different data marts. Here separate data marts are combined based on Conformed dimensions and Conformed Facts. A Conformed dimensions and Conformed Facts can be shared across data marts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Bottom-up approach should be used when:&lt;br /&gt;&lt;/strong&gt;We have time and money constraint.&lt;br /&gt;We do not complete clarity of all verticals of Business and have clarity of only one or two business vertical.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc260411016"&gt;&lt;strong&gt;Data warehousing Terms&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Fact Table:&lt;/strong&gt; A Fact table consists of the measurements, metrics or facts of a business process. It is often located at the centre of a star schema or a snowflake schema, surrounded by dimension tables. E.g. In a banking data warehouse accounting and balances will be stored in a Fact table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Dimension Table: &lt;/strong&gt;A dimension table consists of textual representation of the business process. E.g. In a banking data warehouse accounting and balances will be stored in a Fact table where as customer name, address, mobile numbers will be stored in the dimension table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Cube:&lt;/strong&gt; Cube is a logical schema which contains facts and dimensions&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Star Schema: &lt;/strong&gt;Star Schema is simplest data warehouse schema which consists of a few fact tables and multiple dimension tables connected to fact table.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Snowflake Schema: &lt;/strong&gt;Snowflake schema is a variation of Star schema where dimension table are normalized into multiple related tables. Fact table remains same similar to Star schema.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Data Mart:&lt;/strong&gt; Data marts are analytical data stores designed to focus on specific business functions for a specific community within an organization. A single Data warehouse may have multiple data marts.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Extract Transform and Load (ETL):&lt;/strong&gt; It is a process through which data is extracted from disparate sources, transformed as per the requirement and loaded to the target database.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Operational Data Store (ODS):&lt;/strong&gt; It comes between Staging Area and Data warehouse. Data is extracted from OLTP system to stating area and then after cleansing and validation, data is loaded into ODS. Later on data is summarized and loaded into Data warehouse.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Data Mining: &lt;/strong&gt;Data mining (sometimes called data or knowledge discovery) is the process of analyzing data from different perspectives and summarizing it into useful information - information that can be used to increase revenue, cuts costs, or both.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Business Intelligence (BI): &lt;/strong&gt;Business intelligence (BI) is a broad category of applications and technologies for gathering, storing, analyzing, and providing access to data to help enterprise users make better business decisions. It involves data mining, business performance management, benchmarking, text mining, and predictive analytics&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name="_Toc260411020"&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;We had learn that in Data warehousing data is collected from different sources, cleansed, validated, summarized and stored in a separate repository called data warehouse. This data is then analyzed from different perspective in order to take good business decisions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-79516160685293111?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/79516160685293111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=79516160685293111' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/79516160685293111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/79516160685293111'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2010/06/introduction-to-data-warehousing.html' title='Introduction to Data warehousing'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_4ubN5QTiZfU/TBTPk4pvbCI/AAAAAAAABi8/-9XGPqxW92s/s72-c/TopDownApproach.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-2735153847639456866</id><published>2008-07-28T20:24:00.001+05:30</published><updated>2008-08-05T15:15:04.978+05:30</updated><title type='text'>Sorting: Character should come first</title><content type='html'>When we issue ORDER BY clause Oracle engine sorts data in an ascending order by first bringing all numeric data and then character data. As you can see below:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SELECT id FROM test ORDER BY id;&lt;br /&gt;ID&lt;br /&gt;---&lt;br /&gt;1&lt;br /&gt;2&lt;br /&gt;3&lt;br /&gt;A&lt;br /&gt;B&lt;br /&gt;C&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There could be case when we want character data to come first and then numeric data. This can be achieved by simple manipulation of ORDER BY clause as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;SELECT id FROM test&lt;br /&gt;ORDER BY DECODE(REGEXP_REPLACE(id, ‘\d+’), null, 1, 0);&lt;br /&gt;ID&lt;br /&gt;---&lt;br /&gt;A&lt;br /&gt;B&lt;br /&gt;C&lt;br /&gt;1&lt;br /&gt;2&lt;br /&gt;3&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;REGEXP_REPLACE is a regular expression function introduced in Oracle 10g. Here by using this function we are identifying all numeric data and replacing it with NULL. After that using DECODE function all NULLs are replaced with 1 and the remaining character data is replaced with 0. Hay this is only done in ORDER BY field NOT IN SELECT. Now we can ensure that zero (character data) obviously comes before 1 (numeric data in our case).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-2735153847639456866?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/2735153847639456866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=2735153847639456866' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/2735153847639456866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/2735153847639456866'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2008/07/sorting-character-should-come-first.html' title='Sorting: Character should come first'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-3053486756473825717</id><published>2008-07-03T03:16:00.002+05:30</published><updated>2009-07-20T15:45:14.062+05:30</updated><title type='text'>Loading data into Oracle from Text File</title><content type='html'>&lt;div class="Section1"&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-family:Verdana;"&gt;&lt;p class="MsoNormal"&gt;SQLLOADER is a bulk loader utility used to move data from external files into oracle database. Simple example of loading external file is given below.&lt;/p&gt;&lt;p class="MsoNormal"&gt;First you need to create a control file which should look similar to the below example&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;CONTROL FILE:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;OPTIONS ( SKIP=1)&lt;br /&gt;LOAD DATA&lt;br /&gt;INFILE 'C:\TextFile\emp.csv'&lt;br /&gt;BADFILE 'C:\TextFile\emp.bad'&lt;br /&gt;DISCARDFILE 'C:\TextFile\emp.dsc'&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;INTO TABLE "SCOTT"."EMP"&lt;br /&gt;INSERT FIELDS TERMINATED BY ','&lt;br /&gt;OPTIONALLY ENCLOSED BY '"'TRAILING NULLCOLS&lt;br /&gt;(&lt;br /&gt;EMP_ID sequence(Max, 1),&lt;br /&gt;EMP_NAME,&lt;br /&gt;EMP_DEPT,&lt;br /&gt;EMP_ADDRESS,&lt;br /&gt;EMP_DOB&lt;br /&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;If your .csv file has headers then you need to add SKIP = 1.&lt;/p&gt;&lt;p class="MsoNormal"&gt;You need to make sure that you have emp.csv exist in the given location. Other files like .bad and .dsc will be generated by sqlloader itself, if required.&lt;/p&gt;&lt;p class="MsoNormal"&gt;Now save this control file on any directory (eg. c:\LoadTest\Emp.ctl)&lt;/p&gt;&lt;p class="MsoNormal"&gt;To execute this, Type following command in the command prompt&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; "&gt;c:\sqlldr userid=scott/tiger@orcl control=c:\LoadTest\Emp.ctl log=c:\LoadTest\Emp.log&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-3053486756473825717?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/3053486756473825717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=3053486756473825717' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/3053486756473825717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/3053486756473825717'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2008/07/loading-data-into-oracle-from-text-file.html' title='Loading data into Oracle from Text File'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-647601383143738239</id><published>2008-07-03T03:15:00.004+05:30</published><updated>2009-07-20T15:43:08.177+05:30</updated><title type='text'>Copying table from one database instance to another without using dblink</title><content type='html'>&lt;div class="Section1"&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Times New Roman;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: auto;"&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse;"&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; "&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;Copy to UserId/Pwd@MyDB&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;create NewTable(field1)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;using select * from temp1;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here MyDB is the TNS name of your database.&lt;/div&gt;&lt;div&gt;Here there is no need to create DBLink.&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Times New Roman;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-647601383143738239?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/647601383143738239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=647601383143738239' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/647601383143738239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/647601383143738239'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2008/07/copying-table-from-one-database-to.html' title='Copying table from one database instance to another without using dblink'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-477600541629586653</id><published>2008-07-03T03:10:00.001+05:30</published><updated>2008-07-18T15:42:32.324+05:30</updated><title type='text'>Querying current value of sequence without incrementing it</title><content type='html'>&lt;span style="font-family:verdana;"&gt;As we know when we use SequenceName.NextVal, sequence got increment by whatever increment number is defined while it was created&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Eg.&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CREATE SEQUENCE seq1&lt;br /&gt;START WITH 1&lt;br /&gt;INCREMENT BY 1&lt;br /&gt;CACHE 20;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;If we try to issue &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;SELECT seq1.CurrVal FROM dual &lt;span style="font-family:verdana;"&gt;without issuing se1.NextVal. It &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;will give error stating that sequence is not yet defined in this session. But, if we use seq1.NextVal, it will increment sequence by 1 which we don’t want. So here is one easy way for getting this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ALTER SEQUENCE seq1 NOCACHE;&lt;br /&gt;SELECT last_number FROM user_sequences WHERE sequence_name = ‘seq1’;&lt;br /&gt;ALTER SEQUENCE seq1 CACHE 20; --* or whatever is defined earlier&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/7210653247696739168-477600541629586653?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/477600541629586653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=477600541629586653' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/477600541629586653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/477600541629586653'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2008/07/querying-current-value-of-view-without.html' title='Querying current value of sequence without incrementing it'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-7128611525517462310</id><published>2008-07-03T03:04:00.001+05:30</published><updated>2008-07-03T03:08:18.741+05:30</updated><title type='text'>Loading data into text file from Oracle</title><content type='html'>&lt;div class="Section1"&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;div style="BORDER-RIGHT: #2f6fab 1pt dashed; PADDING-RIGHT: 12pt; BORDER-TOP: #2f6fab 1pt dashed; PADDING-LEFT: 12pt; BACKGROUND: #f9f9f9; PADDING-BOTTOM: 12pt; BORDER-LEFT: #2f6fab 1pt dashed; PADDING-TOP: 12pt; BORDER-BOTTOM: #2f6fab 1pt dashed; mso-element: para-border-div"&gt;&lt;pre&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt;set colsetp,&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt;set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt;spool oradata.txt&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt;SELECT col1  ','  col2  ','  col3&lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt;FROM tab1&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt; WHERE col2 = 'XYZ';&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Courier New;color:black;"&gt;&lt;span style="color:windowtext;"&gt;spool off&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-7128611525517462310?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/7128611525517462310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=7128611525517462310' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/7128611525517462310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/7128611525517462310'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2008/07/loading-data-into-text-file-from-oracle.html' title='Loading data into text file from Oracle'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-6375355747188882344</id><published>2007-11-20T14:44:00.000+05:30</published><updated>2008-07-03T05:39:15.045+05:30</updated><title type='text'>Finding a Leap Year</title><content type='html'>We all very well know what a leap year is? A year which has 366 days is called a leap year. But how many of us know how do you know which year is a leap year? Do you know which calendar year will have 29 days in the month of February?&lt;br /&gt;&lt;br /&gt;Most of us have a very wrong perception of a Leap year. If you ask any person how do you calculate a Leap year? His obvious reply will be divide the year by 4, if it gets divided then it is a leap year. Well that seems to be very simple, so why do we need a function to calculate a leap year?&lt;br /&gt;&lt;br /&gt;Actually leap year is some thing more then divide by 4. First you need to check whether a year gets divided by 4, if it gets divided by 4 then ensure that it does not get divided by 100, if it does not get divided by 100 then it is a leap year. But, if it gets divided by 100 then it should also get divided by 400 in order to be a leap year.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This function takes year as an input and returns 1, if it is a leap year and 0 if it is not a leap year.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;CREATE OR REPLACE FUNCTION IsLeapYear&lt;br /&gt;(&lt;br /&gt;p_year IN NUMBER&lt;br /&gt;)&lt;br /&gt;RETURN NUMBER&lt;br /&gt;&lt;br /&gt;IS&lt;br /&gt;&lt;br /&gt;v_chkLeapYr NUMBER;&lt;br /&gt;X NUMBER;&lt;br /&gt;&lt;br /&gt;BEGIN &lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&lt;br /&gt;--**Leap Year Calculation&lt;br /&gt;&lt;br /&gt;SELECT DISTINCT MOD(p_year, 4) INTO v_chkLeapYr FROM DUAL;&lt;br /&gt;&lt;br /&gt;IF v_chkLeapYr = 0 THEN&lt;br /&gt;  IF mod(p_year,100) = 0 THEN --* If divided by 4 and not by 100 then LEAP YEAR&lt;br /&gt;    IF mod(p_year,400) = 0 THEN --* If divided by 4 and 100 then it should also get divided by 400 then LEAP YEAR&lt;br /&gt;       X := 366;&lt;br /&gt;    ELSE&lt;br /&gt;       X := 365;&lt;br /&gt;    END IF;&lt;br /&gt;  ELSE&lt;br /&gt;    X := 366;&lt;br /&gt;  END IF;&lt;br /&gt;ELSE&lt;br /&gt;  X := 365;&lt;br /&gt;END IF;&lt;br /&gt;&lt;br /&gt;If x = 366 Then&lt;br /&gt;Return (1); --* Lear Year&lt;br /&gt;Else&lt;br /&gt;Return (0);&lt;br /&gt;End If;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;END IsLeapYear;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:85%;"  &gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-6375355747188882344?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/6375355747188882344/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=6375355747188882344' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/6375355747188882344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/6375355747188882344'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2007/11/finding-leap-year.html' title='Finding a Leap Year'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-137380155686097300</id><published>2007-10-30T17:48:00.000+05:30</published><updated>2007-10-30T18:22:22.318+05:30</updated><title type='text'>SQL Server: Function vs Stored Procedure</title><content type='html'>Functions are referred as &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;UDF&lt;/span&gt;&lt;/span&gt; (User Defined Functions) in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;SQL&lt;/span&gt;&lt;/span&gt; Server. There where no &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;UDF&lt;/span&gt;&lt;/span&gt; till &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;SQL&lt;/span&gt;&lt;/span&gt; Server 7.0. &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;UDF&lt;/span&gt;&lt;/span&gt; was first introduced in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;SQL&lt;/span&gt;&lt;/span&gt; Server 2000.&lt;br /&gt;&lt;br /&gt;Some of the difference between &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;UDF&lt;/span&gt;&lt;/span&gt; and Stored procedure given in &lt;a href="http://www.sqlmag.com/Articles/ArticleID/96745/96745.html"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;SQL&lt;/span&gt; Magazine&lt;/a&gt; are as follows:&lt;br /&gt;&lt;br /&gt;1) A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;UDF&lt;/span&gt; must return a value-a single result set. A stored procedure can return a value-or even multiple result sets-but doesn't have to.&lt;br /&gt;&lt;br /&gt;2) You can use a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;UDF&lt;/span&gt;&lt;/span&gt; directly in a SELECT statement as well as in ORDER BY, WHERE, and FROM clauses, but you can't use a stored procedure in a SELECT statement.&lt;br /&gt;&lt;br /&gt;3) A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;UDF&lt;/span&gt;&lt;/span&gt; can't use a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;nondeterministic&lt;/span&gt;&lt;/span&gt; function such as &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;GETDATE&lt;/span&gt;&lt;/span&gt;(), &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;NEWID&lt;/span&gt;&lt;/span&gt;(), or RAND(), whereas a stored procedure can use such functions. A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;nondeterministic&lt;/span&gt;&lt;/span&gt; function is one that can return a different result given the same input parameters.&lt;br /&gt;&lt;br /&gt;4) A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;UDF&lt;/span&gt;&lt;/span&gt; can't change server environment variables; a stored procedure can.&lt;br /&gt;&lt;br /&gt;5) A &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;UDF&lt;/span&gt;&lt;/span&gt; always stops execution of T-&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;SQL&lt;/span&gt;&lt;/span&gt; code when an error occurs, whereas a stored procedure continues to the next instruction if you've used proper error handling code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-137380155686097300?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/137380155686097300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=137380155686097300' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/137380155686097300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/137380155686097300'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2007/10/sql-server-function-vs-stored-procedure.html' title='SQL Server: Function vs Stored Procedure'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-943908067396090450</id><published>2007-08-23T14:14:00.000+05:30</published><updated>2007-10-30T18:36:47.382+05:30</updated><title type='text'>Oracle: Function vs Stored Procedure</title><content type='html'>&lt;strong&gt;Difference between procedure and funtion:&lt;/strong&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Function always have a returns value where as procedure does not have a return value, but you can use OUT parameter for this purpose.&lt;/li&gt;&lt;li&gt;Function can be used in SELECT statement where as procedure can not. eg. SELECT GetName(v_id) FROM DUAL;&lt;/li&gt;&lt;li&gt;You can have DML(Insert, Update, Delete) DDL(TRUNCATE, Drop), TCL(COMMIT, ROLLBACK) in a function but then you can not call that function in any SQL query.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-943908067396090450?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/943908067396090450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=943908067396090450' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/943908067396090450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/943908067396090450'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2007/08/difference-between-procedure-and.html' title='Oracle: Function vs Stored Procedure'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-7225264411894384541</id><published>2007-08-22T18:26:00.001+05:30</published><updated>2011-01-31T16:13:23.061+05:30</updated><title type='text'>Formatting SQL Code</title><content type='html'>Tired of formatting your code manually. Just try this online tool, its free!!&lt;br /&gt;&lt;a href="http://www.dpriver.com/pp/sqlformat.htm"&gt;http://www.dpriver.com/pp/sqlformat.htm&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-7225264411894384541?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/7225264411894384541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=7225264411894384541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/7225264411894384541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/7225264411894384541'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2007/08/formatting-code.html' title='Formatting SQL Code'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7210653247696739168.post-3784542992716554698</id><published>2007-08-22T17:21:00.001+05:30</published><updated>2010-09-20T11:52:22.902+05:30</updated><title type='text'>Oracle: EXISTS vs IN</title><content type='html'>We have a general perception that EXISTS is faster then IN. This is not always true. There can be some cases where IN performs better then EXISTS.&lt;br /&gt;&lt;br /&gt;This depends on the size of the tables (and data queried) Using "IN", the optimizer generally runs the subquery first, then joins with the main dataset (nested loops, merge, whatever). If the table in the subquery is small, and the table in the main query is large, then IN usually makes sense.&lt;br /&gt;&lt;br /&gt;Using "EXISTS", the optimizer generally runs the main query first, then applies that dataset to the subquery. If the table in the subquery is large, and the table in the main query is small, then EXISTS usually makes sense.&lt;br /&gt;&lt;br /&gt;By the way, Full Table Scan are not necessarily bad. If you are querying more than, say 15 - 20%, of the data in a table the Full Table Scan may be faster. Two Full Table Scans with a Hash Join are frequently gobs faster than a Nested Loops type of plan.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7210653247696739168-3784542992716554698?l=database-centre.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://database-centre.blogspot.com/feeds/3784542992716554698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7210653247696739168&amp;postID=3784542992716554698' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/3784542992716554698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7210653247696739168/posts/default/3784542992716554698'/><link rel='alternate' type='text/html' href='http://database-centre.blogspot.com/2007/08/oracle-exists-vs-in.html' title='Oracle: EXISTS vs IN'/><author><name>Danish</name><uri>http://www.blogger.com/profile/17109990371913690410</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
