tag:blogger.com,1999:blog-89197606156976114682024-03-18T21:37:16.947-07:00.A tour of Microsoft Technology with Pankaj TiwariPankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.comBlogger88125tag:blogger.com,1999:blog-8919760615697611468.post-78513132499126638912014-02-04T11:12:00.000-08:002014-02-15T07:41:34.238-08:00.NET - Web Services Interview Questions<div dir="ltr" style="text-align: left;" trbidi="on"><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">What is a "Web Service"?</span></b></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;"><br /></span></b></span></div><div><span style="font-family: Verdana, sans-serif;"><span style="background-color: white;">A "Web Service" is a .NET component that replies to HTTP requests that are formatted using SOAP syntax. </span><span style="background-color: white;">Web services are one of the cornerstones of the .NET initiative in that they allow a degree of interoperability among applications over the internet that was inconceivable before.</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">How are web services implemented in .NET?</span></b></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;"><br /></span></b></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">Web services are implemented as HTTP Handlers that intercept requests to .asmx files.</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">What are the drawbacks of "Response Caching"?</span></b></span></div><div><span style="background-color: white;"><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: Verdana, sans-serif;"> </span></span></span></div><div><span style="font-family: Verdana, sans-serif;"><span style="background-color: white;">If the method or accepts a wide range of values, response caching might be inefficient or even wasteful because a great deal of information might be stored in caching. </span><span style="background-color: white;">If the method depends on other information not supplied in parameters (like user authentication or session data), it will be bypassed.</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">The method will be bypassed even if it needs to perform actions other than returning values (like writing to a log file)</span></span></div><div><span style="font-family: Verdana, sans-serif;"><br /></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">How to overcome the limitations of response caching while providing an acceptable level of caching?</span></b></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;"><br /></span></b></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">By using data caching (System.Web.Caching.Cach)</span></span></div><div><span style="font-family: Verdana, sans-serif;"><br /></span></div><div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">What are the protocols supported by web services built with ASP.NET to exchange data?</span></b></span></div><div><span style="background-color: white;"><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: Verdana, sans-serif;"> </span></span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">HTTP GET</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">HTTP POST</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">SOAP</span></span></div><div><span style="font-family: Verdana, sans-serif;"><br /></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">What are the limitations of using GET & POST to communicate with a web service?</span></b></span></div><div><span style="background-color: white;"><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: Verdana, sans-serif;"> </span></span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">It is less secured than SOAP.</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">It prevents the user from passing structures and objects as arguments</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">It prevents the user from passing ByRef arguments</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">How to make a class accessible as a web service?</span></b></span></div><div><span style="background-color: white;"><span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: Verdana, sans-serif;"> </span></span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">-By making the class inherits from the System.Web.Services.WebService class</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">-By qualifying the class with the WebService attribute</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"> Inheriting from the WebService class is beneficiary in that it allows the class to access the ASP.NET context and other useful objects such as the session and application objects. On the other hand, qualifying the class with the WebService attribute allows for setting additional properties of the web service such as its description and namespace.</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"> <span class="Apple-tab-span" style="white-space: pre;"> </span></span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"> [WebService]</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"> public class TestService : System.Web.Services.WebService</span></span></div><div><span style="font-family: Verdana, sans-serif;"><br /></span></div><div><span style="background-color: white;"><b><span style="font-family: Verdana, sans-serif;">How to make a method of a web service class accessible through the internet?</span></b></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"><br /></span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;">By qualifying the method with the WebMethod attribute.</span></span></div><div></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"> [WebMethod()]</span></span></div><div><span style="background-color: white;"><span style="font-family: Verdana, sans-serif;"> public string MethodName()</span></span></div><div><br /></div></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-26732616779933388572014-02-03T11:58:00.000-08:002014-02-15T07:41:34.247-08:00Recommended Hardware and Software Specifications For Sql Server 2012<div dir="ltr" style="text-align: left;" trbidi="on"><div style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizelegibility;"><span style="font-family: Verdana, sans-serif;">Microsoft has come out with a list of specifications needed to install and run SQL Server 2012.</span></div><div style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizelegibility;"><span style="font-family: Verdana, sans-serif;">You would need: <strong style="box-sizing: border-box; line-height: inherit;"><br style="box-sizing: border-box;" /></strong></span></div><ol style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; list-style-position: outside; margin: 0px 0px 1.25em; padding: 0px 0px 0px 1.3em;"><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">More than 3.6 gigabytes of free space on your hard drive.</span></li><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">64-bit:<br style="box-sizing: border-box;" />Intel Xeon (supported by Intel EM64T), AMD Athlon 64, AMD Opteron, or Intel Pentium IV (supported by EM64T with at least 2.0 GHz)</span></li><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">32-bit<br style="box-sizing: border-box;" />Compatible with Pentium III (at least 2.0 GHz)</span></li><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">Recommended RAM: At least 2 gigabytes or whatever is the highest supported.</span></li></ol><div style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizelegibility;"><span style="font-family: Verdana, sans-serif;">Software you need to install before installing SQL Server 2012</span></div><ul style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; list-style-position: outside; margin: 0px 0px 1.25em; padding: 0px;"><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">.Net Framework 4.0</span></li><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">Hyper-V (needed for virtualization)</span></li><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;">Windows PowerShell 2.0 (which you could download at <a href="http://go.microsoft.com/?linkid=9745645" style="box-sizing: border-box; line-height: inherit; text-decoration: none;">http://go.microsoft.com/?linkid=9745645</a>)</span></li></ul><div style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizelegibility;"><span style="font-family: Verdana, sans-serif;"><strong style="box-sizing: border-box; line-height: inherit;"></strong></span></div><div style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; margin-bottom: 1.25em; padding: 0px; text-rendering: optimizelegibility;"><strong style="box-sizing: border-box; line-height: inherit;"><span style="font-family: Verdana, sans-serif;">Other tips:</span></strong></div><ol style="background-color: white; box-sizing: border-box; direction: ltr; line-height: 1.6; list-style-position: outside; margin: 0px 0px 1.25em; padding: 0px 0px 0px 1.3em;"><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="box-sizing: border-box; line-height: inherit;">Use NTFS file system.</strong><br style="box-sizing: border-box;" />While SQL Server 2012 works on FAT32 systems, for this application it is not recommended. You should also avoid compressed or mapped drives.</span></li><li style="box-sizing: border-box; direction: ltr; margin: 0px; padding: 0px;"><span style="font-family: Verdana, sans-serif;"><strong style="box-sizing: border-box; line-height: inherit;">Install the no-reboot package from Microsoft.</strong><br style="box-sizing: border-box;" />This is typically bundled in with Windows 7 SP1, but you can download the package here: <a href="http://go.microsoft.com/fwlink/?LinkId=198092" style="box-sizing: border-box; line-height: inherit; text-decoration: none;">http://go.microsoft.com/fwlink/?LinkId=198092</a>.</span></li></ol></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-80180051082468593652014-02-03T11:52:00.000-08:002014-02-15T07:41:34.254-08:00New Features of SQL Server 2012 <div dir="ltr" style="text-align: left;" trbidi="on"><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">1. AlwaysOn Availability Groups</strong> -- This feature takes database mirroring to a whole new level. With AlwaysOn, users will be able to fail over multiple databases in groups instead of individually. Also, secondary copies will be readable, and can be used for database backups. The big win is that your DR environment no longer needs to sit idle.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">2. Windows Server Core Support </strong>-- If you don't know what Windows Server Core is, you may want to come up to speed before Windows 8 (MS is making a push back to the command line for server products). Core is the GUI-less version of Windows that uses DOS and PowerShell for user interaction. It has a much lower footprint (50% less memory and disk space utilization), requires fewer patches, and is more secure than the full install. Starting with SQL 2012, it is supported for SQL Server.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">3. Columnstore Indexes</strong> -- This a cool new feature that is completely unique to SQL Server. They are special type of read-only index designed to be use with Data Warehouse queries. Basically, data is grouped and stored in a flat, compressed column index, greatly reducing I/O and memory utilization on large queries.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">4. User-Defined Server Roles</strong> -- DBAs have always had the ability to create custom database role, but never server wide. For example, if the DBA wanted to give a development team read/write access to every database on a shared server, traditionally the only ways to do it were either manually, or using undocumented procedures. Neither of which were good solutions. Now, the DBA can create a role, which has read/write access on every DB on the server, or any other custom server wide role.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">5. Enhanced Auditing Features</strong> -- Audit is now available in all editions of SQL Server. Additionally, users can define custom audit specifications to write custom events into the audit log. New filtering features give greater flexibility in choosing which events to write to the log.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">6. BI Semantic Model</strong> -- This is replacing the Analysis Services Unified Dimensional Model (or cubes most people referred to them). It's a hybrid model that allows one data model will support all BI experiences in SQL Server. Additionally, this will allow for some really neat text infographics</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">7. Sequence Objects</strong> -- For those folks who have worked with Oracle, this has been a long requested feature. A sequence is just an object that is a counter -- a good example of it's use would be to increment values in a table, based a trigger. SQL has always had similar functionality with identity columns, but now this is a discrete object.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">8. Enhanced PowerShell Support</strong> -- Windows and SQL Server admins should definitely start brushing up on their PowerShell scripting skills. Microsoft is driving a lot of development effort into instrumenting all of their server-based products with PowerShell. SQL 2008 gave DBAs some exposure to it, but there are many more in cmdlets in SQL 2012.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">9. Distributed Replay</strong> -- Once again this is answer to a feature that Oracle released (Real Application Testing). However, and in my opinion where the real value proposition of SQL Server is, in Oracle it is a (very expensive) cost option to Enterprise Edition. With SQL, when you buy your licenses for Enterprise Edition, you get everything. Distributed replay allows you to capture a workload on a production server, and replay it on another machine. This way changes in underlying schemas, support packs, or hardware changes can be tested under production conditions.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">10. PowerView</strong> -- You may have heard of this under the name "Project Crescent" it is a fairly powerful self-service BI toolkit that allows users to create mash ups of BI reports from all over the Enterprise.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">11. SQL Azure Enhancements</strong> -- These don't really go directly with the release of SQL 2012, but Microsoft is making some key enhancements to SQL Azure. Reporting Services for Azure will be available, along with backup to the Windows Azure data store, which is a huge enhancement. The maximum size of an Azure database is now up to 150G. Also Azure data sync allows a better hybrid model of cloud and on-premise solutions</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;"><strong style="border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">12. Big Data Support</strong> -- I saved the biggest for last, introduced at the PASS (Professional Association for SQL Server) conference last year, Microsoft announced a partnership with Hadoop provider Cloudera. One part of this involves MS releasing a ODBC driver for SQL Server that will run on a Linux platform. Additionally, Microsoft is building connectors for Hadoop, which is an extremely popular NoSQL platform. With this announcement, Microsoft has made a clear move into this very rapidly growing space.</span></div><div style="background-color: white; border: 0px; color: #333333; margin-bottom: 10px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;">SQL 2012 is a big step forward for Microsoft -- the company is positioning itself to be a leader in availability and in the growing area of big data. As a database professional, I look forward to using SQL 2012 to bring new solutions to my clients.</span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-28631903921108203792013-11-10T07:56:00.000-08:002014-02-15T07:41:34.262-08:00Most Frequently Asked Interview Questions - Asp.Net 3 + Years<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: blue;">What is asp.net life cycle ?</span> </b></span></span><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>PreInit</b><br /><br />The properties like IsPostBack have been set at this time.<br /><br />This event will be used when we want to: <br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Set master page dynamically.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Set theme dynamically.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Read or set profile property values.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This event is also preferred if want to create any dynamic controls.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>Init</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Raised after all the controls have been initialized with their default values and any skin settings have been applied.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fired for individual controls first and then for page.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>LoadViewState</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fires only if IsPostBack is true.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Values stored in HiddenField with id as _ViewState decoded and stored into corresponding controls.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>LoadPostData</b><br /><br />Some controls like:<br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="letter-spacing: 0.75pt;">Fires only if IsPostBack is true.</span></span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Some controls like Textbox are implemented from IPostBackDataHandler and this fires only for such controls.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In this event page processes postback data included in the request object pass it to the respective controls.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>PreLoad</b><br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Used only if want to inject logic before actual page load starts.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>Load</b><br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Used normally to perform tasks which are common to all requests, such as setting up a database query.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>Control events</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This event is fired when IsPostBack is true.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>PreRender</b>Raised after the page object has created all the controls that are required for rendering which includes child controls and composite controls.<br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Use the event to make final changes to the contents of the page or its controls before the values are stored into the viewstate and the rendering stage begins.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Mainly used when we want to inject custom JavaScript logic.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>SaveViewState</b><br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">All the control values that support viewstate are encoded and stored into the viewstate.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>Render</b>Generates output (HTML) to be rendered at the client side.<br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can add custom HTML to the output if we want here.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b>Unload</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fired for individual controls first and then for page.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> 2. Used to perform cleanup work like closing open files and database connections. </span></span></span><br /><br /><span style="color: blue;"><b><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> </span></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="BlogsWelcomeHeading" id="ctl00_ContentMain_BlogDetailControl1_LabelBlogTitle">Difference between ASP.NET HttpHandler and HttpModule</span></span></span></b></span><br /><br /><span style="color: blue;"><i><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="BlogsWelcomeHeading" id="ctl00_ContentMain_BlogDetailControl1_LabelBlogTitle"><span style="font-size: x-small;"><span style="color: black;"><span id="ctl00_ContentMain_BlogDetailControl1_LabelBlogDetail">What are http handlers and modules. And in which condition which one is suitable. For that first we need to understand when user request application resource to web server, what happened? The user requests for a resource on web server. The web server examines the file name extension of the requested file, and determines which ISAPI extension should handle the request. Then the request is passed to the appropriate ISAPI extension. For example when an .aspx page is requested it is passed to ASP.Net page handler. Then Application domain is created and after that different ASP.Net objects like Httpcontext, HttpRequest, HttpResponse are created. Then instance of HttpApplication is created and also instance of any configured modules. One can register different events of HttpApplication class like BeginRequest, AuthenticateRequest, AuthorizeRequest, ProcessRequest etc.</span></span></span></span></span></span></i><b><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="BlogsWelcomeHeading" id="ctl00_ContentMain_BlogDetailControl1_LabelBlogTitle"> </span></span></span></b></span><br /><br /><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span id="ctl00_ContentMain_BlogDetailControl1_LabelBlogDetail"></span></span></span></span><br /><div class="MsoNormal"><span style="font-size: small;"><b>HTTP Handler</b></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"> </span><br /><div class="MsoNormal"><span style="font-size: small;">HTTP Handler is the process which runs in response to a HTTP request. So whenever user requests a file it is processed by the handler based on the extension. So, custom http handlers are created when you need to special handling based on the file name extension. Let's consider an example to create RSS for a site. So, create a handler that generates RSS-formatted XML. Now bind the .rss extension to the custom handler.</span></div><span style="font-size: small;"><div class="MsoNormal"><br /></div><div class="MsoNormal"><b>HTTP Modules</b></div><div class="MsoNormal"><br /></div><div class="MsoNormal">HTTP Modules are plugged into the life cycle of a request. So when a request is processed it is passed through all the modules in the pipeline of the request. So generally http modules are used for:</div><div class="MsoNormal"><i>Security</i>: For authenticating a request before the request is handled.</div><div class="MsoNormal"><i>Statistics and Logging</i>: Since modules are called for every request they can be used for gathering statistics and for logging information.</div><div class="MsoNormal"><i>Custom header</i>: Since response can be modified, one can add custom header information to the response.</div> </span><br /><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>More clear difference between </b></span></span></span><span dir="ltr" id="sites-page-title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: blue;">HttpHandler and HttpModule for experience guys</span></b></span></span></span><br /><br /><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="font-weight: bold; line-height: 20px;">HttpHandler:</span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"></span><span style="line-height: 20px;"><span style="color: magenta;">Meaning</span></span><span style="font-style: italic; line-height: 20px;"><span style="color: magenta;">:</span>- </span><span style="line-height: 20px;">An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. We can create our own HTTP handlers that render custom output to the browser.In order to create a Custom HTTP Handler,we need to Implement IHttpHandler interface(synchronous handler) or</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Implement IHttpAsyncHandler(asynchronous handler).</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">2.</span><span style="font-style: italic; line-height: 20px;">When to use HTTP handlers:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">RSS feeds: To create an RSS feed for a Web site, we can create a handler that emits RSS-formatted XML. We can then bind a file name extension such as .rss to the custom handler. When users send a request to your site that ends in .rss, ASP.NET calls our handler to process the request.</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Image server: If we want a Web application to serve images in a variety of sizes, we can write a custom handler to resize images and then send them to the user as the handler’s response.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">3.</span><span style="font-style: italic; line-height: 20px;">How to develop an ASP.NET handler:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">All we need is implementing IHttpHandler interface</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">public class MyHandler :IHttpHandler</span><br style="line-height: 20px;" /><span style="line-height: 20px;">{</span><br style="line-height: 20px;" /><span style="line-height: 20px;">public bool IsReusable</span><br style="line-height: 20px;" /><span style="line-height: 20px;">{</span><br style="line-height: 20px;" /><span style="line-height: 20px;">get { return false; }</span><br style="line-height: 20px;" /><span style="line-height: 20px;">}</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">public void ProcessRequest(HttpContext context)</span><br style="line-height: 20px;" /><span style="line-height: 20px;">{</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">}</span><br style="line-height: 20px;" /><span style="line-height: 20px;">}</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">4.</span><span style="font-style: italic; line-height: 20px;">Number of HTTP handler called:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">During the processing of an http request, only one HTTP handler will be called.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">5.</span><span style="font-style: italic; line-height: 20px;">Processing Sequence:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">In the asp.net request pipe line ,http handler comes after http Module and it is the end point objects in ASP.NET pipeline.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">6.</span><span style="font-style: italic; line-height: 20px;">What it does actually?</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">HTTP Handler actually processes the request and produces the response</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">7.</span><span style="font-style: italic; line-height: 20px;">HTTP Handler implement following Methods and Properties:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">Process Request: This method is called when processing asp.net requests. Here you can perform all the things related to processing request.</span><br style="line-height: 20px;" /><span style="line-height: 20px;">IsReusable: This property is to determine whether same instance of HTTP Handler can be used to fulfill another request of same type.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">8. </span><span style="font-style: italic; line-height: 20px;">Configuring HTTP handler in web.config :</span><br style="line-height: 20px;" /><span style="line-height: 20px;">We can use <httpHandlers> and <add> nodes for adding HTTP</span><br style="line-height: 20px;" /><span style="line-height: 20px;">handlers to our Web applications. In fact the handlers are</span><br style="line-height: 20px;" /><span style="line-height: 20px;">listed with <add> nodes in between <httpHandlers> and</span><br style="line-height: 20px;" /><span style="line-height: 20px;"></httpHandlers> nodes.</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Ex: <httpHandlers></span><br style="line-height: 20px;" /><span style="line-height: 20px;"><add verb="supported http verbs" path="path"</span><br style="line-height: 20px;" /><span style="line-height: 20px;">type="namespace.classname, assemblyname" /></span><br style="line-height: 20px;" /><span style="line-height: 20px;"><httpHandlers></span><br style="line-height: 20px;" /><span style="line-height: 20px;">(In this verb=GET/POST/HEAD path=path for</span><br style="line-height: 20px;" /><span style="line-height: 20px;">incoming HTTP requests type=…)</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;">HttpModule:</span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="color: magenta;"><span style="line-height: 20px;"></span><span style="line-height: 20px;">Meaning</span></span><span style="font-style: italic; line-height: 20px;">:- </span><span style="line-height: 20px;">An HTTP module is an assembly that is called on every request that is made to our application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules examine incoming and outgoing requests and take action based on the request.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">2.</span><span style="font-style: italic; line-height: 20px;">When to use HTTP modules:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">Security: Because we can examine incoming requests, an HTTP module can perform custom authentication or other security checks before the requested page, XML Web service, or handler is called. In Internet Information Services (IIS) 7.0 running in Integrated mode, we can extend forms authentication to all content types in an application.</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Statistics and logging: Because HTTP modules are called on every request, we can gather request statistics and log information in a centralized module, instead of in individual pages.</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Custom headers or footers: Because we can modify the outgoing response, we can insert content such as custom header information into every page or XML Web service response.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">3.</span><span style="font-style: italic; line-height: 20px;">How to develop a Http Module:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">All we need is implementing System.Web.IHttpModule interface.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">public class MyHttpModule : IHttpModule</span><br style="line-height: 20px;" /><span style="line-height: 20px;">{</span><br style="line-height: 20px;" /><span style="line-height: 20px;">public void Dispose()</span><br style="line-height: 20px;" /><span style="line-height: 20px;">{</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">}</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">public void Init(HttpApplication context)</span><br style="line-height: 20px;" /><span style="line-height: 20px;">{</span><br style="line-height: 20px;" /><span style="line-height: 20px;">//here we have to define handler for events such as BeginRequest ,PreRequestHandlerExecute ,EndRequest,AuthorizeRequest and ....</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">}</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">// you need to define event handlers here</span><br style="line-height: 20px;" /><span style="line-height: 20px;">}</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">4.</span><span style="font-style: italic; line-height: 20px;">Number of HTTP module called:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">Whereas more than one HTTP modules may be called. </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">5. </span><span style="font-style: italic; line-height: 20px;">Processing Sequence:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">In the asp.net request pipe line, http Module comes first.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">6.</span><span style="font-style: italic; line-height: 20px;">What it does actually?</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">HTTP module can work on request before and on the response after HTTP Handler </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">7.</span><span style="font-style: italic; line-height: 20px;">Http Module implements following Methods and Properties:</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">InIt: This method is used for implementing events of HTTP Modules in HTTPApplication object.</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Dispose: This method is used perform cleanup before Garbage Collector destroy everything.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">8.</span><span style="font-style: italic; line-height: 20px;">Configuring HTTP Modules in web.config:</span><br style="line-height: 20px;" /><span style="line-height: 20px;">Ex: <system.web></span><br style="line-height: 20px;" /><span style="line-height: 20px;"><httpModules></span><br style="line-height: 20px;" /><span style="line-height: 20px;"><add name="MyModule"</span><br style="line-height: 20px;" /><span style="line-height: 20px;">type="MyModule.SyncModule, MyModule" /></span><br style="line-height: 20px;" /><span style="line-height: 20px;"></httpModules></span><br style="line-height: 20px;" /><span style="line-height: 20px;"></system.web></span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><br /><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"></span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process. </span></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">inetinfo.exe is the Microsoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe. </span></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"> </span><br style="line-height: 20px;" /><span style="line-height: 20px;"></span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What’s the difference between Response.Write() and Response.Output.Write()?</span><span style="line-height: 20px;"> </span></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">The latter one allows you to write formatted output. </span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"></span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What methods are fired during the page load? </span></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">Init() - when the page is instantiated, </span><br style="line-height: 20px;" /><span style="line-height: 20px;">Load() - when the page is loaded into server memory, </span><br style="line-height: 20px;" /><span style="line-height: 20px;">PreRender() - the brief moment before the page is displayed to the user as HTML, </span><br style="line-height: 20px;" /><span style="line-height: 20px;">Unload() - when page finishes loading. </span></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"> </span><br style="line-height: 20px;" /><span style="line-height: 20px;"></span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Where does the Web page belong in the .NET Framework class hierarchy? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">System.Web.UI.Page </span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"></span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Where do you store the information about the user’s locale? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">System.Web.UI.Page.Culture </span></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"> </span><span style="color: blue;"><br style="line-height: 20px;" /><span style="line-height: 20px;"></span><span style="font-weight: bold; line-height: 20px;">What’s the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?</span></span></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="font-weight: bold; line-height: 20px;"> </span><span style="line-height: 20px;"> CodeBehind is relevant to Visual Studio.NET only. </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What’s a bubbled event? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents. </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;"> </span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Suppose you want a certain ASP.NET function executed on MouseOver over a certain button. Where do you add an event handler? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">It’s the Attributes property, the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();") </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What data type does the RangeValidator control support? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">Integer, String and Date.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><span style="color: blue;">Explain the differences between Server-side and Client-side code?</span> </span><br style="line-height: 20px;" /><span style="line-height: 20px;">Server-side code runs on the server. Client-side code runs in the clients’ browser.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><span style="color: blue;">What type of code (server or client) is found in a Code-Behind class?</span> </span><br style="line-height: 20px;" /><span style="line-height: 20px;">Server-side code.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><span style="color: blue;">Should validation (did the user enter a real date) occur server-side or client-side? Why?</span> </span><br style="line-height: 20px;" /><span style="line-height: 20px;">Client-side. This reduces an additional request to the server to validate the users input.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What does the "EnableViewState" property do? Why would I want it on or off? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">It enables the viewstate on the page. It allows the page to save the users input on a form.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">Server.Transfer is used to post a form to another page. Response.Redirect is used to redirect the user to another page or site.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;"> </span><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Can you explain the difference between an ADO.NET Dataset and an ADO Recordset? </span></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="line-height: 20px;">• A DataSet can represent an entire relational database in memory, complete with tables, relations, and views. </span><br style="line-height: 20px;" /><span style="line-height: 20px;">• A DataSet is designed to work without any continuing onnection to the original data source. </span><br style="line-height: 20px;" /><span style="line-height: 20px;">• Data in a DataSet is bulk-loaded, rather than being loaded on demand. </span><br style="line-height: 20px;" /><span style="line-height: 20px;">• There's no concept of cursor types in a DataSet. </span><br style="line-height: 20px;" /><span style="line-height: 20px;">• DataSets have no current record pointer You can use For Each loops to move through the data. </span><br style="line-height: 20px;" /><span style="line-height: 20px;">• You can store many edits in a DataSet, and write them to the original data source in a single operation. </span><br style="line-height: 20px;" /><span style="line-height: 20px;">• Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources. </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><b><span style="line-height: 20px;">Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines? </span></b></span></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"> </span><br style="line-height: 20px;" /><span style="line-height: 20px;">This is where you can set the specific variables for the Application and Session objects.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="line-height: 20px;"> </span></span><span style="font-weight: bold; line-height: 20px;"><span style="color: blue;">If I’m developing an application that must accommodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users?</span> </span><br style="line-height: 20px;" /><span style="line-height: 20px;">Maintain the login state security through a database.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Can you explain what inheritance is and an example of when you might use it? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">When you want to inherit (use the functionality of) another class. Base Class Employee. A Manager class could be derived from the Employee base class.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Whats an assembly? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN</span><br style="line-height: 20px;" /><span style="color: blue;"><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;">Describe the difference between inline and code behind. </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Explain what a diffgram is, and a good use for one? </span></span><span style="line-height: 20px;">The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Whats MSIL, and why should my developers need an appreciation of it if at all? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Which method do you invoke on the DataAdapter control to load your generated dataset with data? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">The .Fill() method</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Can you edit data in the Repeater control? </span></span><span style="line-height: 20px;">No, it just reads the information from its data source</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><span style="color: blue;">Which template must you provide, in order to display data in a Repeater control?</span> </span><br style="line-height: 20px;" /><span style="line-height: 20px;">ItemTemplate</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">How can you provide an alternating color scheme in a Repeater control? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">Use the AlternatingItemTemplate</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? </span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">You must set the DataSource property and call the DataBind method.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What base class do all Web Forms inherit from? </span></span><span style="line-height: 20px;">The Page class.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Name two properties common in every validation control? </span></span><span style="line-height: 20px;">ControlToValidate property and Text property.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What tags do you need to add within the asp:datagrid tags to bind columns manually? </span></span><span style="line-height: 20px;">Set AutoGenerateColumns Property to false on the datagrid tag</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What tag do you use to add a hyperlink column to the DataGrid? </span></span><span style="line-height: 20px;"><asp:HyperLinkColumn></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What is the transport protocol you use to call a Web service? </span></span><span style="line-height: 20px;">SOAP is the preferred protocol. </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">True or False: A Web service can only be written in .NET? </span></span><span style="line-height: 20px;">False</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What does WSDL stand for? </span></span><span style="line-height: 20px;">(Web Services Description Language)</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="line-height: 20px;"></span><span style="font-weight: bold; line-height: 20px;">Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box? </span></span><span style="line-height: 20px;">DataTextField property </span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Which control would you use if you needed to make sure the values in two different controls matched? </span></span><span style="line-height: 20px;">CompareValidator Control</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">True or False: To test a Web service you must create a windows application or Web application to consume this service?</span></span><span style="line-height: 20px;">False, the webservice comes with a test page and it provides HTTP-GET method to test.</span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">How many classes can a single .NET DLL contain?</span><span style="line-height: 20px;"> </span></span><span style="line-height: 20px;">It can contain many classes.</span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"><span style="background-color: white;"><span style="color: blue;"><span style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; font-weight: bold; line-height: 20px;">optimization technique description</span></span><br style="color: #333333; font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;" /><span style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;"> Avoid unnecessary use of view state which lowers the performance.</span><br style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;" /><span style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;"> Avoid the round trips to server.</span><br style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;" /><span style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;"> Use connection pooling.</span><br style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;" /><span style="font-family: Lucida Grande,Verdana,Arial,Bitstream Vera Sans,sans-serif; line-height: 20px;"> Use stored procedures.</span></span></span></span></span></span></div><div dir="ltr"></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"><span style="background-color: white;"><span style="color: #333333; line-height: 20px;"><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What serialization?</span></span><br style="color: #333333; line-height: 20px;" /><span style="color: black;"><span style="line-height: 20px;">Serialization is a process of conversion an objects into stream of bytes so that they can transfer through the channels.</span> </span></span></span> </span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"> </span></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span></span></span></div><div dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="line-height: 20px;"></span></span></span></span></div><br /><span dir="ltr" id="sites-page-title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="background-color: white;"><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">26) About a class access specifiers and method access specifiers</span></span></span></b><span style="background-color: white;"><span style="line-height: 20px;"> Public : available throughout application.</span><br style="line-height: 20px;" /><span style="line-height: 20px;"> Private : available for class and its inherited class.</span><br style="line-height: 20px;" /><span style="line-height: 20px;"> Protected : restricted to that class only.</span><br style="line-height: 20px;" /><span style="line-height: 20px;"> Internal : available throughout that assembly.</span> </span></span></span></span><br /><br /><span dir="ltr" id="sites-page-title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What are the different types of caching?</span></span><br style="color: #333333; line-height: 20px;" /><span style="line-height: 20px;">Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In context of web application, caching is used to retain the pages or data across HTTP requests and reuse them without the expense of recreating them.ASP.NET has 3 kinds of caching strategiesOutput CachingFragment CachingData</span><br style="color: #333333; line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><br />CachingOutput Caching:</span><span style="line-height: 20px;"> Caches the dynamic output generated by a request. Some times it is useful to cache the output of a website even for a minute, which will result in a better performance. For caching the whole page the page should have OutputCache directive.</span><br style="line-height: 20px;" /><span style="line-height: 20px;"><%@ OutputCache Duration="60" VaryByParam="state" %></span><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><br />Fragment Caching:</span><span style="line-height: 20px;"> Caches the portion of the page generated by the request. Some times it is not practical to cache the entire page, in such cases we can cache a portion of page<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;">Data Caching:</span><span style="line-height: 20px;"> Caches the objects programmatically. For data caching asp.net provides a cache object for eg: cache["States"] = dsStates;</span> </span></span></span></span><br /><br /><span dir="ltr" id="sites-page-title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">What are different types of directives in .NET?</span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">@Page: Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files <%@ Page AspCompat="TRUE" language="C#" %></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;">@Control:</span><span style="line-height: 20px;">Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language="VB" EnableViewState="false" %></span><br style="line-height: 20px;" /><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;">@Import:</span><span style="line-height: 20px;"> Explicitly imports a namespace into a page or user control. The Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @Import directives. <% @ Import Namespace="System.web" %></span><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><br />@Implements:</span><span style="line-height: 20px;"> Indicates that the current page or user control implements the specified .NET framework interface.<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %></span><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><br />@Register:</span><span style="line-height: 20px;"> Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix="Acme" Tagname="AdRotator" Src="AdRotator.ascx" %></span><br style="line-height: 20px;" /><span style="font-weight: bold; line-height: 20px;"><br />@Assembly:</span><span style="line-height: 20px;"> Links an assembly to the current page during compilation, making all the assembly's classes and interfaces available for use on the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly Src="MySource.vb" %></span> </span></span></span></span><br /><br /><span dir="ltr" id="sites-page-title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"><span style="color: blue;"><span style="font-weight: bold; line-height: 20px;">Can a user browsing my Web site read my Web.config or Global.asax files?</span></span><br style="line-height: 20px;" /><span style="line-height: 20px;">No. The section of Machine.config, which holds the master configuration settings for ASP.NET, contains entries that map ASAX files, CONFIG files, and selected other file types to an HTTP handler named HttpForbiddenHandler, which fails attempts to retrieve the associated file. You can modify it by editing Machine.config or including an section in a local Web.config file.</span> </span></span></span></span><br /><br /><span dir="ltr" id="sites-page-title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"> </span><b> </b></span></span></span><br /><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> </span></span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-82128220692138291372013-11-09T06:15:00.000-08:002014-02-15T07:41:34.280-08:00SSAS Interview Questions and Answers<div dir="ltr" style="text-align: left;" trbidi="on"><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is the difference between SSAS 2005 and SSAS2008?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In 2005 its not possible to create an empty cube but in 2008 we can create an empty cube.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A new feature in Analysis Services 2008 is the Attribute Relationships tab in the Dimension Designer . to implement attribute relationship is complex in ssas 2005</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">we can create ONLY 2000 partitions per Measure Group in ssas 2005 and the same limit of partitions is removed in ssas 2008.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You can answer more but if you end this with these then the interviewer feel that you are REAL EXPERIENCED.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is datawarehouse in short DWH?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The datawarehouse is an informational environment that</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Provides an integrated and total view of the enterprise</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Makes the enterprise’s current and historical information easily available for decision making</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Makes decision-support transactions possible without hindering operational systems</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Renders the organization’s information consistent</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Presents a flexible and interactive source of strategic information</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">OR a warehouse is a</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Subject oriented</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Integrated</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Time variant</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Non volatile for doing decision support</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">OR</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Collection of data in support of management’s decision making process”. He defined the terms in the sentence as follows.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">OR</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Subject oriented:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It define the specific business domain ex: banking, retail, insurance, etc…..</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Integrated:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It should be in a position to integrated data from various source systems</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex: sql,oracle,db2 etc……</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Time variant:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It should be in a position to maintain the data the various time periods.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Non volatile:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Once data is inserted it can’t be changed</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is data mart?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A data mart is a subset of an organizational data store, usually oriented to a specific purpose or major data subject that may be distributed to support business needs. Data marts are analytical data stores designed to focus on specific business functions for a specific community within an organization.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Data marts are often derived from subsets of data in a <a href="http://en.wikipedia.org/wiki/Data_warehouse" title="Data warehouse">data warehouse</a>, though in the bottom-up data warehouse design methodology the data warehouse is created from the union of organizational data marts.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are 3 types of data mart they are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Dependent</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Independent</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Logical data mart</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What are the difference between data mart and data warehouse?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Datawarehouse is complete data where as Data mart is Subset of the same.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">All the organisation data may related to finance department, HR, banking dept are stored in data warehouse where as in data mart only finance data or HR department data will be stored. So data warehouse is a collection of different data marts.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>Have you ever worked on performance tuning, if yes what are the steps involved in it?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We need to identify the bottlenecks to tune the performance, to overcome the bottleneck we need to following the following.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Avoid named queries</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Unnecessary relationships between tables</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Proper attribute relationships to be given</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Proper aggregation design</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Proper partitioning of data</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Proper dimension usage design</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Avoid unnecessary many to many relationships</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Avoid unnecessary measures</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Set AttributeHierarchyEnabled = FALSE to Attributes that is not required</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Won’t take even single measure which is not necessary.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are the difficulties faced in cube development?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This question is either to test whether you are really experienced or when he doesnot have any questions to ask .. <img alt=";)" class="wp-smiley" src="http://www.msbiguide.com/wp-includes/images/smilies/icon_wink.gif" /></span></span> <br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You can tell any area where you feel difficult to work. But always the best answers will be the following.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Giving attribute relationships</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Calculations</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Giving dimension usage (many to many relationship)</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Analyzing the requirements</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>Explain the flow of creating a cube?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Steps to create a cube in ssas</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Create a data source.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Create a datasource view.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Create Dimensions</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Create a cube.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Deploy and Process the cube.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is a datasource or DS?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The data source is the Physical Connection information that analysis service uses to connect to the database that host the data. The data source contains the connection string which specifies the server and the database hosting the data as well as any necessary authentication credentials.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is datasourceview or DSV?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A data source view is a persistent set of tables from a data source that supply the data for a particular cube. BIDS also includes a wizard for creating data source views, which you can invoke by right-clicking on the Data Source Views folder in Solution Explorer.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Datasource view is the logical view of the data in the data source.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Data source view is the only thing a cube can see.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is named calculation?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A named calculation is a SQL expression represented as a calculated column. This expression appears and behaves as a column in the table. A named calculation lets you extend the relational schema of existing tables or views in a data source view without modifying the tables or views in the underlying data source.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Named calculation is used to create a new column in the DSV using hard coded values or by using existing columns or even with both.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is named query?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Named query in DSV is similar to View in Database. This is used to create Virtual table in DSV which will not impact the underlying database. Named query is mainly used to merge the two or more table in the datasource view or to filter columns of a table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Why we need named queries?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A named query is used to join multiple tables, to remove unnecessary columns from a table of a database. You can achieve the same in database using Views but this Named Queries will be the best bet whe you don’t have access to create Views in database.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>How will you add a new column to an existing table in data source view?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">By using named calculations we can add a new column to an existing table in the data source view. Named Calculation is explained above.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is dimension table?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A dimension table contains hierarchical data by which you’d like to summarize. A dimension table contains specific business information, a dimension table that contains the specific name of each member of the dimension. The name of the dimension member is called an “attribute”</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The key attribute in the dimension must contain a unique value for each member of the dimension. This key attribute is called “primary key column”</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The primary key column of each dimension table corresponding to the one of the key column in any related fact table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is fact table?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A fact table contains the basic information that you wish to summarize. The table that stores the detailed value for measure is called fact table. In simple and best we can define as “The table which contains METRICS” that are used to analyse the business.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It consists of 2 sections</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1) Foregine key to the dimesion</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">2) measures/facts(a numerical value that used to monitor business activity)</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is Factless fact table?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This is very important interview question. The “Factless Fact Table” is a table which is similar to Fact Table except for having any measure; I mean that this table just has the links to the dimensions. These tables enable you to track events; indeed they are for recording events.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Factless fact tables are used for tracking a process or collecting stats. They are called so because, the fact table does not have aggregatable numeric values or information. They are mere key values with reference to the dimensions from which the stats can be collected</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is attribute relationships, why we need it?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Attribute relationships are the way of telling the analysis service engine that how the attributes are related with each other. It will help to relate two or more attributes to each other.Processing time will be decreased if proper relationships are given. This increases the Cube Processing performance and MDX query performance too.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In Microsoft SQL Server Analysis Services, attributes within a dimension are always related either directly or indirectly to the key attribute. When you define a dimension based on a star schema, which is where all dimension attributes are derived from the same relational table, an attribute relationship is automatically defined between the key attribute and each non-key attribute of the dimension. When you define a dimension based on a snowflake schema, which is where dimension attributes are derived from multiple related tables, an attribute relationship is automatically defined as follows:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Between the key attribute and each non-key attribute bound to columns in the main dimension table.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Between the key attribute and the attribute bound to the foreign key in the secondary table that links the underlying dimension tables.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Between the attribute bound to foreign key in the secondary table and each non-key attribute bound to columns from the secondary table.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How many types of attribute relationships are there?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are 2 types of attribute relationships they are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Rigid</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Flexible</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Rigid: </strong>In Rigid relationships where the relationship between the attributes is fixed, attributes will not change levels or their respective attribute relationships.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Example: The time dimension. We know that month “January 2009″ will ONLY belong to Year “2009″ and it wont be moved to any other year.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Flexible : </strong>In Flexible relationship between the attributes is changed.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Example: An employee and department. An employee can be in accounts department today but it is possible that the employee will be in Marketing department tomorrow.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>How many types of dimensions are there and what are they?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are 3 types of dimensions:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">confirm dimension</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">junk dimension</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">degenerate attribute</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are confirmed dimensions, junk dimension and degenerated dimensions?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Confirm dimension: It is the dimension which is sharable across the multiple facts or data model. This is also called as Role Playing Dimensions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">junk dimension: A number of very small dimensions might be lumped (a small irregularly shaped) together to form a single dimension, a junk dimension – the attributes are not closely related. Grouping of Random flags and text Attributes in a dimension and moving them to a separate sub dimension is known as junk dimension.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Degenerated dimension: In this degenerate dimension contains their values in fact table and the dimension id not available in dimension table. Degenerated Dimension is a dimension key without corresponding dimension.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Example: In the PointOfSale Transaction Fact table, we have:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Date Key (FK), Product Key (FK), Store Key (FK), Promotion Key (FP), and POS Transaction Number</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Date Dimension corresponds to Date Key, Production Dimension corresponds to Production Key. In a traditional parent-child database, POS Transactional Number would be the key to the transaction header record that contains all the info valid for the transaction as a whole, such as the transaction date and store identifier. But in this dimensional model, we have already extracted this info into other dimension. Therefore, POS Transaction Number looks like a dimension key in the fact table but does not have the corresponding dimension table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are the types of database schema?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are 3 types of database schema they are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Star</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Snowflake</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Starflake</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is star, snowflake and star flake schema?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Star schema:</strong> In star schema fact table will be directly linked with all dimension tables. The star schema’s dimensions are denormalized with each dimension being represented by a single table. In a star schema a central fact table connects a number of individual dimension tables.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Snowflake: </strong>The snowflake schema is an extension of the <a href="http://www.1keydata.com/datawarehousing/www.1keydata.com/datawarehousing/star-schema.html">star schema</a>, where each point of the star explodes into more points. In a star schema, each dimension is represented by a single dimensional table, whereas in a snowflake schema, that dimensional table is normalized into multiple lookup tables, each representing a level in the dimensional hierarchy. In snow flake schema fact table will be linked directly as well as there will be some intermediate dimension tables between fact and dimension tables.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Star flake:</strong> A hybrid structure that contains a mixture of star(denormalized) and snowflake(normalized) schema’s.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How will you hide an attribute?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can hide the attribute by selecting “AttributeHierarchyVisible = False” in properties of the attribute.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>How will you make an attribute not process?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">By selecting “ AttributeHierarchyEnabled = False”, we can make an attribute not in process.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is use of IsAggregatable property?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In Analysis Service we generally see all dimension has All member. This is because of IsAggregatable property of the attribute. You can set its value to false, so that it will not show All member. Its default member for that attribute. If you hide this member than you will have to set other attribute value to default member else it will pick some value as default and this will create confusion in browsing data if someone is not known to change in default member.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What are key, name and value columns of an attribute?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Key column of any attribute: </strong>Contains the column or columns that represent the key for the attribute, which is the column in the underlying relational table in the data source view to which the attribute is bound. The value of this column for each member is displayed to users unless a value is specified for the NameColumn property.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Name column of an attribute:</strong> Identifies the column that provides the name of the attribute that is displayed to users, instead of the value in the key column for the attribute. This column is used when the key column value for an attribute member is cryptic or not otherwise useful to the user, or when the key column is based on a composite key. The NameColumn property is not used in parent-child hierarchies; instead, the NameColumn property for child members is used as the member names in a parent-child hierarchy.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Value columns of an attribute: </strong>Identifies the column that provides the value of the attribute. If the NameColumn element of the attribute is specified, the same DataItem values are used as default values for the ValueColumn element. If the NameColumn element of the attribute is not specified and the KeyColumns collection of the attribute contains a single KeyColumn element representing a key column with a string data type, the same DataItem values are used as default values for the ValueColumn element.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is hierarchy, what are its types and difference between them?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A hierarchy is a very important part of any OLAP engine and allows users to drill down from summary levels hierarchies represent the way user expect to explore data at more detailed level</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">hierarchies is made up of multipule levels creating the structure based on end user requirements.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">->years->quarter->month->week ,are all the levels of calender hierarchy</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are 2 types of hierarchies they are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Natural hierarchy</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Unnatural hierarchy</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> Natural hierarchy: </strong>This means that the attributes are intuitively related to one another. There is a clear relationship from the top of the hierarchy to the bottom.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Example: An example of this would be date: year, quarter and month follow from each other, and in part, define each other.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Unnatural hierarchy: </strong>This means that the attributes are not clearly related.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Example: An example of this might be geography; we may have country -> state -> city, but it is not clear where Province might sit.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is Attribute hierarchy?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">An attribute hierarchy is created for every attribute in a dimension, and each hierarchy is available for dimensioning fact data. This hierarchy consists of an “All” level and a detail level containing all members of the hierarchy.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">you can organize attributes into user-defined hierarchies to provide navigation paths in a cube. Under certain circumstances, you may want to disable or hide some attributes and their hierarchies.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is use of AttributeHierarchyDisplayFolder property ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>AttributeHierarchyDisplayFolder:</strong> Identifies the folder in which to display the associated attribute hierarchy to end users. For example if I set the property value as “Test” to all the Attributes of a dimension then a folder with the name “Test” will be created and all the Attributes will be placed into the same.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong><strong>What is use of AttributeHierarchyEnabled?</strong></strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>AttributeHierarchyEnabled: </strong>Determines whether an attribute hierarchy is generated by Analysis Services for the attribute. If the attribute hierarchy is not enabled, the attribute cannot be used in a user-defined hierarchy and the attribute hierarchy cannot be referenced in Multidimensional Expressions (MDX) statements.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is use of AttributeHierarchyOptimizedState?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>AttributeHierarchyOptimizedState: </strong>Determines the level of optimization applied to the attribute hierarchy. By default, an attribute hierarchy is FullyOptimized, which means that Analysis Services builds indexes for the attribute hierarchy to improve query performance. The other option, NotOptimized, means that no indexes are built for the attribute hierarchy. Using NotOptimized is useful if the attribute hierarchy is used for purposes other than querying, because no additional indexes are built for the attribute. Other uses for an attribute hierarchy can be helping to order another attribute.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is use of AttributeHierarchyOrdered ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>AttributeHierarchyOrdered: </strong>Determines whether the associated attribute hierarchy is ordered. The default value is True. However, if an attribute hierarchy will not be used for querying, you can save processing time by changing the value of this property to False.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is the use of AttributeHierarchyVisible ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>AttributeHierarchyVisible : </strong>Determines whether the attribute hierarchy is visible to client applications. The default value is True. However, if an attribute hierarchy will not be used for querying, you can save processing time by changing the value of this property to False.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What are types of storage modes?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are three standard storage modes in OLAP applications</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">MOLAP</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ROLAP</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">HOLAP</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Compare the Three Storage Modes ?</strong></span></span></li></ul></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Summary and comparison</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="0" cellpadding="0" cellspacing="0" style="width: 565px;"><tbody><tr><td valign="top" width="60"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Basic Storage Mode</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Storage Location for Detail Data</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Storage Location for Summary/ Aggregations</span></span></td><td valign="top" width="88"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Storage space requirement</span></span></td><td valign="top" width="71"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Query Response Time</span></span></td><td valign="top" width="79"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Processing Time</span></span></td><td valign="top" width="61"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Latency</span></span></td></tr><tr><td valign="top" width="60"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">MOLAP</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Multidimensional Format</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Multidimensional Format</span></span></td><td valign="top" width="88"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">MediumBecause detail data is stored in compressed format.</span></span></td><td valign="top" width="71"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fast</span></span></td><td valign="top" width="79"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fast</span></span></td><td valign="top" width="61"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">High</span></span></td></tr><tr><td valign="top" width="60"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">HOLAP</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Relational Database</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Multidimensional Format</span></span></td><td valign="top" width="88"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Small</span></span></td><td valign="top" width="71"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Medium</span></span></td><td valign="top" width="79"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fast</span></span></td><td valign="top" width="61"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Medium</span></span></td></tr><tr><td valign="top" width="60"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ROLAP</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Relational Database</span></span></td><td valign="top" width="103"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Relational Database</span></span></td><td valign="top" width="88"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Large</span></span></td><td valign="top" width="71"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Slow</span></span></td><td valign="top" width="79"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Slow</span></span></td><td valign="top" width="61"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Low</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is MOLAP and its advantage?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">MOLAP (Multi dimensional Online Analytical Processing) : MOLAP is the most used storage type. Its designed to offer maximum query performance to the users. the data and aggregations are stored in a multidimensional format, compressed and optimized for performance. This is both good and bad. When a cube with MOLAP storage is processed, the data is pulled from the relational database, the aggregations are performed, and the data is stored in the AS database. The data inside the cube will refresh only when the cube is processed, so latency is high.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Since the data is stored on the OLAP server in optimized format, queries (even complex calculations) are faster than ROLAP.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The data is compressed so it takes up less space.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">And because the data is stored on the OLAP server, you don’t need to keep the connection to the relational database.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Cube browsing is fastest using MOLAP.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is ROLAP and its advantage?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ROLAP (Relational Online Analytical Processing) : ROLAP does not have the high latency disadvantage of MOLAP. With ROLAP, the data and aggregations are stored in relational format. This means that there will be zero latency between the relational source database and the cube.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Disadvantage of this mode is the performance, this type gives the poorest query performance because no objects benefit from multi dimensional storage.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Since the data is kept in the relational database instead of on the OLAP server, you can view the data in almost real time.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Also, since the data is kept in the relational database, it allows for much larger amounts of data, which can mean better scalability.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Low latency.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is HOLAP and its advantage?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Hybrid Online Analytical Processing (HOLAP): HOLAP is a combination of MOLAP and ROLAP. HOLAP stores the detail data in the relational database but stores the aggregations in multidimensional format. Because of this, the aggregations will need to be processed when changes are occur. With HOLAP you kind of have medium query performance: not as slow as ROLAP, but not as fast as MOLAP. If, however, you were only querying aggregated data or using a cached query, query performance would be similar to MOLAP. But when you need to get that detail data, performance is closer to ROLAP.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">HOLAP is best used when large amounts of aggregations are queried often with little detail data, offering high performance and lower storage requirements.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Cubes are smaller than MOLAP since the detail data is kept in the relational database.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Processing time is less than MOLAP since only aggregations are stored in multidimensional format.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Low latency since processing takes place when changes occur and detail data is kept in the relational database.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are Translations and its use?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Translation:</strong> The translation feature in analysis service allows you to display caption and attributes names that correspond to a specific language. It helps in providing GLOBALIZATION to the Cube.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Database dimension?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">All the dimensions that are created using NEW DIMENSION Wizard are database dimensions. In other words, the dimensions which are at Database level are called Database Dimensions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">What is Cube dimension?</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A cube dimension is an instance of a database dimension within a cube is called as cube dimension. A database dimension can be used in multiple cubes, and multiple cube dimensions can be based on a single database dimension</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Difference between Database dimension and Cube dimension?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The Database dimension has only Name and ID properties, whereas a Cube dimension has several more properties.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Database dimension is created one where as Cube dimension is referenced from database dimension.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Database dimension exists only once.where as Cube dimensions can be created more than one using ROLE PLAYING Dimensions concept.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>How will you add a dimension to cube?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">To add a dimension to a cube follow these steps.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In Solution Explorer, right-click the cube, and then click View Designer.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In the Design tab for the cube, click the Dimension Usage tab.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Either click the Add Cube Dimension button, or right-click anywhere on the work surface and then click Add Cube Dimension.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In the Add Cube Dimension dialog box, use one of the following steps:</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">To add an existing dimension, select the dimension, and then click OK.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">To create a new dimension to add to the cube, click New dimension, and then follow the steps in the Dimension Wizard.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is SCD (slowly changing dimension)?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Slowly changing dimensions (SCD) determine how the historical changes in the dimension tables are handled. Implementing the SCD mechanism enables users to know to which category an item belonged to in any given date.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are types of SCD?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It is a concept of STORING Historical Changes and when ever an IT guy finds a new way to store then a new Type will come into picture. Basically there are 3 types of SCD they are given below</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SCD type1</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SCD type2</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SCD type3</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Type1, Type2, Type3 of SCD?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Type 1: </strong>In Type 1 Slowly Changing Dimension, the new information simply overwrites the original information. In other words, no history is kept.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In our example, recall we originally have the following table:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="1" cellpadding="0"><tbody><tr><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Name</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">State</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1001</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Illinois</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">After Christina moved from Illinois to California, the new information replaces the new record, and we have the following table:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="1" cellpadding="0"><tbody><tr><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Name</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">State</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1001</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">California</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages: This is the easiest way to handle the Slowly Changing Dimension problem, since there is no need to keep track of the old information.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Disadvantages: All history is lost. By applying this methodology, it is not possible to trace back in history.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Usage: About 50% of the time.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">When to use Type 1: Type 1 slowly changing dimension should be used when it is not necessary for the data warehouse to keep track of historical changes.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> Type 2: </strong>In Type 2 Slowly Changing Dimension, a new record is added to the table to represent the new information. Therefore, both the original and the new record will be present. The new record gets its own primary key.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In our example, recall we originally have the following table:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="1" cellpadding="0"><tbody><tr><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Name</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">State</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1001</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Illinois</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">After Christina moved from Illinois to California, we add the new information as a new row into the table:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="1" cellpadding="0"><tbody><tr><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Name</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">State</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1001</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Illinois</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1005</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">California</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages: This allows us to accurately keep all historical information.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Disadvantages:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This will cause the size of the table to grow fast. In cases where the number of rows for the table is very high to start with, storage and performance can become a concern.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This necessarily complicates the ETL process.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Usage: About 50% of the time.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Type3 : </strong>In Type 3 Slowly Changing Dimension, there will be two columns to indicate the particular attribute of interest, one indicating the original value, and one indicating the current value. There will also be a column that indicates when the current value becomes active.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In our example, recall we originally have the following table:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="1" cellpadding="0"><tbody><tr><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Name</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">State</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1001</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Illinois</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">To accommodate Type 3 Slowly Changing Dimension, we will now have the following columns:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key,Name,OriginalState,CurrentState,Effective Date</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">After Christina moved from Illinois to California, the original information gets updated, and we have the following table (assuming the effective date of change is January 15, 2003):</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><table border="1" cellpadding="0"><tbody><tr><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Customer Key</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Name</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">OriginalState</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">CurrentState</span></span></td><td width="120"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Effective Date</span></span></td></tr><tr><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1001</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Christina</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Illinois</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">California</span></span></td><td><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">15-JAN-2003</span></span></td></tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This does not increase the size of the table, since new information is updated.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This allows us to keep some part of history.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Disadvantages: Type 3 will not be able to keep all history where an attribute is changed more than once. For example, if Christina later moves to Texas on December 15, 2003, the California information will be lost.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Usage: Type 3 is rarely used in actual practice.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is role playing dimension with two examples?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Role play dimensions: </strong>We already discussed about this. This is nothing but CONFIRMED Dimensions. A dimension can play different role in a fact table you can recognize a roleplay dimension when there are multiple columns in a fact table that each have foreign keys to the same dimension table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex1: There are three dimension keys in the factinternalsales,factresellersales tables which all refer to the dimtime table,the same time dimension is used to track sales by that contain either of these fact table,the corresponding role-playing dimension are automatically added to the cube.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex2 : In retail banking, for checking account cube we could have transaction date dimension and effective date dimension. Both dimensions have date, month, quarter and year attributes. The formats of attributes are the same on both dimensions, for example the date attribute is in ‘dd-mm-yyyy’ format. Both dimensions have members from 1993 to 2010.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is measure group, measure?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Measure groups : </strong>These measure groups can contain different dimensions and be at different granularity but so long as you model your cube correctly, your users will be able to use measures from each of these measure groups in their queries easily and without worrying about the underlying complexity.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Creating multiple measure groups : To create a new measure group in the Cube Editor, go to the Cube Structure tab and right-click on the cube name in the Measures pane and select ‘New Measure Group’. You’ll then need to select the fact table to create the measure group from and then the new measure group will be created; any columns that aren’t used as foreign key columns in the DSV will automatically be created as measures, and you’ll also get an extra measure of aggregation type Count. It’s a good idea to delete any measures you are not going to use at this stage.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> Measures :</strong> Measures are the numeric values that our users want to aggregate, slice, dice and otherwise analyze, and as a result, it’s important to make sure they behave the way we want them to. One of the fundamental reasons for using Analysis Services is that, unlike a relational database it allows us to build into our cube design business rules about measures: how they should be formatted, how they should aggregate up, how they interact with specific dimensions and so on.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is attribute?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">An attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is surrogate key?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A surrogate key is the SQL generated key which acts like an alternate primary key for the table in database, Data warehouses commonly use a surrogate key to uniquely identify an entity. A surrogate is not generated by the user but by the system. A primary difference between a primary key and surrogate key in few databases is that primarykey uniquely identifies a record while a Surrogatekey uniquely identifies an entity.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex: An employee may be recruited before the year 2000 while another employee with the same name may be recruited after the year 2000. Here, the primary key will uniquely identify the record while the surrogate key will be generated by the system (say a serial number) since the SK is NOT derived from the data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How many types of relations are there between dimension and measure group?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are six relation between the dimension and measure group, they are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">No Relationship</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Regular</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Refernce</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Many to Many</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Data Mining</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fact</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is regular type, no relation type, fact type, referenced type, many-to-many type with example?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>No relationship:</strong> The dimension and measure group are not related.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Regular:</strong> The dimension table is joined directly to the fact table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Referenced:</strong> The dimension table is joined to an intermediate table, which in turn,is joined to the fact table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Many to many:</strong>The dimension table is to an intermediate fact table,the intermediate fact table is joined , in turn, to an intermediate dimension table to which the fact table is joined.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Data mining:</strong>The target dimension is based on a mining model built from the source dimension. The source dimension must also be included in the cube.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Fact table: </strong>The dimension table is the fact table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What are calculated members and what is its use?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Calculations are item in the cube that are eveluated at runtime</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Calculated members: You can create customized measures or dimension members, called calculated members, by combining cube data, arithmetic operators, numbers, and/or functions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Example: You can create a calculated member called Marks that converts dollars to marks by multiplying an existing dollar measure by a conversion rate. Marks can then be displayed to end users in a separate row or column. Calculated member definitions are stored, but their values exist only in memory. In the preceding example, values in marks are displayed to end users but are not stored as cube data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What are KPIs and what is its use?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In Analysis Services, a KPI is a collection of calculations that are associated with a measure group in a cube that are used to evaluate business success. We use KPI to see the business at the particular point, this is represents with some graphical items such as traffic signals,ganze etc</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are actions, how many types of actions are there, explain with example?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Actions are powerful way of extending the value of SSAS cubes for the end user. They can click on a cube or portion of a cube to start an application with the selected item as a parameter, or to retrieve information about the selected item.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">One of the objects supported by a SQL Server Analysis Services cube is the action. An action is an event that a user can initiate when accessing cube data. The event can take a number of forms. For example, a user might be able to view a Reporting Services report, open a Web page, or drill through to detailed information related to the cube data</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Analysis Services supports three types of actions..</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Report action: </strong>Report action Returns a Reporting Services report that is associated with the cube data on which the action is based.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Drill through: </strong>Drillthrough Returns a result set that provides detailed information related to the cube data on which the action is based.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Standard: </strong>Standard has five action subtypes that are based on the specified cube data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Dataset:</strong> Returns a mutlidimensional dataset.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Proprietary:</strong> Returns a string that can be interpreted by a client application.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Rowset:</strong> Returns a tabular rowset.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Statement:</strong> Returns a command string that can be run by a client application.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>URL:</strong> Returns a URL that can be opened by a client application, usually a browser.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is partition, how will you implement it?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You can use the Partition Wizard to define partitions for a measure group in a cube. By default, a single partition is defined for each measure group in a cube. Access and processing performance, however, can degrade for large partitions. By creating multiple partitions, each containing a portion of the data for a measure group, you can improve the access and processing performance for that measure group.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is the minimum and maximum number of partitions required for a measure group?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In 2005 a MAX of 2000 partitions can be created per measure group and that limit is lifted in later versions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In any version the MINIMUM is ONE Partition per measure group.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What are Aggregations and its use?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Aggregations provide performance improvements by allowing Microsoft SQL Server Analysis Services (SSAS) to retrieve pre-calculated totals directly from cube storage instead of having to recalculate data from an underlying data source for each query. To design these aggregations, you can use the Aggregation Design Wizard. This wizard guides you through the following steps:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Selecting standard or custom settings for the storage and caching options of a partition, measure group, or cube.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Providing estimated or actual counts for objects referenced by the partition, measure group, or cube.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Specifying aggregation options and limits to optimize the storage and query performance delivered by designed aggregations.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Saving and optionally processing the partition, measure group, or cube to generate the defined aggregations.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">After you use the Aggregation Design Wizard, you can use the Usage-Based Optimization Wizard to design aggregations based on the usage patterns of the business users and client applications that query the cube.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is perspective, have you ever created perspective?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Perspectives are a way to reduce the complexity of cubes by hidden elements like measure groups, measures, dimensions, hierarchies etc. It’s nothing but slicing of a cube, for ex we are having retail and hospital data and end user is subscribed to see only hospital data, then we can create perspective according to it.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is deploy, process and build?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Bulid:</strong> Verifies the project files and create several local files.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Deploy: </strong>Deploy the structure of the cube(Skeleton) to the server.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Process:</strong> Read the data from the source and build the dimesions and cube structures</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Elaborating the same is given below.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Build: </strong>Its is a used to process the data of the cube database. Build is a version of a <a href="http://searchsoftwarequality.techtarget.com/sDefinition/0,,sid92_gci212834,00.html">program</a>. As a rule, a build is a pre-release version and as such is identified by a build number, rather than by a release number. Reiterative (repeated) builds are an important part of the development process. Throughout development, application components are collected and repeatedly <a href="http://whatis.techtarget.com/definition/0,,sid9_gci211824,00.html">compiled</a> for testing purposes, to ensure a reliable final product. Build tools, such as <a href="http://whatis.techtarget.com/definition/0,,sid9_gci873189,00.html">make</a> or <a href="http://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci873167,00.html">Ant</a>, enable developers to automate some programming tasks. As a verb, to build can mean either to write <a href="http://whatis.techtarget.com/definition/0,,sid9_gci213934,00.html">code</a> or to put individual coded components of a program together.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Deployment: </strong>During development of an Analysis Services project in Business Intelligence Development Studio, you frequently deploy the project to a development server in order to create the Analysis Services database defined by the project. This is required to test the project.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">for example, to browse cells in the cube, browse dimension members, or verify key performance indicators (KPIs) formulas.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What is the maximum size of a dimension?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The maximum size of the dimension is <strong>4 gb</strong>.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <strong>What are the types of processing and explain each?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They are 6 types of processing in ssas ,they are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Process Full</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Process Data</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Process Index</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Process Incremental</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Process Structure</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">UnProcess</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> Process Full: </strong>Processes an Analysis Services object and all the objects that it contains. When Process Full is executed against an object that has already been processed, Analysis Services drops all data in the object, and then processes the object. This kind of processing is required when a structural change has been made to an object, for example, when an attribute hierarchy is added, deleted, or renamed. This processing option is supported for cubes, databases, dimensions, measure groups, mining models, mining structures, and partitions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Process Data: </strong>Processes data only without building aggregations or indexes. If there is data is in the partitions, it will be dropped before re-populating the partition with source data. This processing option is supported for dimensions, cubes, measure groups, and partitions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Process Index: </strong>Creates or rebuilds indexes and aggregations for all processed partitions. This option causes an error on unprocessed objects. This processing option is supported for cubes, dimensions, measure groups, and partitions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Process Increment: A</strong>dds newly available fact data and process only to the relevant partitions. This processing option is supported for measure groups, and partitions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Process Structure: </strong>If the cube is unprocessed, Analysis Services will process, if it is necessary, all the cube’s dimensions. After that, Analysis Services will create only cube definitions. If this option is applied to a mining structure, it populates the mining structure with source data. The difference between this option and the Process Full option is that this option does not iterate the processing down to the mining models themselves. This processing option is supported for cubes and mining structures.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Unprocess : </strong>Drops the data in the object specified and any lower-level constituent objects. After the data is dropped, it is not reloaded. This processing option is supported for cubes, databases, dimensions, measure groups, mining models, mining structures, and partitions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Process Default: </strong>Detects the process state of an object, and performs processing necessary to deliver unprocessed or partially processed objects to a fully processed state. This processing option is supported for cubes, databases, dimensions, measure groups, mining models, mining structures, and partitions.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is a cube?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The basic unit of storage and analysis in Analysis Services is the <em>cube</em>. A cube is a collection of data that’s been aggregated to allow queries to return data quickly.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">For example, a cube of order data might be aggregated by time period and by title, making the cube fast when you ask questions concerning orders by week or orders by title.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is AMO?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The full form of AMO is Analysis Managament Objects. This is used to create or alter cubes from .NET code.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>After creating the cube, if we added a new column to the OLTP table then how you add this new attribute to the cube?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Just open the datasourceview and on right click we find the option REFRESH. Click the REFRESH then it will add new attributes to the table which can be added to Cube.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="text-decoration: underline;"><strong>REAL TIME INTERVIEW QUESTIONS - </strong></span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is the size of the Cube in your last Project?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Answer to this question varies from project to project and mainly depends on how BIG is your database and how COMPLEX the database design is. Generally for the database with a TRANSACTION TABLE of 50 crore records, the cube size will be around 100GB. So, better go with 100GB as answer to this question.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is size of the database in your last Project?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You can expect this question immediately after you answer 100GB to the last question. The database size will be 600 to 800GB for which the cube will come to 100 GB. So go with 800GB for this question.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is size of the fact(Transaction) table in your last Project?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This will be the next question if you answer 800GB as your dataabase size. Here he is not expecting SIZE in GBs but the interviewer will be expecting NUMBER OF ROWS in the Transaction table. Go with 57Crore records for this question.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How frequently you process the cube?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You have to be very careful here. Frequency of processing cube depends on HOW FREQUENTLY YOU ARE GETTING NEW DATA. Once the new data comes then SSIS team loads it and send a mail to SSAS team after load is completed successfully. Once SSAS team receives the mail then these guys will look for best time to PROCESS.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Typically we get data either Weekly or Monthly. So you can say that the processing of the cube will be done either Weekly or monthly.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How frequently you get DATA from clients?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This answer should be based on your last answer. IF you answered WEEKLY to last question then the Answer to this question also should be WEEKLY. IF MONTHLY for last question then this answer also should be MONTHLY.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What type of Processing Options you used to process the cube in your Project?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This is the toughest question to answer. This depends on DATA you have and CLIENTS requirements. Let me explain here.</span></span></div><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">If the database is SMALL, let’s say it has only 1 crore records then people do FULL PROCESS as it wont take much time.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">If the database is MEDIUM, let’s say it has only 15 crore records then people prefer to do INCREMENTAL PROCESS unless CLIENTS ask us to do FULL PROCESS as it takes little bit of time.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">If the database is HUGE, let’s say it has more than 35 to 40 crore records then people prefer to do INCREMENTAL PROCESS unless CLIENTS ask us to do FULL PROCESS as it takes lot of time. In this case we TRY to convince clients for INCREMENTAL and if they don’t agree then we don’t have any other option.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Incremental process will come into picture ONLY when there is no updates to the OLD data i.e no changes to already existing data else NO OTHER OPTION than FULL PROCESS.</span></span></li></ol></div><div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How you provide security to cube?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>By defining roles we provide security to cubes. Using roles we can restrict users from accessing restricted data. Procedure as follows - </b></span></span></div><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Define Role</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Set Permission</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Add appropriate Users to the role</span></span></li></ol></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How you move the cube from one server to another?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are many ways to do the same. Let me explain four here and cleverly you can say “I worked on 4 SSAS projects till date and implemented different types in all the four.”</span></span></div><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Backup and restore – This is the simplest way. Take the Backup from development server and copy the backup to FTP folder of clients. After doing this drop a mail to Client’s Admin and he will take care of RESTORE part.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Directly PROCESS the cube in PRODUCTION environment. For this you need access to Production which will not be given by clients unless the clients are *********. One of the client I worked for given FULL access to me .. <img alt=";)" class="wp-smiley" src="http://www.msbiguide.com/wp-includes/images/smilies/icon_wink.gif" /></span></span> </li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Under Srart –> All Programs –> Sql Server –> Analysis Services you can see deployment wizard. This is one way of moving the cube. This method has some steps to follow. First deploy your cube and FOUR files will be created in BIN folder of PROJECT folder. Copy those FOUR files and paste in Production server in any directory. Then OPEN this DEPLOYMENT Wizard in production and when it ask for Database file then point to the location where you copied the files. After that NEXT,NEXT,NEXT … OK .. Cube will be deployed and processed.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This way is most beautiful one. Synchronization, In this we will first deploy and process the cube in STAGING ENVIRONMENT and then we will go to production server. Connect to Analysis services in SSMS and select Synchronize by right clicking on Databases folder in SSMS of analysis services. Then select source as STAGING SERVER and then click on OK. The changes in the cube present in the Staging server will be copied to the production server.</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 13px;"><strong>What is the toughest challenge you face in your Project?</strong><br /></span></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 13px;">There are couple of this where we face difficulty.</span></span></span></div><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">While working on RELATIONSHIPS between Measure Groups and Dimensions.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Working on Complex calculations</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Performance tuning</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 13px;"><strong>How you created Partitions of the cube in your Last Project?</strong><br /></span></span></span></li></ul></div></div></div></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Partitions can be created on different data. Few people do it on PRODUCT NAME wise and many prefer to do it on DATE data wise. you go with DATE wise.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In dates, we can create MONTH wise,WEEK wise,QUARTER wise and some times YEAR wise. This all depends on how much data you are coming per WEEK or MONTH or QUARTER … If you are getting 50 lakhs records per month then tell you do MONTH wise.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How many dimensions in your last cube?</strong></span></span></li></ul></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">47 to 50.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How many measure groups in your last cube?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Total 10 and in that 4 are Fact tables and remaining 6 are Fact less fact tables.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is the Schema of your last cube?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Snowflake</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Why not STAR Schema ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">My data base design doesn’t support STAR Schema.</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are the different relationships that you are used in your cube?</strong></span></span></li></ul><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Regular</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Referenced</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Many to Many</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fact</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">No Relationship</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 13px;"><strong>Have you created the KPI’s , If then Explain?</strong><br /></span></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 13px;">Don’t add much to this as the questions in this will be tricky. Just tell that you worked on couple of KPI and you have basic knowledge on this. (Don’t worry, this is not MANDATORY)</span></span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How you define Aggregations in your Project?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We defined the aggregations for MOST FREQUENTLY USED data in SSRS reports.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Size of SSAS team in your last Project?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Just 2 guys as we guys are really in demand and lot of scarcity:)</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How many Resources worked on same Cube in your Project?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Only 2 and one in morning shift and another in Evening shift.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How much time it take to Process the Cube?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This is Very very important question. This again depends on the SIZE of database,Complexity of the database and your server settings. For database with 50 cr transaction records, it generally takes 3.5 hrs.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How many Calculation you done in Your Project?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">I answer more than 5000 and if you tell the same then you are caught unless you are super good in MDX. Best answer for you is “Worked on 50 calculations”.</span></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-18593337183047630102013-11-09T06:12:00.000-08:002014-02-15T07:41:34.302-08:00SSIS Interview Questions and Answers<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What do we mean by dataflow in SSIS?</strong><br />Data flow is nothing but the flow of data from the corresponding sources to the referred destinations. In this process, the data transformations make changes to the data to make it ready for the data warehouse.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is a breakpoint in SSIS? How is it setup? How do you disable it?</strong><br />A breakpoint is a stopping point in the code. The breakpoint can give the Developer\DBA an<br />opportunity to review the status of the data, variables and the overall status of the SSIS package.<br />10 unique conditions exist for each breakpoint.<br />Breakpoints are setup in BIDS. In BIDS, navigate to the control flow interface. Right click on the<br />object where you want to set the breakpoint and select the ‘Edit Breakpoints…’ option.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Can you name 5 or more of the native SSIS connection managers?</strong></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1) OLEDB connection – Used to connect to any data source requiring an OLEDB connection (i.e.,<br />SQL Server 2000)<br />2) Flat file connection – Used to make a connection to a single file in the File System. Required for reading information from a File System flat file<br />3) ADO.Net connection – Uses the .Net Provider to make a connection to SQL Server 2005 or other<br />connection exposed through managed code (like C#) in a custom task<br />4) Analysis Services connection – Used to make a connection to an Analysis Services database or project. Required for the Analysis Services DDL Task and Analysis Services Processing Task<br />5) File connection – Used to reference a file or folder. The options are to either use or create a file or folder<br />6) Excel</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the use of Bulk Insert Task in SSIS?</strong><br />Bulk Insert Task is used to upload large amount of data from flat files into Sql Server. It supports only OLE DB connections for destination database.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Conditional Split transformation in SSIS?</strong><br />This is just like IF condition which checks for the given condition and based on the condition evaluation, the output will be sent to the appropriate OUTPUT path. It has ONE input and MANY outputs. Conditional Split transformation is used to send paths to different outputs based on some conditions. For example, we can organize the transform for the students in a class who have marks greater than 40 to one path and the students who score less than 40 to another path.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• How do you eliminate quotes from being uploaded from a flat file to SQL Server? </strong><br />This can be done using TEXT QUALIFIER property. In the SSIS package on the Flat File Connection Manager Editor, enter quotes into the Text qualifier field then preview the data to ensure the quotes are not included.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Can you explain how to setup a checkpoint file in SSIS?</strong><br />The following items need to be configured on the properties tab for SSIS package:</span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>CheckpointFileName</strong> – Specify the full path to the Checkpoint file that the package uses to save the value of package variables and log completed tasks. Rather than using a hard-coded path as shown above, it’s a good idea to use an expression that concatenates a path defined in a package variable and the package name.</span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>CheckpointUsage</strong> – Determines if/how checkpoints are used. Choose from these options: Never(default), IfExists, or Always. Never indicates that you are not using Checkpoints. IfExists is the typical setting and implements the restart at the point of failure behavior. If a Checkpoint file is found it is used to restore package variable values and restart at the point of failure. If a Checkpoint file is not found the package starts execution with the first task. The Always choice raises an error if the Checkpoint file does not exist.</span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>SaveCheckpoints</strong> – Choose from these options: True or False (default). You must select True to implement the Checkpoint behavior.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are the different values you can set for CheckpointUsage property ?</strong><br />There are three values, which describe how a checkpoint file is used during package execution:<br />1) <strong>Never</strong>: The package will not use a checkpoint file and therefore will never restart.<br />2) <strong>If Exists</strong>: If a checkpoint file exists in the place you specified for the CheckpointFilename property, then it will be used, and the package will restart according to the checkpoints written.<br />3) <strong>Always</strong>: The package will always use a checkpoint file to restart, and if one does not exist, the package will fail.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the ONLY Property you need to set on TASKS in order to configure CHECKPOINTS to RESTART package from failure?</strong><br />The one property you have to set on the task is <strong>FailPackageOnFailure</strong>. This must be set for each task or container that you want to be the point for a checkpoint and restart. If you do not set this property to true and the task fails, no file will be written, and the next time you invoke the package, it will start from the beginning again.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Where can we set the CHECKPOINTS, in DataFlow or ControlFlow ?</strong><br />Checkpoints only happen at the Control Flow; it is not possible to checkpoint transformations or restart inside a Data Flow. The Data Flow Task can be a checkpoint, but it is treated as any other task.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Can you explain different options for dynamic configurations in SSIS?</strong><br />1) XML file<br />2) custom variables<br />3) Database per environment with the variables<br />4) Use a centralized database with all variables</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the use of Percentage Sampling transformation in SSIS?</strong><br />Percentage Sampling transformation is generally used for data mining. This transformation builds a random sample of set of output rows by choosing specified percentage of input rows. For example if the input has 1000 rows and if I specify 10 as percentage sample then the transformation returns 10% of the RANDOM records from the input data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the use of Term Extraction transformation in SSIS?</strong><br />Term Extraction transformation is used to extract nouns or noun phrases or both noun and noun phrases only from English text. It extracts terms from text in a transformation input column and then writes the terms to a transformation output column. It can be also used to find out the content of a dataset.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Data Viewer and what are the different types of Data Viewers in SSIS?</strong><br />A Data Viewer allows viewing data at a point of time at runtime. If data viewer is placed before and after the Aggregate transform, we can see data flowing to the transformation at the runtime and how it looks like after the transformation occurred. The different types of data viewers are:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1. Grid<br />2. Histogram<br />3. Scatter Plot<br />4. Column Chart.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Ignore Failure option in SSIS?</strong><br />In Ignore Failure option, the error will be ignored and the data row will be directed to continue on the next transformation. Let’s say you have some JUNK data(wrong type of data or JUNK data) flowing from source, then using this option in SSIS we can REDIRECT the junk data records to another transformation instead of FAILING the package. This helps to MOVE only valid data to destination and JUNK can be captured into separate file.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Which are the different types of Control Flow components in SSIS?</strong><br />The different types of Control Flow components are: Data Flow Tasks, SQL Server Tasks, Data Preparation Tasks, Work flow Tasks, Scripting Tasks, Analysis Services Tasks, Maintenance Tasks, Containers.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are containers? What are the different types of containers in SSIS?</strong><br />Containers are objects that provide structures to packages and extra functionality to tasks. There are four types of containers in SSIS, they are: Foreach Loop Container, For Loop Container, Sequence Container and Task Host Container.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are the different types of Data flow components in SSIS?</strong><br />There are 3 data flow components in SSIS.<br />1. Sources<br />2. Transformations<br />3. Destinations</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are the different types of data sources available in SSIS?</strong><br />There are 7 types of data sources provided by SSIS: a.) Data Reader source b.) Excel source c.) Flat file source d.) OLEDB source e.) Raw file source f.) XML source g.) Script component</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is SSIS Designer?</strong><br />It is a graphical tool for creating packages. It has 4 tabs: Control Flow, Data Flow, Event Handlers and Package Explorer.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Control Flow tab?</strong><br />It is the tab in SSIS designer where various Tasks can be arranged and configured. This is the tab where we provide and control the program flow of the project.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Data Flow tab?</strong><br />This is the tab where we do all the work related to ETL job. It is the tab in SSIS Designer where we can extract data from sources, transform the data and then load them into destinations.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the function of control flow tab in SSIS?</strong><br />On the control flow tab, the tasks including dataflow task, containers and precedence constraints that connect containers and tasks can be arranged and configured.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the function of Event handlers tab in SSIS?</strong><br />On the Event handlers tab, workflows can be configured to respond to package events.<br />For example, we can configure Work Flow when ANY task Failes or Stops or Starts ..</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the function of Package explorer tab in SSIS?</strong><br />This tab provides an explorer view of the package. You can see what is happening in the package. The Package is a container at the top of the hierarchy.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Solution Explorer?</strong><br />It is a place in SSIS Designer where all the projects, Data Sources, Data Source Views and other miscellaneous files can be viewed and accessed for modification.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• How do we convert data type in SSIS?</strong><br />The Data Conversion Transformation in SSIS converts the data type of an input column to a different data type.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• How are variables useful in ssis package?</strong><br />Variables can provide communication among objects in the package. Variables can provide communication between parent and child packages. Variables can also be used in expressions and scripts. This helps in providing dynamic values to tasks.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Aggregate Transformation in SSIS?</strong><br />It aggregates data, similar you do in applying TSQL functions like Group By, Min, Max, Avg, and Count. For example you get total quantity and Total line item for each product in Aggregate Transformation Editor. First you determine input columns, then output column name in Output Alias table in datagrid, and also operations for each Output Alias in Operation columns of the same datagrid. Some of operation functions listed below :<br />• Group By<br />• Average<br />• Count<br />• Count Distinct : count distinct and non null column value<br />• Min, Max, Sum<br />In Advanced tab, you can do some optimization here, such as setting up Key Scale option (low, medium, high), Count Distinct scale option (low, medium, high), Auto Extend factor and Warn On Division By Zero. If you check Warn On Division By Zero, the component will give warning instead of error. Key Scale option will optimize transformation cache to certain number of key threshold. If you set it low, optimization will target to 500,000 keys written to cache, medium can handle up to 5 million keys, and high can handle up to 25 million keys, or you can specify particular number of keys here. Default value is unspecified. Similar to number of keys for Count Distinct scale option. It is used to optimize number of distinct value written to memory, default value is unspecified. Auto Extend Factor is used when you want some portion of memory is used for this component. Default value is 25% of memory.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Audit Transformation ?</strong><br />It allows you to add auditing information as required in auditing world specified by HIPPA and Sarbanes-Oxley (SOX). Auditing options that you can add to transformed data through this transformation are :<br />1. Execution of Instance GUID : ID of execution instance of the package<br />2. PackageID : ID of the package<br />3. PackageName<br />4. VersionID : GUID version of the package<br />5. Execution StartTime<br />6. MachineName<br />7. UserName<br />8. TaskName<br />9. TaskID : uniqueidentifier type of the data flow task that contains audit transformation.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Character Map Transformation?</strong><br />It transforms some character. It gives options whether output result will override the existing column or add to new column. If you define it as new column, specify new column name. Operations available here are:<br />1. Uppercase<br />2. Lowercase<br />3. Byte reversal : such as from 0×1234 to 0×4321<br />4. Full width<br />5. Half width<br />6. Hiragana/katakana/traditional Chinese/simplified Chinese<br />7. Linguistic casing</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Conditional split Transformation ?</strong><br />It functions as if…then…else construct. It enables send input data to a satisfied conditional branch. For example you want to split product quantity between less than 500 and greater or equal to 500. You can give the conditional a name that easily identifies its purpose. Else section will be covered in Default Output Column name.<br />After you configure the component, it connect to subsequent transformation/destination, when connected, it pops up dialog box to let you choose which conditional options will apply to the destination transformation/destination.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Copy column Transformation?</strong><br />This component simply copies a column to another new column. Just like ALIAS Column in T-Sql.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Data conversion Transformation?</strong><br />This component does conversion data type, similar to TSQL function CAST or CONVERT. If you wish to convery the data from one type to another then this is the best bet. But please make sure that you have COMPATABLE data in the column.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Data Mining query Transformation?</strong><br />This component does prediction on the data or fills gap on it. Some good scenarios uses this component is:<br />1. Take some input columns as number of children, domestic income, and marital income to predict whether someone owns a house or not.<br />2. Take prediction what a customer would buy based analysis buying pattern on their shopping cart.<br />3. Filling blank data or default values when customer doesn’t fill some items in the questionnaire.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Derived column Transformation?</strong><br />Derived column creates new column or put manipulation of several columns into new column. You can directly copy existing or create a new column using more than one column also.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Merge Transformation?</strong><br />Merge transformation merges two paths into single path. It is useful when you want to break out data into path that handles errors after the errors are handled, the data are merge back into downstream or you want to merge 2 data sources. It is similar with Union All transformation, but Merge has some restrictions :<br />1. Data should be in sorted order<br />2. Data type , data length and other meta data attribute must be similar before merged.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Merge Join Transformation?</strong><br />Merge Join transformation will merge output from 2 inputs and doing INNER or OUTER join on the data. But if you the data come from 1 OLEDB data source, it is better you join through SQL query rather than using Merge Join transformation. Merge Join is intended to join 2 different data source.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Multicast Transformation?</strong><br />This transformation sends output to multiple output paths with no conditional as Conditional Split does. Takes ONE Input and makes the COPY of data and passes the same data through many outputs. In simple Give one input and take many outputs of the same data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Percentage and row sampling Transformations?</strong><br />This transformation will take data from source and randomly sampling data. It gives you 2 outputs. First is selected data and second one is unselected data. It is used in situation where you train data mining model. These two are used to take the SAMPLE of data from the input data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Sort Transformation?</strong><br />This component will sort data, similar in TSQL command ORDER BY. Some transformations need sorted data.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Explain Union all Transformation?</strong><br />It works in opposite way to Merge transformation. It can take output from more than 2 input paths and combines into single output path.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What r the possible locations to save SSIS package?</strong><br />You can save a package wherever you want.<br />SQL Server<br />Package Store<br />File System</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is a package?</strong><br />A discrete executable unit of work composed of a collection of control flow and other objects, including data sources, transformations, process sequence, and rules, errors and event handling, and data destinations.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is a workflow in SSIS?</strong><br />A workflow is a set of instructions on how to execute tasks.<br />(It is a set of instructions on how to execute tasks such as sessions, emails and shell commands. a workflow is created form work flow mgr.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is the diff between control flow Items and data flow Items?</strong><br />The control flow is the highest level control process. It allows you to manage the run-time process activities of data flow and other processes within a package.<br />When we want to extract, transform and load data within a package. You add an SSIS dataflow task to the package control flow.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are the main component of SSIS(project-architecture)?</strong><br />SSIS archItecture has 4 main components<br />1.ssis service<br />2.ssis runtime engine & runtime executables<br />3.ssis dataflow engine & dataflow components<br />4.ssis clients</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• Different components in SSIS package?</strong><br />Control flow<br />Data flow<br />Event handler<br />Package explorer</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are Connection Managers?</strong><br />It is a bridge b/w package object and physical data. It provides logical representation of a connection at design time the properties of the connection mgr describes the physical connection that integration services creates when the package is run.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is environment variable in SSIS?</strong><br />An environment variable configuration sets a package property equal to the value in an environment variable.<br />Environmental configurations are useful for configuring properties that are dependent on the computer that is executing the package.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• How to provide securIty to packages?</strong><br />We can provide security in two ways<br />1. Package encryption<br />2. Password protection.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What are Precedence constraints?</strong><br />Constraints that link executable, container, and tasks wIthin the package control flow and specify condItion that determine the sequence and condItions for determine whether executable run.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>• What is Design time Deployment in SSIS ?</strong></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">When<strong> </strong>you run a package from with in BIDS,it is built and temporarily deployed to the folder. By default the package will be deployed to the BIN folder in the Package’s Project folder and you can configure for custom folder for deployment. When the Package’s execution is completed and stopped in BIDS,the deployed package will be deleted and this is called as Design Time Deployment.</span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-1852101558574866692013-11-09T06:08:00.000-08:002014-02-15T07:41:34.314-08:00Sql Server Interview Questions with Answers<div dir="ltr" style="text-align: left;" trbidi="on"><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What are Constraints or Define Constraints ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Generally we use Data Types to limit the kind of Data in a Column. For example, if we declare any column with data type INT then ONLY Integer data can be inserted into the column. Constraint will help us to limit the Values we are passing into a column or a table. In simple Constraints are nothing but Rules or Conditions applied on columns or tables to restrict the data.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong><strong>Different types of Constraints ?</strong></strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are THREE Types of Constraints.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Domain</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Entity</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Referential</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Domain has the following constraints types -</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Not Null</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Check</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Entity has the following constraint types -</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Primary Key</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Unique Key</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Referential has the following constraint types -</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Foreign Key</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 13px;"><strong>What is the difference between Primary Key and Unique Key ?</strong></span></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both the Primary Key(PK) and Unique Key(UK) are meant to provide Uniqueness to the Column on which they are defined. PFB the major differences between these two.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">By default PK defines Clustered Index in the column where as UK defines Non Clustered Index.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">PK doesn’t allow NULL Value where as UK allow ONLY ONE NULL.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You can have only one PK per table where as UK can be more than one per table.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">PK can be used in Foreign Key relationships where as UK cannot be used.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong><span style="line-height: 13px;">What is the difference between Delete and Truncate ?</span></strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both Delete and Truncate commands are meant to remove rows from a table. There are many differences between these two and pfb the same.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Truncate is Faster where as Delete is Slow process.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Truncate doesn’t log where as Delete logs an entry for every record deleted in Transaction Log.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can rollback the Deleted data where as Truncated data cannot be rolled back.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Truncate resets the Identity column where as Delete doesn’t.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can have WHERE Clause for delete where as for Truncate we cannot have WHERE Clause.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Delete Activates TRIGGER where as TRUNCATE Cannot.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Truncate is a DDL statement where as Delete is DML statement.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong><span style="line-height: 13px;">What are Indexes or Indices ?</span></strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">An Index in SQL is similar to the Index in a book. Index of a book makes the reader to go to the desired page or topic easily and Index in SQL helps in retrieving the data faster from database. An Index is a seperate physical data structure that enables queries to pull the data fast. Indexes or Indices are used to improve the performance of a query.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Types of Indices in SQL ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are TWO types of Indices in SQL server.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Clustered</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Non Clustered</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong><span style="line-height: 13px;">How many Clustered and Non Clustered Indexes can be defined for a table ?</span></strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Clustered – 1<br />Non Clustered – 999</span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">MSDN reference – <a href="http://msdn.microsoft.com/en-us/library/ms143432.aspx" target="_blank">Click Here</a></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Transaction in SQL Server ? </strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Transaction groups a set of T-Sql Statements into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group successfully complete. If any of the tasks fails, the transaction fails. Therefore, atransaction has only two results: success or failure. Incomplete steps result in the failure of the transaction.by programmers to group together read and write operations. In Simple Either FULL or NULL i.e either all the statements executes successfully or all the execution will be rolled back.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Types of Transactions ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are TWO forms of Transactions.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Implicit – Specifies any Single Insert,Update or Delete statement as Transaction Unit. No need to specify Explicitly.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Explicit – A group of T-Sql statements with the beginning and ending marked with Begin Transaction,Commit and RollBack. PFB an Example for Explicit transactions.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">BEGIN TRANSACTION</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Update Employee Set Emp_ID = 54321 where Emp_ID = 12345</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">If(@@Error <>0)</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ROLLBACK</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Update LEave_Details Set Emp_ID = 54321 where Emp_ID = 12345</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">If(@@Error <>0)</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ROLLBACK</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">COMMIT</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In the above example we are trying to update an EMPLOYEE ID from 12345 to 54321 in both the master table “Employee” and Transaction table “Leave_Details”. In this case either BOTH the tables will be updated with new EMPID or NONE.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is the Max size and Max number of columns for a row in a table ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Size – 8060 Bytes</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Columns – 1024</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Normalization and Explain different normal forms.</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Database normalization is a process of data design and organization which applies to data structures based on rules that help building relational databases.<br />1. Organizing data to minimize redundancy.<br />2. Isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1NF: Eliminate Repeating Groups</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Each set of related attributes should be in separate table, and give each table a primary key. Each field contains at most one value from its attribute domain.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">2NF: Eliminate Redundant Data</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1. Table must be in 1NF.<br />2. All fields are dependent on the whole of the primary key, or a relation is in 2NF if it is in 1NF and every non-key attribute is fully dependent on each candidate key of the relation. If an attribute depends on only part of a multi‐valued key, remove it to a separate table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">3NF: Eliminate Columns Not Dependent On Key</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1. The table must be in 2NF.<br />2. Transitive dependencies must be eliminated. All attributes must rely only on the primary key. If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">BCNF: Boyce‐Codd Normal Form<br />for every one of its non-trivial functional dependencies X → Y, X is a superkey—that is, X is either a candidate key or a superset thereof. If there are non‐trivial dependencies between candidate key attributes, separate them out into distinct tables.<br />4NF: Isolate Independent Multiple Relationships<br />No table may contain two or more 1:n or n:m relationships that are not directly related.<br />For example, if you can have two phone numbers values and two email address values, then you should not have them in the same table.<br />5NF: Isolate Semantically Related Multiple Relationships<br />A 4NF table is said to be in the 5NF if and only if every join dependency in it is implied by the candidate keys. There may be practical constrains on information that justify separating logically related many‐to‐many relationships.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Denormalization ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">For optimizing the performance of a database by adding redundant data or by grouping data is called de-normalization.<br />It is sometimes necessary because current DBMSs implement the relational model poorly.<br />In some cases, de-normalization helps cover up the inefficiencies inherent in relational database software. A relational normalized database imposes a heavy access load over physical storage of data even if it is well tuned for high performance.<br />A true relational DBMS would allow for a fully normalized database at the logical level, while providing physical storage of data that is tuned for high performance. De‐normalization is a technique to move from higher to lower normal forms of database modeling in order to speed up database access.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Query to Pull ONLY duplicate records from table ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are many ways of doing the same and let me explain one here. We can acheive this by using the keywords GROUP and HAVING. The following query will extract duplicate records from a specific column of a particular table.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Select specificColumn<br />FROM particluarTable<br />GROUP BY specificColumn<br />HAVING COUNT(*) > 1</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This will list all the records that are repeated in the column specified by “specificColumn” of a “particlarTable”.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Types of Joins in SQL SERVER ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">There are 3 types of joins in Sql server.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Inner Join</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Outer Join</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Cross Join</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Outer join again classified into 3 types.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Right Outer Join</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Left Outer Join</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Full Outer Join.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Table Expressions in Sql Server ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Table Expressions are subqueries that are used where a TABLE is Expected. There are TWO types of table Expressions.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Derived tables</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Common Table Expressions.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Derived Table ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Derived tables are table expression which appears in FROM Clause of a Query. PFB an example of the same.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">select * from (Select Month(date) as Month,Year(Date) as Year from table1) AS Table2</span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In the above query the subquery in FROM Clause “(Select Month(date) as Month,Year(Date) as Year from table1) ” is called Derived Table.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is CTE or Common Table Expression ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Common table expression (CTE) is a temporary named result set that you can reference within a</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SELECT, INSERT, UPDATE, or DELETE statement. You can also use a CTE in a CREATE VIEW statement, as part of the view’s SELECT query. In addition, as of SQL Server 2008, you can add a CTE to the new MERGE statement. There are TWO types of CTEs in Sql Server -</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Recursive</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Non Recursive</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Difference between SmallDateTime and DateTime datatypes in Sql server ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both the data types are meant to specify date and time but these two has slight differences and pfb the same.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">DateTime occupies 4 Bytes of data where as SmallDateTime occupies only 2 Bytes.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">DateTime ranges from 01/01/1753 to 12/31/9999 where as SmallDateTime ranges from 01/01/1900 to 06/06/2079.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong><span style="line-height: 13px;">What is SQL_VARIANT Datatype ? </span></strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The SQL_VARIANT data type can be used to store values of various data types at the same time, such as numeric values, strings, and date values. (The only types of values that cannot be stored are TIMESTAMP values.) Each value of an SQL_VARIANT column has two parts: the data value and the information that describes the value. (This information contains all properties of the actual data type of the value, such as length, scale, and precision.)</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Temporary table ? </strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A temporary table is a database object that is temporarily stored and managed by the database system. There are two types of Temp tables.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Local</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Global</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are the differences between Local Temp table and Global Temp table ? </strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Before going to the differences, let’s see the similarities.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both are stored in tempdb database.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both will be cleared once the connection,which is used to create the table, is closed.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both are meant to store data temporarily.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">PFB the differences between these two.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Local temp table is prefixed with # where as Global temp table with ##.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Local temp table is valid for the current connection i.e the connection where it is created where as Global temp table is valid for all the connection.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Local temp table cannot be shared between multiple users where as Global temp table can be shared.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Whar are the differences between Temp table and Table variable ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This is very routine question in interviews. Let’s see the major differences between these two.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Table variables are Transaction neutral where as Temp tables are Transaction bound. For example if we declare and load data into a temp table and table variable in a transaction and if the transaction is ROLLEDBACK, still the table variable will have the data loaded where as Temp table will not be available as the transaction is rolled back.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Temporary Tables are real tables so you can do things like CREATE INDEXes, etc. If you have large amounts of data for which accessing by index will be faster then temporary tables are a good option.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Table variables don’t participate in transactions, logging or locking. This means they’re faster as they don’t require the overhead.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">You can create a temp table using SELECT INTO, which can be quicker to write (good for ad-hoc querying) and may allow you to deal with changing datatypes over time, since you don’t need to define your temp table structure upfront.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is the difference between Char,Varchar and nVarchar datatypes ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>char[(n)]</strong> - Fixed-length non-Unicode character data with length of n bytes. n must be a value from 1 through 8,000. Storage size is n bytes. The SQL-92 synonym for char is character.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>varchar[(n)] </strong>- Variable-length non-Unicode character data with length of n bytes. n must be a value from 1 through 8,000. Storage size is the actual length in bytes of the data entered, not n bytes. The data entered can be 0 characters in length. The SQL-92 synonyms for varchar are char varying or character varying.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>nvarchar(n) </strong>- Variable-length Unicode character data of n characters. n must be a value from 1 through 4,000. Storage size, in bytes, is two times the number of characters entered. The data entered can be 0 characters in length. The SQL-92 synonyms for nvarchar are national char varying and national character varying.</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is the difference between STUFF and REPLACE functions in Sql server ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The Stuff function is used to replace characters in a string. This function can be used to delete a certain length of the string and replace it with a new string.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Syntax – STUFF (string_expression, start, length, replacement_characters)</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex - SELECT STUFF(‘I am a bad boy’,8,3,’good’)</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Output – “I am a good boy”</span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">REPLACE function replaces all occurrences of the second given string expression in the first string expression with a third expression.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Syntax - REPLACE (String, StringToReplace, StringTobeReplaced)</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Ex – REPLACE(“Roopesh”,”pe”,”ep”)</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Output – “Rooepsh” – You can see PE is replaced with EP in the output.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What are Magic Tables ? </strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Sometimes we need to know about the data which is being inserted/deleted by triggers in database. Whenever a trigger fires in response to the INSERT, DELETE, or UPDATE statement, two special tables are created. These are the <span style="color: red;">inserted <span style="color: black;">and </span><span style="color: black;">the </span>deleted tables</span>. They are also referred to as the <strong>magic tables</strong>. These are the conceptual tables and are similar in structure to the table on which trigger is defined (the trigger table).</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The <strong>inserted table</strong> contains a copy of all records that are inserted in the trigger table.<br />The <strong>deleted table</strong> contains all records that have been deleted from deleted from the trigger table.<br />Whenever any updation takes place, the trigger uses both the inserted and deleted tables.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Explain about RANK,ROW_NUMBER and DENSE_RANK in Sql server ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Found a very interesting explanation for the same in the url <a href="http://mangalpardeshi.blogspot.in/2008/10/difference-between-rownumber-rank-and.html" target="_blank"><strong>Click Here</strong></a> . PFB the content of the same here.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Lets take 1 simple example to understand the difference between 3.<br />First lets create some sample data :</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">– create table<br />CREATE TABLE Salaries<br />(<br />Names VARCHAR(1),<br />SalarY INT<br />)<br />GO<br />– insert data<br />INSERT INTO Salaries SELECT<br />‘A’,5000 UNION ALL SELECT<br />‘B’,5000 UNION ALL SELECT<br />‘C’,3000 UNION ALL SELECT<br />‘D’,4000 UNION ALL SELECT<br />‘E’,6000 UNION ALL SELECT<br />‘F’,10000<br />GO<br />– Test the data<br />SELECT Names, Salary<br />FROM Salaries</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Now lets query the table to get the salaries of all employees with their salary in descending order.<br />For that I’ll write a query like this :<br />SELECT names<br />, salary<br />,row_number () OVER (ORDER BY salary DESC) as ROW_NUMBER<br />,rank () OVER (ORDER BY salary DESC) as RANK<br />,dense_rank () OVER (ORDER BY salary DESC) as DENSE_RANK<br />FROM salaries</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">>>Output</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><table bgcolor="#ffffff" border="1" style="width: 412px;"><tbody><tr bgcolor="#c6c3b5"><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">NAMES</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SALARY</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ROW_NUMBER</span></span></td><td align="center" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">RANK</span></span></td><td align="center" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">DENSE_RANK</span></span></td></tr><tr><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">F</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">10000</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1</span></span></td><td align="center" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1</span></span></td><td align="center" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1</span></span></td></tr><tr><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">E</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">6000</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">2</span></span></td><td align="center" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">2</span></span></td><td align="center" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">2</span></span></td></tr><tr><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">5000</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>3</strong></span></span></td><td align="center" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>3</strong></span></span></td><td align="center" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>3</strong></span></span></td></tr><tr><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">B</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">5000</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>4</strong></span></span></td><td align="center" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>3</strong></span></span></td><td align="center" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>3</strong></span></span></td></tr><tr><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">D</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">4000</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">5</span></span></td><td align="center" bgcolor="#bc8f8f" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>5</strong></span></span></td><td align="center" bgcolor="#bc8f8f" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>4</strong></span></span></td></tr><tr><td width="56"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">C</span></span></td><td width="63"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">3000</span></span></td><td align="center" width="105"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">6</span></span></td><td align="center" width="80"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">6</span></span></td><td align="center" width="106"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">5</span></span></td></tr></tbody></table></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Interesting Names in the result are employee A, B and D. Row_number assign different number to them. Rank and Dense_rank both assign same rank to A and B. But interesting thing is what RANK and DENSE_RANK assign to next row? Rank assign 5 to the next row, while dense_rank assign 4.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The numbers returned by the DENSE_RANK function do not have gaps and always have consecutive ranks. The RANK function does not always return consecutive integers. The ORDER BY clause determines the sequence in which the rows are assigned their unique ROW_NUMBER within a specified partition.<br />So question is which one to use?<br />Its all depends on your requirement and business rule you are following.<br />1. Row_number to be used only when you just want to have serial number on result set. It is not as intelligent as RANK and DENSE_RANK.<br />2. Choice between RANK and DENSE_RANK depends on business rule you are following. Rank leaves the gaps between number when it sees common values in 2 or more rows. DENSE_RANK don’t leave any gaps between ranks.<br />So while assigning the next rank to the row RANK will consider the total count of rows before that row and DESNE_RANK will just give next rank according to the value.<br />So If you are selecting employee’s rank according to their salaries you should be using DENSE_RANK and if you are ranking students according to there marks you should be using RANK(Though it is not mandatory, depends on your requirement.)</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What are the differences between WHERE and HAVING clauses in SQl Server ? </strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">PFB the major differences between WHERE and HAVING Clauses ..</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1.<strong>Where</strong> Clause can be used other than Select statement also where as <strong>Having</strong> is used only with the SELECT statement.<br />2.<strong>Where</strong> applies to each and single row and <strong>Having</strong> applies to summarized rows (summarized with GROUP BY).<br />3.In <strong>Where</strong> clause the data that fetched from memory according to condition and In <strong>having</strong> the completed data firstly fetched and then separated according to condition.<br />4.<strong>Where</strong> is used before GROUP BY clause and <strong>HAVING</strong> clause is used to impose condition on GROUP Function and is used after GROUP BY clause in the query.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Explain Physical Data Model or PDM ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Physical data model represents how the model will be built in the database. A physical database model shows all table structures, including column name, column data type, column constraints, primary key, foreign key, and relationships between tables. Features of a physical data model include:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Specification all tables and columns.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Foreign keys are used to identify relationships between tables.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Specying Data types.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">EG -</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="" src="http://epf.eclipse.org/wikis/openupsp/openup_basic/guidances/guidelines/resources/PDMSample.JPG" height="309" id="il_fi" width="597" /></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Reference from <a href="http://www.1keydata.com/datawarehousing/logical-data-model.html" target="_blank"><strong>Here</strong></a></strong></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> Explain Logical Data Model ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A logical data model describes the data in as much detail as possible, without regard to how they will be physical implemented in the database. Features of a logical data model include:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Includes all entities and relationships among them.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">All attributes for each entity are specified.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The primary key for each entity is specified.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Foreign keys (keys identifying the relationship between different entities) are specified.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Normalization occurs at this level.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="" src="http://www.1keydata.com/datawarehousing/logical-data-model.jpg" height="400" id="il_fi" width="400" /></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Reference from <a href="http://www.1keydata.com/datawarehousing/logical-data-model.html" target="_blank"><strong>Here</strong></a></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Explain Conceptual Data Model ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A conceptual data model identifies the highest-level relationships between the different entities. Features of conceptual data model include:</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Includes the important entities and the relationships among them.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">No attribute is specified.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">No primary key is specified.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="" src="http://www.1keydata.com/datawarehousing/conceptual-data-model.jpg" height="260" id="il_fi" width="300" /></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Reference from <a href="http://www.1keydata.com/datawarehousing/logical-data-model.html" target="_blank"><strong>Here</strong></a></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Log Shipping ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Log Shipping is a basic level SQL Server high-availability technology that is part of SQL Server. It is an automated backup/restore process that allows you to create another copy of your database for failover.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Log shipping involves copying a database backup and subsequent transaction log backups from the primary (source) server and restoring the database and transaction log backups on one or more secondary (Stand By / Destination) servers. The Target Database is in a standby or no-recovery mode on the secondary server(s) which allows subsequent transaction logs to be backed up on the primary and shipped (or copied) to the secondary servers and then applied (restored) there.</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What are the advantages of database normalization ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Benefits of normalizing the database are</span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">No need to restructure existing tables for new data.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Reducing repetitive entries.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Reducing required storage space</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Increased speed and flexibility of queries.</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What are Linked Servers ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Linked servers are configured to enable the Database Engine to execute a Transact-SQL statement that includes tables in another instance of SQL Server, or another database product such as Oracle. Many types OLE DB data sources can be configured as linked servers, including Microsoft Access and Excel. Linked servers offer the following advantages:</span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The ability to access data from outside of SQL Server.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The ability to issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The ability to address diverse data sources similarly.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Can connect to MOLAP databases too.</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is the Difference between the functions COUNT and COUNT_BIG ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Both Count and Count_Big functions are used to count the number of rows in a table and the only difference is what it returns.</span></span></div></div><div><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Count returns INT datatype value where as Count_Big returns BIGINT datatype value.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Count is used if the rows in a table are less where as Count_Big will be used when the numbenr of records are in millions or above.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Syntax -</span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Count – Select count(*) from tablename</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Count_Big – Select Count_Big(*) from tablename</span></span></li></ol><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> How to insert values EXPLICITLY to an Identity Column ? </strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This has become a common question these days in interviews. Actually we cannot Pass values to Identity column and you will get the following error message when you try to pass value.</span></span></div><pre><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Msg 544, Level 16, State 1, Line 3<br />Cannot insert explicit value for identity column in table 'tablename' when IDENTITY_INSERT is set to OFF.</span></span></pre><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">To pass an external value we can use the property IDENTITY_INSERT. PFB the sysntax of the same.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SET IDENTITY_INSERT <tablename> ON;</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Write your Insert statement here by passing external values to the IDENTITY column.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Once the data is inserted then remember to SET the property to OFF.</span></span></div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How to RENAME a table and column in SQL ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can rename a table or a column in SQL using the System stored procedure SP_RENAME. PFB the sample queries.</span></span></div></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Table - </strong>EXEC sp_rename @objname = department, @newname = subdivision</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Column - </strong>EXEC sp_rename @objname = ‘sales.order_no’ , @newname = ordernumber</span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How to rename a database ?</strong></span></span></li></ul></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">To rename a database please use the below syntax.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><pre><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">USE master;<br />GO<br />ALTER DATABASE databasename<br />Modify Name = newname ;<br />GO</span></span></pre><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is the use the UPDATE_STATISTICS command ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">UPDATE_STATISTICS updates the indexes on the tables when there is large processing of data. If we do a large amount of deletions any modification or Bulk Copy into the tables, we need to basically update the indexes to take these changes into account.</span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>How to read the last record from a table with Identity Column ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can get the same using couple of ways and PFB the same.</span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>First - </strong></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SELECT *<br />FROM TABLE<br />WHERE ID = IDENT_CURRENT(‘TABLE’)</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Second - </strong></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">SELECT *<br />FROM TABLE<br />WHERE ID = (SELECT MAX(ID) FROM TABLE)</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Third - </strong></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">select top 1 * from TABLE_NAME order by ID desc</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Worktable ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A <i>worktable</i> is a temporary table used internally by SQL Server to process the intermediate results of a query. Worktables are created in the tempdb database and are dropped automatically after query execution. Thease table cannot be seen as these are created while a query executing and dropped immediately after the execution of the query.</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is HEAP table ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A table with NO CLUSTERED INDEXES is called as HEAP table. The data rows of a heap table are not stored in any particular order or linked to the adjacent pages in the table. This unorganized structure of the heap table usually increases the overhead of accessing a large heap table, when compared to accessing a large nonheap table (a table with clustered index). So, prefer not to go with HEAP tables .. <img alt=":)" class="wp-smiley" src="http://www.msbiguide.com/wp-includes/images/smilies/icon_smile.gif" /></span></span> <br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is ROW LOCATOR ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">If you define a NON CLUSTERED index on a table then the index row of a nonclustered index contains a pointer to the corresponding data row of the table. This pointer is called a <i>row locator</i>. The value of the row locator depends on whether the data pages are stored in a heap or are clustered. For a nonclustered index, the row locator is a pointer to the data row. For a table with a clustered index, the row locator is the clustered index key value.</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is Covering Index ?</strong></span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A <i>covering index</i> is a nonclustered index built upon all the columns required to satisfy a SQL query without going to the base table. If a query encounters an index and does not need to refer to the underlying data table at all, then the index can be considered a covering index. For Example</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Select col1,col2 from table<br />where col3 = Value<br />group by col4<br />order by col5</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Now if you create a clustered index for all the columns used in Select statement then the SQL doesn’t need to go to base tables as everything required are available in index pages.</span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> What is Indexed View ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A database view in SQL Server is like a virtual table that represents the output of a SELECT statement. A view is created using the CREATE VIEW statement, and it can be queried exactly like a table. In general, a view doesn’t store any data—only the SELECT statement associated with it. Every time a view is queried, it further queries the underlying tables by executing its associated SELECT statement.</span></span></div><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A database view can be materialized on the disk by creating a unique clustered index on the view. Such a view is referred to as an <i>indexed view</i>. After a unique clustered index is created on the view, the view’s result set is materialized immediately and persisted in physical storage in the database, saving the overhead of performing costly operations during query execution. After the view is materialized, multiple nonclustered indexes can be created on the indexed view.</span></span></div><div><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>What is Bookmark Lookup ?</strong></span></span></li></ul><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">When a SQL query requests a small number of rows, the optimizer can use the nonclustered index, if available, on the column(s) in the WHERE clause to retrieve the data. If the query refers to columns that are not part of the nonclustered index used to retrieve the data, then navigation is required from the index row to the corresponding data row in the table to access these columns.This operation is called a bookmark lookup.</span></span></div></div></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com1tag:blogger.com,1999:blog-8919760615697611468.post-78102091846909736002013-11-09T06:04:00.000-08:002014-02-15T07:41:34.328-08:00SSRS Interview Questions and Answers<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong> <span style="color: blue;">1). What is Query parameter in SSRS?</span></strong><br />Query parameters is mentioned in the query of the datasources that are to be included into the SQL script’s WHERE clause of the SQL that can accept parameters. Query parameters begin with the symbol @.The name should not contain spaces and can not begin with numeral. For clarity, we use only letters.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>2). What are the Reporting Service Components in SSRS?</strong></span><br />Report Designer: A place where we can create report. Report Server: Provides services for implementation and delivery of reports. Report Manager: A Web-based administration tool for managing the Report Server.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>3). What is a matrix in SSRS?</strong></span><br />A matrix is a data region linked to a report set. Matrix allows us to create crosstab reports with the report variables displaying on rows and columns. It allows us to drag and drop fields into it.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>4). What are sub reports and how to create them?</strong></span><br />A sub report is like any other reports which can be called in main report and can be generate<br />through main report. Parameters can be passed from main report to sub report and basis of<br />that report can be generated.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>5). What is the report model project?</strong></span><br />Report model project is for creating Adhoc reporting. You can create the adhoc reports<br />through report builder. Report model project can be created on bids or report server. This<br />model can have simple view. And using</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>6). What is report server project?</strong></span><br />Report Server Project contains the RDL file and it need to be deployed on report server to<br />view the report files to application and user.<br />It a solution where we design our reports. You can add it by going into BIDS clicking on<br />new item and then selecting reports server project. Once the solution is created you can start<br />creating reports.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>7). What is the report builder?</strong></span><br />Report builder is used to create small reports and it a define interface. You can’t change the<br />report interface in report builder it pre designed. You can just drag columns in the report.<br />Report builder creates reports on database objects available with report model project.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>8). In which SQL Server version report builder introduced?</strong></span><br />Report builder introduced in SQL Server 2005. While creating or deploying report model<br />project on report server you can get error or it might not get created. For this you need to<br />check whether the service pack 22 is installed or not.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>9). How to deploy the Report?</strong></span><br />Report can be deployed in three ways.<br />1. Using visual studio: In visual studio you can directly deploy the report through<br />solution explorer by providing the report server URL in project properties at Target<br />Server URL. This will deploy entire project or single report as per you selection.<br />2. Using report server: Can directly go to the report server and deploy the report by<br />browsing the report from the disk location on server.<br />3. Creating the utility: SQL server provides the utility using that which can be used to<br />create a customize utility for your report deployment in bulk.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>10). What is RS.exe utility?</strong></span><br />Rs.exe utility is used for deploying the report on report server. It comes with the report<br />server and can be customize accordingly.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>11). What is the name of reporting services config file and what’s it’s used for?</strong></span><br />Reporting service config file is used for report configuration details. It contains the report<br />format and also the report import types. Report service config reside at ISS.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>12). What are the three different part of RDL file explain them?</strong></span><br />In visual studio RDL files has three parts.<br />1. Data: It contains the dataset on which we write the query. Data set is connected with<br />data source.<br />2. Design: In design you can design report. Can create tables and matrix reports. Drag<br />columns values from source.<br />3. Preview: to check the preview after the report run.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>13). Which language rdl files made of?</strong></span><br />RDL files are written in XML.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>14). What is the chart in report?</strong></span><br />Chart reports are for graphical representation. You can get pie charts columns harts and<br />various other options.<br />3d charts are also available in reporting services.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>15). What is Data Set in report?</strong></span><br />Data set are the set of data which we want to show in report. Data creates on data source.<br />Data source is the source of data from where we are getting this data i.e. database server and<br />database name connection string.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>16). What are the different types of data sources in SSRS?</strong></span><br />SSRS use different data source. Some of them are listed below.<br />1. Microsoft SQL Server<br />2. OLEDB<br />3. Oracle<br />4. ODBC<br />5. SQL Server Analysis Service<br />6. Report Server Model<br />7. SAP Net weaver BI<br />8. Hyperion<br />9. Teradata<br />10. XML</span></span><br /><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>17). What is the web service used for reporting services?</strong></span><br />Reporting Service Web Service used in SSRS. By accessing this web service you can access all<br />report server component and also get the report deployed on report server.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>18). How to add the custom code in Report?</strong></span><br />To add the custom codes in report go to report tab on top then properties and there you will<br />find the options for custom code.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>19). What is a cache in SSRS?</strong></span><br />Report server can lay up a copy of processed report in a memory and return the copy when a user opens the report. This server memory is known as cache and the process is called caching.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>20). What is report snapshot in SSRS?</strong></span><br />Report snapshot is a report which contains layout information and a dataset that is extracted at a particular point of time. When the new snapshot is created the previous report snapshot will be overwritten.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>21). What is bookmark link in SSRS?</strong></span><br />Bookmark is a link which a person clicks to shift to a different area or page in a report. We can insert bookmarks links only to textboxes and images.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>22). What is Command parameter in SSRS?</strong></span><br />A Command parameter is used to forward protocol to the Report Server regarding the item that has been retrieved. Command parameter is also used for rearranging a user’s session information.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>23). What is Format parameter in SSRS?</strong></span><br />Format parameter is used to control report output. Every delivering format on Report Server has to pass through this parameter.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>24). What is Snapshot parameter in SSRS?</strong></span><br />When a report is saved in a snapshot history, it is allocated a time or date to uniquely identify that report. Snapshot parameter is used to get back these historical reports by passing this time or date to get proper report.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>25). What are the rendering extensions of SSRS?</strong></span><br />Rendering extensions manage the category of document produced when a report is processed. Rendering Extensions are: HTML, MHTML, EXCEL, CSV, IMAGE, PDF, and XML.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>26). What is a ReportItem in SSRS?</strong></span><br />A ReportItem is one of the subsequent types of items: Rectangle, Textbox, Image, Subreport, Line, CustomReportItem, List, Table, Matrix or Chart.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>27). What is Datasets in SSRS?</strong></span><br />Dataset elements have information about the sets of data recovered as a part of the report.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>28). What are the main components of reporting services?</strong></span><br />The main components of Reporting Services are</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Report designer</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Report server</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Report manager</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Report user.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>29). What is Report Designer?</strong></span><br />Report Designer is a collection of graphical query and design tools that are hosted within the Microsoft Visual Studio environment.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Report Designer provides a Report Data pane to organize data used in your report, and tabbed views for Design and Preview so that you can design a report interactively.<br />Report Designer also provides query designers to help specify data to retrieve from data sources and the Expression dialog to specify report data to use in the report layout.<br />When the report is complete, you can use Report Designer to preview the report and publish it directly to the report server.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>30). What is Report manager?</strong></span><br />Report Manager is a Web-based report access and management tool that you use to administer a single report server instance from a remote location over an HTTP connection. You can also use Report Manager for its report viewer and navigation features.<br />You can use Report Manager to browse the report server folders or search for specific reports. You can view a report, its general properties, and past copies of the report that are captured in report history.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>31). What is Report Builder?</strong></span><br />Web-based tool to create reports<br />Come free with SQL Server 2005<br />Launch Report Builder 1.0 to create ad hoc reports that you can save and run on the report server.<br />Users build desired reports themselves; can export to Word, Excel, PDF, and more</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><strong>32). What is Report Server?</strong></span><br />The report server is the central component of a Reporting Services installation. It consists of a pair of core processors plus a collection of special-purpose extensions that handle authentication, data processing, rendering, and delivery operations.</span></span><br /><br /></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-10180362845378007892013-11-07T13:40:00.000-08:002014-02-15T07:41:34.338-08:00ASP.Net Interview Question and Answer for 2+ or 3+ years experience<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: #0b5394;"></span><span style="color: blue;"><b>1.) What is asp.net life cycle ?</b></span></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Life Cycle Events <br /><br /><b>PreInit</b><br /><br />The properties like IsPostBack have been set at this time.<br /><br />This event will be used when we want to:</span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Set master page dynamically.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Set theme dynamically.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Read or set profile property values.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This event is also preferred if want to create any dynamic controls.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Init</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Raised after all the controls have been initialized with their default values and any skin settings have been applied.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fired for individual controls first and then for page.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>LoadViewState</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fires only if IsPostBack is true.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Values stored in HiddenField with id as _ViewState decoded and stored into corresponding controls.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>LoadPostData</b><br /><br />Some controls like:<br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="letter-spacing: 0.75pt;">Fires only if IsPostBack is true.</span></span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Some controls like Textbox are implemented from IPostBackDataHandler and this fires only for such controls.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In this event page processes postback data included in the request object pass it to the respective controls.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>PreLoad</b><br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Used only if want to inject logic before actual page load starts.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Load</b><br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Used normally to perform tasks which are common to all requests, such as setting up a database query.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Control events</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This event is fired when IsPostBack is true.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>PreRender</b>Raised after the page object has created all the controls that are required for rendering which includes child controls and composite controls.<br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Use the event to make final changes to the contents of the page or its controls before the values are stored into the viewstate and the rendering stage begins.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Mainly used when we want to inject custom JavaScript logic.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>SaveViewState</b><br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">All the control values that support viewstate are encoded and stored into the viewstate.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Render</b>Generates output (HTML) to be rendered at the client side.<br /></span></span><br /><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We can add custom HTML to the output if we want here.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Unload</b><br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Fired for individual controls first and then for page.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> 2. Used to perform cleanup work like closing open files and database connections. </span></span><br /><br /><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><b>2.) How the request is handled by IIS ?</b></span><br /><br />We give an URL to an aspx page in the browser address bar and press enter. What happens next? We get the response in terms of rendered HTML but how?<br /></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">We are requesting something from the browser, which means indirectly we are requesting something from the Web Server, that means IIS. IIS, based on the file extension, decides which ISAPI extension can serve the request.<br /><br />And in case of ASP.Net (.aspx) it will be aspnet_isapi_dll so the request is passed to it for processing.<br /> </span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">When the first request comes to the website,<br /><br />an application domain is created by the ApplicationManager class where exactly the website runs, and which creates an isolation between 2 web applications.<br />Within the application domain an instance of the HostingEnvironment class is created which provides access information about the application such as the name of the folder where the application is stored.<br /> </span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Next ASP.Net creates core objects like HttpContext, HttpRequest,HttpResponse.<br /> </span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Finally the application starts by creating an instance of the HttpApplication Class (which can be reused for multiple requests to maximize performance).</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><b>3.) What is Difference between Session and Cookies ? </b></span><br /><br />The basic and main difference between cookie and session is that cookies are stored in the user's browser but sessions can't store in user's browser. This specifies which is best used for. <br /><br />• A cookie can keep all the information in the client's browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie. <br /><br />• Sessions are not reliant on the user allowing a cookie. They work like a token in the browser which allowing access and passing information while the user has opened his browser. The problem in sessions is when you close the browser the session will automatically lost. So, if you had a site requiring a login, this couldn't be saved as a session but it can be saved as a cookie, and the user has to re-login every time they visit.<br />cookies are nothing but a small piece of information on the client machine. before we create a cookies we should check whether the cookies are allowed at the browser side. They are limited in a size 4k.(they are 2 types of cookies peristant cookie , and session cookies) <br /><br />Sessions cookies are stored in a server memory during the client browser session.When the browser is closed the session cookies are lost. </span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="color: blue;"><br /></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><b>4.) Advantages and disadvantages of Session?</b></span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><b> </b></span><br />Following are the basic advantages and disadvantages of using session. I have describe in details with each type of session at later point of time.<br /></span></span><br /><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Advantages:</span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It helps maintain user state and data all over the application.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It is easy to implement and we can store any kind of object.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Stores client data separately.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Session is secure and transparent from the user.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Disadvantages:</span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ul><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Performance overhead in case of large volumes of data/user, because session data is stored in server memory.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Overhead involved in serializing and de-serializing session data, because in the case of <code>StateServer</code> and <code>SQLServer</code> session modes, we need to serialize the objects before storing them.</span></span></li></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Besides these, there are many advantages and disadvantages of session that are based on the session type. I have discussed all of them in the respective sections below.</span></span><br /><br /><br /><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><span style="font-weight: bold;">5). What is state management?</span></span><br />Ans: <span class="IL_AD" id="IL_AD1">State management</span> is the process by which you maintain state and page information over multiple requests for the same or different pages. <br /><br /><span style="color: blue;"><span style="font-weight: bold;">6). Http is stateless, What does this mean?</span></span><br />Ans: Stateless protocol is a <span class="IL_AD" id="IL_AD4">communications protocol</span> that treats each request as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of requests and responses.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">7). What is Session?</span></span><br />Ans: We know that Http is stateless, means when we open a webpage and fill some information and then move to next page then the data which we have entered will lost.<br />It happed do to Http protocol stateless nature. So here session come into existence, Session provide us the way of storing data in server memory. So you can store your page data into server<br />memory and retrieve it back during page postbacks.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">8). What are the Advantage and disadvantage of Session?</span></span><br />Ans: Advantages:<br />Session provide us the way of maintain user state/data.<br />It is very easy to implement.<br />One big advantage of session is that we can store any kind of object in it. :eg, datatabe, dataset.. etc<br />By using session we don't need to worry about data collesp, because it store every client data separately.<br />Session is secure and transparent from the user.<br />Disadvantages:<br />Performance overhead in case of large volumes of data/user, because session data is stored in server memory.<br />Overhead involved in serializing and de-serializing session data, because in the case of StateServer and SQLServer session modes, we need to serialize the objects before storing them.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">9). What is Session ID in Asp.net?</span></span><br />Ans: Asp.Net use 120 bit identifier to track each session. This is secure enough and can't be reverse engineered. When client communicate with server, only session id is transmitted, between them. When client request for data, ASP.NET looks on to session ID and retrieves corresponding data.<br /><span style="color: blue;"><br /><span style="font-weight: bold;">10). By default where the sessions ID's are stored ?</span></span><br />Ans: By default, the unique identifier for a session is stored in a non-expiring session cookie in the browser. You can specify that session identifiers not be stored in a cookie by setting the cookieless attribute to true in the sessionState configuration element.<br />We can also configure our application to store it in the url by specifying a "cookieless" session<br />The ASP Session cookie has this format:-<br />ASPSESSIONIDACSSDCCC=APHELKLDMNKNIOJONJACDHFN<br /><br /><br /><span style="color: blue;"><span style="font-weight: bold;">11). Where does session stored if cookie is disabled on client’s machine?</span></span><br />Ans: If you want to disable the use of cookies in your ASP.NET application and still make use of session state, you can configure your application to store the session identifier in the URL instead of a cookie by setting the cookieless attribute of the sessionState configuration element to true, or to UseUri, in the Web.<span class="IL_AD" id="IL_AD2">config file</span> for your application.<br />The following code example shows a Web.config file that configures session state to use cookieless session identifiers.<br /><br /></span></span><br /><div class="codeblock"><div class="title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Code:</span></span></div><div class="body" dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: #38761d;"><span style="background-color: white;"><code><configuration><br /> <system.web><br /> <sessionState <br /> cookieless="true"<br /> regenerateExpiredSessionId="true"<br /> timeout="30" /><br /> </system.web><br /></configuration></code></span></span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="background-color: white;"></span><br /><span style="color: blue;"><span style="font-weight: bold;">12). Can you describe all the property set in web.config under session state?</span></span><br />Ans: <br /></span></span><br /><div class="codeblock"><div class="title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Code:</span></span></div><div class="body" dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: #6fa8dc;"><code><span style="color: #38761d;"><configuration><br /> <sessionstate <br /> mode="inproc"<br /> cookieless="false" <br /> timeout="20" <br /> sqlconnectionstring="data source=127.0.0.1;<span class="IL_AD" id="IL_AD3">user id</span>=<user id>;password=<password>"<br /> server="127.0.0.1" <br /> port="42424" <br /> /></span><br /><span style="color: #38761d;"></configuration></span></code></span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Mode: The mode setting supports three options: inproc, sqlserver, and stateserver. As stated earlier, ASP.NET supports two modes: in process and out of process. There are also two options for out-of-process state management: memory based (stateserver), and SQL Server based (sqlserver). We'll discuss implementing these options shortly.<br />Cookieless: The cookieless option for ASP.NET is configured with this simple Boolean setting.<br />Timeout: This option controls the length of time a session is considered valid. The session timeout is a sliding value; on each request the timeout period is set to the current time plus the timeout value<br />Sqlconnectionstring: The sqlconnectionstring identifies the database connection string that names the database used for mode sqlserver.<br />Server: In the out-of-process mode stateserver, it names the server that is running the required Windows NT service: ASPState.<br />Port: The port setting, which accompanies the server setting, identifies the port number that corresponds to the server setting for mode stateserver.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">13). What are Session Events?</span></span><br />Ans: There are two types of session events available in ASP.NET:<br />Session_Start<br />Session_End<br />You can handle both these events in the global.asax file of your web application. When a new session initiates, the session_start event is raised, and the Session_End event raised when a session is abandoned or expires.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">14). How you can disable session?</span></span><br />Ans: If we set session Mode="off" in web.config, session will be disabled in the application. For this, we need to configure web.config the following way:<br /></span></span><br /><div class="codeblock"><div class="title"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Code:</span></span></div><div class="body" dir="ltr"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><code><configuration><br /> <sessionstate Mode="off"/><br /></configuration></code></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span></div><br /><br /><div id="font"><span style="font-weight: bold;"> <span style="color: blue;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="background-color: white;">15). If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) in my application?</span></span></span></span></span><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="color: blue;"><span style="background-color: #0b5394;"></span></span><br /><span style="background-color: #0b5394;"><br /></span> Ans.The version number is stored in the following format: …. The assembly manifest can then contain a reference to which version number we want to use.<br /><br /><span style="font-weight: bold;"> <span style="color: blue;">16). How do you create threading in.NET? What is the namespace for that?</span></span><br />Ans.<br />System.Threading;<br /><br />//create <span class="IL_AD" id="IL_AD4">new thread</span> using the thread class’s constructor<br /><br />Thread myThread = new Thread(new ThreadStart (someFunction));<br /><br /><span style="color: blue;"><span style="font-weight: bold;">17). What do you mean by Serialize and MarshalByRef?</span></span><br /><br />Serialization is the act of saving the state of an object so that it can be recreated (i.e deserialized) at a later date.<br />The MarshalByRef class is part of the System.Runtime.Remoting namespace and enables us to access and use objects that reside in different application <br />domains. It is the base class for objects that need to communicate across application domains. MarshalByRef objects are accessed directly within their own <br />application domain by using a proxy to communicate. With MarshalByValue the a copy of the entire object is passed across <span class="IL_AD" id="IL_AD3">the application</span> domain<br /><br /> <span style="color: blue;">18). <span style="font-weight: bold;">What is the difference between Array and LinkedList?</span></span><br />An array is a collection of the same type. The size of the array is fixed in its <span class="IL_AD" id="IL_AD2">declaration</span>.<br />A linked list is similar to an array but it doesn’t have a limited size.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">19). What is Asynchronous call and how it can be implemented using delegates?</span></span><br /><br />A synchronous call will wait for a method to complete before program flow is resumed. With an asynchronous call the program flow continues whilst the method executes.<br /><br />//create object<br />SomeFunction objFunc = new SomeFunction();<br /><br />//create delegate<br />SomeDelegate objDel = new SomeDelegate(objFunc.FunctionA);<br /><br />//invoke the method asynchronously (use interface IAsyncResult)<br />IAsyncResult asynchCall = SomeDelegate.Invoke();<br /><br /><span style="color: blue;"><b> 20). How to create events for a control? What is custom events? How to create it?</b></span><br />Ans.<br />An event is a mechanism used in a class that can be used to provide a notification when something interesting happens. (typical evens in a windows application <br />include: change text in textbox, double click or click a button, select an item in dropdown box). <br />A custom event is an event created by the user that other developers can use. For example assuming that we have a CashTransaction class and we have a bank <br />balance property in that class. We may want to set-up an event that provides a notification when the bank balance drops below a certain amount. In order to <br />produce an event the process would be roughly as follows: <br />Create the class for the event derived from EventArgs.<br />Create a delegate with a return type of void.<br />Create a class containing the method that will activate the event.<br />Create a class with methods to handle the event.<br /><br /><span style="color: blue;"><b> 21). If you want to write your own dot net language, what steps you will you take care?</b></span><br /><br />We will need to ensure that the high level code is compiled to MSIL (Microsoft intermediate language) so that it can be interpreted by the CLR.<br /><br /><span style="font-weight: bold;"> <span style="color: blue;">22). Describe the diffeerence between inline and code behind - which is best in a loosely coupled solution?</span></span><span style="color: blue;"><br /></span><span style="color: #0b5394;"></span><br />The term ‘code behind’ refers to application code that is not embedded within the ASPX page and is separated out into a separate file which is then referenced <br />from the ASPX page. Inline code is the traditional ASP architectural model where business logic code was embedded within the ASP page. Separating <span class="IL_AD" id="IL_AD1">the business</span> <br />logic code from the presentation layer offers several advantages: <br />1) It allows graphic designers and web developers to work on the presentation layer whilst the application developers concentrate on the business logic.<br />2) The codebehind file is compiled as a single dll increasing the efficiency of the application,<br />3) The codebehind model offers a true OO development platform,<br />4) It speeds up development time as it allows developers to fully maximise the features of the .NET framework such as Cahing, ViewState, Session, Smart Navigation etc.<br />5) Code is much easier to maintain and susceptible for change.<br />6) The compiler and VS.NET provides much better support for error checking, intellisense and debugging when using the code behind model.<br /><br /><span style="color: blue;"><span style="font-weight: bold;">23). How dot net compiled code will become platform independent?</span></span><br /><span style="color: #0b5394;"></span><br />The raison d’etre for .NET was to cater for multiples languages on a single windows platform whereas the aim of Java was to be a single language on multiple <br />platforms. The only way that .NET can be platform independent is if there is a version of the .NET framework installed on the target machine.<br /><span style="color: blue;"><b><br /> 24). Without modifying source code if we compile again, will it be generated MSIL again?<br /></b></span><br /><span style="color: #0b5394;">Ans.</span>No.<br /><span style="color: blue;"><span style="font-weight: bold;"><br />25). How does you handle this COM components developed in other programming languages in.NET?</span></span><br /><br /><span style="color: #0b5394;">Ans.</span><br />use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use System.Runtime.InteropServices<br />use RegAsm.exe to call a .NET developed component in a COM application.<br /><br /><span style="color: blue;"><b> 26). How CCW (Com Callable Wrapper) and RCW (Runtime Callable Wrappers) works?</b></span><br /><span style="color: #0b5394;"></span><br />CCW: When a COM application calls a NET object the CLR creates the CCW as a proxy since the COM application is unable to directly access the .NET object.<br />RCW: When a .NET application calls a COM object the CLR creates the RCW as a proxy since the .NET application is unable to directly access the .COM object.<br /><br /><b><span style="color: blue;"> 27). What are the new thee features of COM+ services, which are not there in COM (MTS)?</span></b><br /><span style="color: #0b5394;"></span><br />Role based security.<br />Neutral apartment threading.<br />New environment called context which defines the execution environment<br /><span style="color: blue;"><br /> <span style="font-weight: bold;">28). What are the differences between COM architecture and.NET architecture?</span></span><br /><span style="color: #0b5394;"></span><br />.Net architecture has superseded the old COM architecture providing a flexible rapid application development environment which can be used to create windows, <br />web and console applications and web services. .NET provides a powerful development environment that can be used to create objects in any .NET compliant language.<br />.NET addresses the previous problems of dll hell with COM by providing strongly named assemblies and side-by-side execution where two assemblies with the same name can run on the same box.<br /><b><span style="color: blue;"><br />29). Can we copy a COM dll to GAC folder?</span></b><br /><br /><span style="color: #0b5394;">Ans.</span><br />No. It only stores .NET assemblies.<br /><b><br /><span style="color: blue;">30). What is Shared and Repeatable Inheritance?</span></b><br /><span style="color: #0b5394;"></span><br />Shared Inheritance-: Shared Inheritance-: ITt is multiple times using same class. The mechanism of deriving a new class from an existing class is called inheritance. Shared inheritance introduces a new opportunity of ambiguity and additional implementation complexity. Assume D inherits from B and C, both of which inherits from A. Here A in shared. Single copy made from both derived classes is called shared inheritance.<br /><br /> <span style="color: blue;"><span style="font-weight: bold;">31). Can you explain what inheritance is and an example of when you might use it?</span></span><br /><span style="color: #0b5394;"><span style="font-weight: bold;"> </span><br /> Ans</span>.<br />Inheritance is a fundamental feature of any OO language. It allows us to inherit the members and attributes from a base class to a new derived class. This <br />leads to increased code reusability and also makes applications easier to develop, maintain and extend as the new derived class can contain new features not <br />available in the base class whilst at the same time preserving the attributes inherited from the base class.<br /><br /><span style="font-weight: bold;"><span style="color: blue;">32). How can you write a class to restrict that only one object of this class can be created (Singleton class)?</span></span><span style="color: #0b5394;"></span><br /><span style="color: #0b5394;"><br /> Ans.</span><br />Use the singleton design pattern.</span></span></div><div id="font"></div><div id="font"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> public sealed class Singleton <br /> { <br /> static readonly Singleton Instance=new Singleton(); <br /> static Singleton() <br /> { <br /> } <br /> Singleton() <br /> { <br /> } <br /> public static Singleton Instance <br /> { <br /> get <br /> { <br /> return Instance; <br /> } <br /> } <br /> } </span></span></div><div id="font"></div><div id="font"></div><div id="font"><span style="color: blue;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> </span></span></span><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><span style="color: blue;"><b>33). What are virtual destructures?</b></span><br /><br /><br />A constructor can not be virtual but a destructor may. Use virtual destructors when you want to implement polymorphic tearing down of an object.<br /><br /> <span style="color: blue;"><b>34). What is close method? How its different from Finalize and Dispose?</b></span><br /> <span style="color: #0b5394;"><span style="font-weight: bold;"></span></span><br />finalise is the process that allows the garbage collector to clean up any unmanaged resources before it is destroyed.<br />The finalise method can not be called directly; it is automatically called by the CLR. In order to allow more control over the release of unmanaged resources<br />the .NET framework provides a dispose method which unlike finalise can be called directly by code.<br />Close method is same as dispose. It was added as a convenience.<br /><span style="color: blue;"><br /><b> 35). What is Boxing and UnBoxing?</b></span><br /><br />Ans.<br />Boxing is the process of converting a value type to a reference type. More specifically it involves encapsulating a copy of the object and moving it from<br />stack to heap. Unboxing is the reverse process.<br /><span style="color: blue;"><b><br /> 36). What is check/uncheck?</b></span><br /><br />Ans.<br />checked: used to enable overflow checking for arithmetic and conversion functions.<br />unchecked: used to disable overflow checking for arithmetic and conversion functions <br /><br /> <b><span style="color: blue;">37). What is the use of base keyword? Tell me a practical example for base keyword’s usage?</span></b><br /><br />Ans.<br />The base keyword is used to access members of the base class from within a derived class:<br />* Call a method on the base class that has been overridden by another method.<br />* Specify which base-class constructor should be called when creating instances of the derived class.<br /><br />A base class access is permitted only in a constructor, an instance method, or an instance property accessor.<br />It is an error to use the base keyword from within a static method.<br />Example:In this example, both the base class, Person, and the derived class, Employee, have a method named Getinfo. By using the base keyword,<br />it is possible to call the Getinfo method on the base class, from within the derived class.<br />// keywords_base.cs<br />// Accessing base class members</span></span></div><div id="font"></div><div id="font"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br /><br /> using System; <br /> public class Person <br /> { <br /> protected string ssn = "444-55-6666"; <br /> protected string name = "John L. Malgraine"; <br /> public virtual void GetInfo() <br /> { <br /> Console.WriteLine("Name: {0}", name); <br /> Console.WriteLine("SSN: {0}", ssn); <br /> } <br /> } <br /> class Employee: Person <br /> { <br /> public string id = "ABC567EFG"; <br /> public override void GetInfo() <br /> { <br /> // Calling the base class GetInfo method: <br /> base.GetInfo(); <br /> Console.WriteLine("Employee ID: {0}", id); <br /> } <br /> } <br /> class TestClass { <br /> public static void Main() <br /> { <br /> Employee E = new Employee(); <br /> E.GetInfo(); <br /> } <br /> } <br /> </span></span></div><div id="font"><br /><h3 class="post-title entry-title" itemprop="name"><span style="color: blue;">38). Difference Between Query String and Session </span></h3><h3 class="post-title entry-title" itemprop="name"><span style="font-weight: normal;"> </span></h3><table border="1" cellspacing="0" class="Design4"><tbody><tr><th>Querystring </th> <th>Session </th> </tr><tr> <td><span class="IL_AD" id="IL_AD2">Querystring</span> is client side <span class="IL_AD" id="IL_AD2">state management</span> technique. </td> <td>Session is <span class="IL_AD" id="IL_AD1">server</span> side state management technique. </td> </tr><tr> <td>Querystring data is page specific i.e. can be <span class="IL_AD" id="IL_AD3">accessed</span> in that page only. </td> <td>Session data can be accessed throughout the session. </td> </tr><tr> <td>Querystring data is visible to user and can be seen in browser url. </td> <td>Session data is not visible to user. </td> </tr><tr> <td>Data is not secured and can be altered hence insensitive data is stored in querystring. </td> <td>Data is secured hence sensitive data such as <span class="IL_AD" id="IL_AD3">user information</span> is stored. </td> </tr><tr> <td>Querystring has constraint of Maxlength. </td> <td>Session does not have such constraint. </td></tr></tbody></table><h3 class="post-title entry-title" itemprop="name"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> </span></span></h3><h1 style="padding-bottom: 5px;"><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">39). Difference between Query string and Cookies</span></span></span></h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #0b5394;">cookies</span></b> is a <span class="IL_AD" id="IL_AD1">text file</span> stored on client machine when we surf ant thing on internet by the server automatically we dont have to create it <br /><br /><b><span style="color: #0b5394;">query string</span></b> is used to transfer data from 1 page to anothe but this is not safe s it shows in url what data we r sending <br />pen any site and see url after question mark tht is url<br /><br /><b><span style="color: #073763;">Cookies</span>: </b>- Cookies are little pieces of information that a server stores on a browser. They are of two types <br />1. Temporary cookie <br />2. Persistent cookie <br /><br />Temporary cookie: - They are also known as session cookies. These are volatile in nature. When the browser is shutdown they are erased. <br /><br />Persistent cookie:- These may be called as permanent cookies. These are especially saved in files. It may remain for a month or year. </span></span></div><div id="font"></div><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #073763;">Properties of cookies </span></b><br />Some properties of cookie <br />Name: - represent the name of cookie. <br />Name value: - represent a collection of key values of cookie <br />Domain: - represent the domain associated with a specific cookie. <br />Path: - the path associated with a cookie. <br />Expires: - expired time of cookie. <br />Hashkey: - identifies whether the cookie is a cookie dictionary. <br />Secure: - specifies whether the cookie is to be sent in an encrypted connection or not<br /><b><span style="color: #073763;">Query string</span></b> is the limited way to pass information to the web server while Transferring from one page to another page. This information is passed in url of the request. see below the code sample <br /><br /><br />Code Sample <br /><br />//Retrieving values from <span class="IL_AD" id="IL_AD4">query string</span> <br />String name; <br />//Retrieving from query string <br />name = Request.Param["umar"].ToString(); <br /><br />But remember that many browsers impose a limit of 255 characters in query strings. You need to use HTTP-Get method to post a page to server otherwise query string values will not be available. </span></span></div><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br /><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: #0b5394;">40).<span style="color: blue;"> How can we identify that the Page is Post Back?</span></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">41). What is the lifespan for items stored in ViewState?</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> PThe items stored in ViewState live until the lifetime of the current page expires including the postbacks to the same page</span></span></div><div id="font"></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">42). What is AutoPostBack?</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> If you want a control to postback automatically when an event is raised, you need to set the AutoPostBack property of the control to True</span></span></div><div id="font"></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">43). Why do you use the App_Code folder in ASP.NET?</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The App_Code folder is automatically present in the project. It stores the files, such as classes, typed data set, text files, and reports. If this folder is not available in the application, you can add this folder. One of the important features of the App_Code folder is that only one dll is created for the complete folder, irrespective of how many files it contains.</span></span></div><div id="font"></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>44). In which event of page cycle is the ViewState available?</b></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br />After the Init() and before the Page_Load().</span></span></div><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>45). How long the items in ViewState exists?</b></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">They exist for the life of the current page.<br /><br /></span></span><br /><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>46). Where the viewstate is stored after the page postback?</b></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br />ViewState is stored in a hidden field on the page at client side. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.<br /><br /></span></span><br /><h3> <span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>47). What are the different Session state management options available in ASP.NET?</strong></span></span></span><br /></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><br /><ol><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In-Process</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Out-of-Process.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>In-Process</strong> stores the session in memory on the web server.</span></span></div><div id="font"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><strong>Out-of-Process</strong> Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management. </span></span></div></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>48). What is the difference between web config and machine config?</strong></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Web config file is specific to a web application where as machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.</span></span></div><div id="font"></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>49). What are the different types of cookies in ASP.NET?</strong></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>Session Cookie</strong> – Resides on the client machine for a single session until the user does not log out.<br /><strong>Persistent Cookie</strong> – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never.</span><span style="font-family: Verdana,sans-serif;"> </span></span></div><div id="font"></div><div id="font"><h3><span style="color: blue;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><strong>50). What is the difference between ExecuteScalar and ExecuteNonQuery?</strong></span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">ExecuteScalar returns output value where as ExecuteNonQuery does not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.</span><span style="font-family: Verdana,sans-serif;"> </span></span></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"></div><div id="font"><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span><span style="font-family: Verdana,sans-serif;"> </span></span><br /><h3 class="post-title entry-title" itemprop="name"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> </span></span></h3></div><div id="font"><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> </span></span><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><code style="color: black; word-wrap: normal;"></code></span></span><span style="font-family: Verdana,sans-serif;"><span style="font-size: small;"></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-62956025386311613102013-10-12T02:09:00.000-07:002014-02-15T07:41:34.350-08:00Difference between CTE and Temp Table and Table Variable<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Temp Table or Table variable or CTE are commonly used for storing data temporarily in SQL Server. In this article, you will learn the differences among these three. </span></span><br /><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">CTE</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">CTE stands for Common Table expressions. It was introduced with SQL Server 2005. It is a temporary result set and typically it may be a result of complex sub-query. Unlike temporary table its life is limited to the current query. It is defined by using WITH statement. CTE improves readability and ease in maintenance of complex queries and sub-queries. Always begin CTE with semicolon.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">A sub query without CTE is given below :</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><pre class="prettyprint lang-sql linenums" style="text-align: left;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">SELECT</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">FROM</span><span class="pln"> </span><span class="pun">(</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">SELECT</span><span class="pln"> Addr</span><span class="pun">.</span><span class="pln">Address</span><span class="pun">,</span><span class="pln"> Emp</span><span class="pun">.</span><span class="pln">Name</span><span class="pun">,</span><span class="pln"> Emp</span><span class="pun">.</span><span class="pln">Age </span><span class="kwd">From</span><span class="pln"> Address Addr</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">Inner</span><span class="pln"> </span><span class="kwd">join</span><span class="pln"> Employee Emp </span><span class="kwd">on</span><span class="pln"> Emp</span><span class="pun">.</span><span class="pln">EID </span><span class="pun">=</span><span class="pln"> Addr</span><span class="pun">.</span><span class="pln">EID</span><span class="pun">)</span><span class="pln"> Temp</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">WHERE</span><span class="pln"> Temp</span><span class="pun">.</span><span class="pln">Age </span><span class="pun">></span><span class="pln"> </span><span class="lit">50</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">ORDER</span><span class="pln"> </span><span class="kwd">BY</span><span class="pln"> Temp</span><span class="pun">.</span><span class="pln">NAME</span></span></span></pre><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">By using CTE above query can be re-written as follows :</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">;</span><span class="kwd">With</span><span class="pln"> CTE1</span><span class="pun">(</span><span class="pln">Address</span><span class="pun">,</span><span class="pln"> Name</span><span class="pun">,</span><span class="pln"> Age</span><span class="pun">)</span><span class="com">--Column names for CTE, which are optional</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">AS</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">(</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">SELECT</span><span class="pln"> Addr</span><span class="pun">.</span><span class="pln">Address</span><span class="pun">,</span><span class="pln"> Emp</span><span class="pun">.</span><span class="pln">Name</span><span class="pun">,</span><span class="pln"> Emp</span><span class="pun">.</span><span class="pln">Age </span><span class="kwd">from</span><span class="pln"> Address Addr</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">INNER</span><span class="pln"> </span><span class="kwd">JOIN</span><span class="pln"> EMP Emp </span><span class="kwd">ON</span><span class="pln"> Emp</span><span class="pun">.</span><span class="pln">EID </span><span class="pun">=</span><span class="pln"> Addr</span><span class="pun">.</span><span class="pln">EID</span></span></span></pre><pre class="prettyprint lang-sql linenums" style="text-align: left;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">)</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">SELECT</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">FROM</span><span class="pln"> CTE1 </span><span class="com">--Using CTE </span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">WHERE</span><span class="pln"> CTE1</span><span class="pun">.</span><span class="pln">Age </span><span class="pun">></span><span class="pln"> </span><span class="lit">50</span></span></span></pre><pre class="prettyprint lang-sql linenums" style="text-align: left;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">ORDER</span><span class="pln"> </span><span class="kwd">BY</span><span class="pln"> CTE1</span><span class="pun">.</span><span class="pln">NAME</span></span></span></pre><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">When to use CTE</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol class="orderlist"><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This is used to store result of a complex sub query for further use.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This is also used to create a recursive query.</span></span></li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Temporary Tables</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">In SQL Server, temporary tables are created at run-time and you can do all the operations which you can do on a normal table. These tables are created inside Tempdb database. Based on the scope and behavior temporary tables are of two types as given below-</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol class="orderlist" style="text-align: left;"><li><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Local Temp Table</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Local temp tables are only available to the SQL Server session or connection (means single user) that created the tables. These are automatically deleted when the session that created the tables has been closed. Local temporary table name is stared with single hash ("#") sign.</span></span><br /> <pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">CREATE</span><span class="pln"> </span><span class="kwd">TABLE</span><span class="pln"> </span><span class="pun">#</span><span class="pln">LocalTemp</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">(</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> UserID int</span><span class="pun">,</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> Name varchar</span><span class="pun">(</span><span class="lit">50</span><span class="pun">),</span><span class="pln"> </span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> Address varchar</span><span class="pun">(</span><span class="lit">150</span><span class="pun">)</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">)</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln">GO</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">insert</span><span class="pln"> </span><span class="kwd">into</span><span class="pln"> </span><span class="pun">#</span><span class="pln">LocalTemp </span><span class="kwd">values</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Shailendra'</span><span class="pun">,</span><span class="str">'Noida'</span><span class="pun">);</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln">GO</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">Select</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">from</span><span class="pln"> </span><span class="pun">#</span><span class="pln">LocalTemp</span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span></span></span></pre><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img class="img" contextmenu="return false;" src="http://www.dotnet-tricks.com/Content/images/sqlserver/cte.png" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">The scope of Local temp table exist to the current session of current user means to the current query window. If you will close the current query window or open a new query window and will try to find above created temp table, it will give you the error.</span></span><br /> </li><li><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Global Temp Table</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Global temp tables are available to all SQL Server sessions or connections (means all the user). These can be created by any SQL Server connection user and these are automatically deleted when all the SQL Server connections have been closed. Global temporary table name is stared with double hash ("##") sign.</span></span><br /> <pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">CREATE</span><span class="pln"> </span><span class="kwd">TABLE</span><span class="pln"> </span><span class="pun">##</span><span class="pln">GlobalTemp</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">(</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> UserID int</span><span class="pun">,</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> Name varchar</span><span class="pun">(</span><span class="lit">50</span><span class="pun">),</span><span class="pln"> </span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> Address varchar</span><span class="pun">(</span><span class="lit">150</span><span class="pun">)</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pun">)</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln">GO</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">insert</span><span class="pln"> </span><span class="kwd">into</span><span class="pln"> </span><span class="pun">##</span><span class="pln">GlobalTemp </span><span class="kwd">values</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Shailendra'</span><span class="pun">,</span><span class="str">'Noida'</span><span class="pun">);</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln">GO</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="kwd">Select</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">from</span><span class="pln"> </span><span class="pun">##</span><span class="pln">GlobalTemp</span></span></span></pre><div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img class="img" contextmenu="return false;" src="http://www.dotnet-tricks.com/Content/images/sqlserver/cte.png" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Global temporary tables are visible to all SQL Server connections while Local temporary tables are visible to only current SQL Server connection.</span></span><br /> </li></ol><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Table Variable</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">This acts like a variable and exists for a particular batch of query execution. It gets dropped once it comes out of batch. This is also created in the Tempdb database but not the memory. This also allows you to create primary key, identity at the time of Table variable declaration but not non-clustered index.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><pre class="prettyprint lang-sql linenums" style="text-align: left;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> GO</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">DECLARE</span><span class="pln"> </span><span class="pun">@</span><span class="pln">TProduct </span><span class="kwd">TABLE</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="pun">(</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> SNo INT </span><span class="kwd">IDENTITY</span><span class="pun">(</span><span class="lit">1</span><span class="pun">,</span><span class="lit">1</span><span class="pun">),</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> ProductID INT</span><span class="pun">,</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> Qty INT</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span></span></span></pre><pre class="prettyprint lang-sql linenums"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="com">--Insert data to Table variable @Product </span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">INSERT</span><span class="pln"> </span><span class="kwd">INTO</span><span class="pln"> </span><span class="pun">@</span><span class="pln">TProduct</span><span class="pun">(</span><span class="pln">ProductID</span><span class="pun">,</span><span class="pln">Qty</span><span class="pun">)</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">SELECT</span><span class="pln"> </span><span class="kwd">DISTINCT</span><span class="pln"> ProductID</span><span class="pun">,</span><span class="pln"> Qty </span><span class="kwd">FROM</span><span class="pln"> ProductsSales </span><span class="kwd">ORDER</span><span class="pln"> </span><span class="kwd">BY</span><span class="pln"> ProductID </span><span class="kwd">ASC</span><span class="pln"> </span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="com">--Select data</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">Select</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">from</span><span class="pln"> </span><span class="pun">@</span><span class="pln">TProduct</span></span></span></pre><pre class="prettyprint lang-sql linenums" style="text-align: left;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="com">--Next batch</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> GO</span></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="pln"> </span><span class="kwd">Select</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="kwd">from</span><span class="pln"> </span><span class="pun">@</span><span class="pln">TProduct </span><span class="com">--gives error in next batch</span></span></span></pre><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Note</span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><ol class="notelist"><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Temp Tables are physically created in the Tempdb database. These tables act as the normal table and also can have constraints, index like normal tables.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">CTE is a named temporary result set which is used to manipulate the complex sub-queries data. This exists for the scope of statement. This is created in memory rather than Tempdb database. You cannot create any index on CTE.</span></span></li><li><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Table Variable acts like a variable and exists for a particular batch of query execution. It gets dropped once it comes out of batch. This is also created in the Tempdb database but not the memory.</span></span></li></ol></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-20511465429454785872013-09-24T19:41:00.000-07:002014-02-15T07:41:34.425-08:00LOG SHIPPING VS. MIRRORING VS. REPLICATION<div dir="ltr" style="text-align: left;" trbidi="on"><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong>Log Shipping::</strong></span></b></span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong></strong></span></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong></strong></span></b><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It automatically sends transaction log backups from one database (Known as the primary database) to a database (Known as the Secondary database) on another server. An optional third server, known as the monitor server, records the history and status of backup and restore operations. The monitor server can raise alerts if these operations fail to occur as scheduled. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong><br /></strong></span></b></span></span><br /><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong>Mirroring::</strong></span></b></span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong></strong></span></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong></strong></span></b></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Database mirroring is a primarily software solution for increasing database availability.<br />It maintains two copies of a single database that must reside on different server instances of SQL Server Database Engine.<br /><b><span style="color: #8080ff;"><strong><br /></strong></span></b></span></span><br /><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong>Replication::</strong></span></b></span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong></strong></span></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;"><strong></strong></span></b></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">It is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency. Using replication, you can distribute data to different locations and to remote or mobile users over local and wide area networks, dial-up connections, wireless connections, and the Internet.<br /></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Components</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Primary server, secondary server and monitor server (Optional).<br /><u>Mirroring::</u>Principal server, mirror server, and witness server (Optional).<br /><u>Replication::</u>Publisher, Subscribers, Distributor (Optional).</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Data Transfer</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>T-Logs are backed up and transferred to secondary server.<br /><u>Mirroring::</u>Individual T-Log records are transferred using TCP endpoints.<br /><u>Replication::</u>Replication works by tracking/detecting changes (either by triggers or by scanning the log) and shipping the changes.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Server Limitation</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>It can be configured as One to Many. i.e one primary server and many secondary servers. Or<br />Secondary server can contain multiple Primary databases that are log shipped from multiple servers.<br /><u>Mirroring::</u>It is one to one. i.e. One principal server to one mirror server.<br /><u>Replication::</u></span></span><br /><ul><span style="font-family: Verdana,sans-serif;"><li>Central publisher/distributor, multiple subscribers.</li><li>Central Distributor, multiple publishers, multiple subscribers.</li><li>Central Distributer, multiple publishers, single subscriber.</li><li>Mixed Topology.</li></span></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Types Of Failover</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Manual.<br /><u>Mirroring::</u>Automatic or manual.<br /><u>Replication::</u>Manual.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">DB Access</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>You can use a secondary database for reporting purposes when the secondary database restore in STANDBY mode.<br /><u>Mirroring::</u>Mirrored DB can only be accessed using snapshot DB.<br /><u>Replication::</u>The Subscriber Database is open to reads and writes.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Recovery Model</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Log shipping supports both Bulk Logged Recovery Model and Full Recovery Model.<br /><u>Mirroring::</u>Mirroring supports only Full Recovery model.<br /><u>Replication::</u>It supports Full Recovery model.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Restoring State</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>The restore can be completed using either the NORECOVERY or STANDBY option.<br /><u>Mirroring::</u>The restore can be completed using with NORECOVERY.<br /><u>Replication::</u>The restore can be completed using With RECOVERY.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Backup/Restore</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>This can be done manually or<br />through Log Shipping options.<br /><u>Mirroring::</u>User make backup & Restore manually.<br /><u>Replication::</u>User create an empty database with the same name.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Monitor/<br />Distributer/ Witness<br /></span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>The monitor server should be on a server separate from the primary or secondary servers to avoid losing critical information and disrupting monitoring if the primary or secondary server is lost. . If a monitor server is not used, alert jobs are created locally on the primary server instance and each secondary server instance.<br /><u>Mirroring::</u>Principal server can’t act as both principal server and witness server.<br /><u>Replication::</u>Publisher can be also distributer.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Types Of Servers</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>All servers should be SQL Server.<br /><u>Mirroring::</u>All servers should be SQL Server.<br /><u>Replication::</u>Publisher can be ORACLE Server.</span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">SQL Server Agent Dependency/Jobs</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Yes. Log shipping involves four jobs, which are handled by dedicated SQL Server Agent jobs. These jobs include the backup job, copy job, restore job, and alert job.<br /><u>Mirroring::</u>Independent on SQL Server agent.<br /><u>Replication::</u>Yes. Snapshot agent, log reader agent & Distribution agent (transactional replication)<br />Merge agent (merge replication).<br /></span></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><div align="center"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Requirements</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u></span></span><br /><ul><span style="font-family: Verdana,sans-serif;"><li>The servers involved in log shipping should have the same logical design and collation setting. </li><li>The databases in a log shipping configuration must use the full recovery model or bulk-logged recovery model.</li><li>The SQL server agent should be configured to start up automatically.</li><li>You must have sysadmin privileges on each computer running SQL server to configure log shipping.</li></span></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Mirroring::</u><br /><ul><li>Verify that there are no differences in system collation settings between the principal and mirror servers.</li><li>Verify that the local windows groups and SQL Server logins definitions are the same on both servers.</li><li>Verify that external software components are installed on both the principal and the mirror servers.</li><li>Verify that the SQL Server software version is the same on both servers.</li><li>Verify that global assemblies are deployed on both the principal and mirror server.</li><li>Verify that for the certificates and keys used to access external resources, authentication and encryption match on the principal and mirror server.</li></ul><u>Replication::</u><br /><ul><li>Verify that there are no differences in system collation settings between the servers.</li><li>Verify that the local windows groups and SQL Server Login definitions are the same on both servers.</li><li>Verify that external software components are installed on both servers.</li><li>Verify that CLR assemblies deployed on the publisher are also deployed on the subscriber.</li><li>Verify that SQL agent jobs and alerts are present on the subscriber server, if these are required.</li><li>Verify that for the certificates and keys used to access external resources, authentication and encryption match on the publisher and subscriber server.</li></ul></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Using With Other Features Or Components</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Log shipping can be used with Database mirroring, Replication.<br /><u>Mirroring::</u>Database mirroring can be used with<br />Log shipping, Database snapshots , Replication.<br /><u>Replication::</u>Replication can be used with log shipping, database mirroring.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">DDL Operations</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>DDL changes are applied automatically.<br /><u>Mirroring::</u>DDL changes are applied automatically.<br /><u>Replication::</u>only DML changes to the tables you have published will be replicated.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Database Limit</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>No limit.<br /><u>Mirroring::</u>generally good to have 10 DB’s for one server.<br /><u>Replication::</u>No limit.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">latency</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>There will be data transfer latency. >1min.<br /><u>Mirroring::</u>There will not be data transfer latency.<br /><u>Replication::</u>Potentially as low as a few seconds.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Committed /<br />Uncommitted<br />Transactions<br /></span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Both committed and uncommitted transactions are transferred to the secondary database.<br /><u>Mirroring::</u>Only committed transactions are transferred to the mirror database.<br /><u>Replication::</u>Only committed transactions are transferred to the subscriber database.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Primary key</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Not required.<br /><u>Mirroring::</u>Not required.<br /><u>Replication::</u>All replicated table should have Primary Key.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">New Created Database&<br />Stored Procedure<br /></span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Monitoring and history information is stored in tables in msdb, which can be accessed using log shipping stored procedures.<br /><u>Replication::</u>Creates new SPs ( 3 Sps of one table).<br />Distribution Database.<br />Rowguid column will be created.<br /></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Individual Articles</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>No. Whole database must be selected.<br /><u>Mirroring::</u>No. Whole database must be selected.<br /><u>Replication::</u>Yes. Including tables, views, stored procedures, and other objects. Also filter can be used to restrict the columns and rows of the data sent to subscribers.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">FILESTREAM</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Log shipping supports FILESTREAM.<br /><u>Mirroring::</u>Mirroring does not support FILESTREAM.<br /><u>Replication::</u>Replication supports FILESTREAM.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">DB Name</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>The secondary database can be either the same name as primary database or it may be another name.<br /><u>Mirroring::</u>It must be the same name.<br /><u>Replication::</u>It must be the same name.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">DB Availability</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>In case of standby mode: read only database.<br />In case of restoring with no recovery: Restoring state.<br /><u>Mirroring::</u>In Recovery state, no user can make any operation.<br />You can take snapshot.<br /><u>Replication::</u>Snapshot (read-only).<br />Other types (Database are available).<br /></span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Warm/ Hot Standby Solution</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>It provides a warm standby solution that has multiple copies of a database and require a manual failover.<br /><u>Mirroring::</u>When a database mirroring session is synchronized, database mirroring provides a hot standby server that supports rapid failover without a loss of data from committed transactions. When the session is not synchronized, the mirror server is typically available as a warm standby server (with possible data loss).<br /><u>Replication::</u>It provides a warm standby solution that has multiple copies of a database and require a manual failover. </span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">System Data Transferred</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u>Mostly.<br /><u>Mirroring::</u>Yes.<br /><u>Replication::</u>No.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">System Databases</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Mirroring::</u>You cannot mirror the Master, msdb, tempdb, or model databases.</span><br /><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"></span></span><span style="font-family: Verdana,sans-serif;"><b></b></span><div align="center"><span style="font-family: Verdana,sans-serif;"><b><span style="color: #8080ff;">Mode Or Types</span></b></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b></b></span></span><span style="font-family: Verdana,sans-serif;"><br /></span><span style="font-family: Verdana,sans-serif;"><u>Log Shipping::</u></span><br /><ul><span style="font-family: Verdana,sans-serif;"><li>Standby mode (read-only)-you can disconnect users when restoring backups .</li><li>No recovery mode (restoring state)-user cannot access the secondary database.</li></span></ul><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><u>Mirroring::</u><br /><ul><li>high-safety mode supports synchronous operation.</li><li>high-performance mode, runs asynchronously.</li><li>High-safety mode with automatic failover.</li></ul><u>Replication::</u><br /><ul><li>Snapshot replication.</li><li>Transactional replication.</li><li>Transactional publication with updatable subscriptions.</li><li>Merge publication.</li><li>Pull/Push subscription.</li></ul></span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-43412974267172947852013-09-12T15:09:00.000-07:002014-02-15T07:41:34.499-08:00WCF Interview Question and Answer <div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>What is WCF? </b><br />Windows Communication Foundation or just WCF is a programming framework used to build applications that communicate with each other. It is a part of the .NET Framework dedicated to communications. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What are the different WCF binding available? </b><br />• BasicHttpBinding <br />• WSHttpBinding <br />• WSDualHttpBinding <br />• WSFederationHttpBinding <br />• NetTcpBinding <br />• NetNamedPipeBinding <br />• NetMsmqBinding <br />• NetPeerTcpBinding <br />• MsmqIntegrationBinding </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is the proxy for WCF Service? </b><br />A proxy is a class by which a service client can Interact with the service. By the use of proxy in the client application we are able to call the different methods exposed by the service. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is the difference between XMLSerializer and the DataContractSerializer? </b><br />1. DataContractSerializer is the default serializer fot the WCF <br />2. DataContractSerializer is very fast. <br />3. DataContractSerializer is basically for very small, simple subset of the XML infoset. <br />4. XMLSerializer is used for complex schemas </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is endpoint in WCF service? </b><br />The endpoint is an Interface which defines how a client will communicate with the service. It consists of three main points: Address,Binding and Contract. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is the difference between WCF Service and Web Service? </b><br />1) WCF Service supports both http and tcp protocol while webservice supports only http protocol. <br />2) WCF Service is more flexible than web service. <br />3) WCF is combination of WebService, Remoting, MSMQ </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What are the various ways of hosting a WCF service? </b><br />Self hosting the service in his own application domain. This we have already covered in the first section. The service comes in to existence when you create the object of ServiceHost class and the service closes when you call the Close of the ServiceHost class. Host in application domain or process provided by IIS Server. Host in Application domain and process provided by WAS (Windows Activation Service) Server. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is service and client in perspective of data communication? </b><br />A service is a unit of functionality exposed to the world. <br />The client of a service is merely the party consuming the service. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>List the behaviors that WCF service uses during its execution. </b><br />A WCF service uses the following list of behaviors during its execution. <br />1. Throttling <br />2. Security <br />3. Instancing <br />- PerCall <br />- PerSession <br />- Single <br />4. Error handling <br />5. Concurrency <br />- Multiple <br />- Single <br />- Reentrant <br />6. Transactions </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is WCF? Explain. </b><br />WCF (A platform for SOA) <br />Unified programming model, provided by WCF, helps in building Service Oriented Application (SOA) through some simple implementation. WCF Service features for usage in SOA implementation. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br />Uses of WCF services: <br />• Expose functionality using contracts to clients <br />• Can be deployed over various protocols to satisfy various distributed and interoperable scenarios <br />• Execute autonomously and do not impact another service in case of failure <br />• Design and implementation are separate from business logic, which eases migration to SOA design </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is the programming life cycle of WCF? </b><br />Windows Communication Foundation (WCF) enables applications to communicate whether they are on the same computer, across the Internet, or on different application platforms. This topic outlines the tasks that are required to build a WCF application. The basic tasks to perform, are, in order to: <br />1. Define the Service Contract <br />2. Implement the Service Contract <br />3. Configure the Service by specifying endpoint information and other behavior information <br />4. Host the service in an application <br />5. Build the client application </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>Define WCF data contract </b><br />- A data contract is defined by using a Data Contract Attribute on a class or structure. <br />- Members of the data structure which will be used by the service need to be marked with the Data Member Attribute. <br />- Only those members will be transferred between the service and its client. In the same way that different classes can implement the same interface, different classes can implement the same Data Contract, and can serialize and deserialize the same data. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is the advantage and disadvantage of implementing IExtensibleDataObject? </b><br />WCF guidelines recommend enhancing all data contracts with support of IExtensibleDataObject interface, to preserve unexpected data from clients. During deserialization, superfluous data is placed in a dictionary on the service side and during serialization, the same data is written as XML as it was originally provided by the client. This is very useful to preserve data from version 2.0 services at a version 1.0 client. It is also useful in case where downstream calls from version 2.0 services go to other services handling version 1.0. <br />However, there is also a disadvantage of implementing IExtensibleDataObject. It carries risks of denial of service (DoS) and unnecessary use of server resources. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What is the role of WSDL in WCF? </b><br />WSDL stands for Web Service Description Language. The WCF service exposes the WSDL document for the clients, to generate proxies and the configuration file. The WSDL file provides the following information for the consumers of the WCF service. <br />1. Provides the information about the service contract and operations available. <br />2. Provides the information about all the end points exposed by the WCF service. <br />3. Provides the information about the messages and types that can be exchanged between the client and the WCF service. <br />4. WSDL also provides any information about the policies used. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What are the different types of bindings available in WCF? </b><br /><u>Basic Binding: </u><br />Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old clients can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>TCP Binding: </u><br />Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>Peer Network Binding: </u><br />Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>IPC Binding: </u><br />Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>Web Service (WS) Binding: </u><br />Offered by the WSHttpBinding class, this usHTTP or HTTPS for transport, and is designed to offer a variety of features such as reliability, transactions, and security over the Internet. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>Federated WS Binding:</u><br />Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>Duplex WS Binding:</u><br />Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><u>MSMQ Binding:</u><br />Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br />MSMQ Integration Binding: <br />Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients. </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br /><b>What are Various Ways of Hosting WCF Services?</b><br />Three ways of hosting WCF Services: <br />1. Self-hosting the service in its own application domain. The service comes into existence when you create the object of Service Host class and the service closes when you call the Close of the Service Host class. <br />2. Host in application domain or process provided by IIS Server. <br />3. Host in application domain and process provided by WAS (Windows Activation Service) Server. </span></span><br /><br /></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-45980263266520798102013-09-07T15:39:00.000-07:002014-02-15T07:41:34.572-08:00Watermark Text for Textbox by using JavaScript<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> This is the simple demonstration in JavaScript how to create watermark text for textbox control. This requirement is the mostly used in web application.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Here the given codes to create the watermark text for textbox control.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>For Example:</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: maroon;">head</span><span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: maroon;">title</span><span style="color: blue;">></span>Sample for Watermark Text Using JavaScript<span style="color: blue;"></</span><span style="color: maroon;">title</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">language</span><span style="color: blue;">="javascript"</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;">function</span> FuncWaterMark(txtEmail, event) {</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;">var</span> strVal = <span style="color: maroon;"> "Enter EmailID Here"</span>;</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: darkgreen;">//Here to check textbox length and event type</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;">if</span> (txtEmail.value.length == 0 & event.type == <span style="color: maroon;">"blur"</span>) {</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>txtEmail.style.color = <span style="color: maroon;">"Gray"</span>;<span style="color: darkgreen;">//setting text color</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>txtEmail.value = strVal; <span style="color: darkgreen;">//setting default text in textbox</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>}</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: darkgreen;">// Here to check textbox value and event type</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;">if</span> (txtEmail.value == strVal & event.type == <span style="color: maroon;">"focus"</span>) {</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>txtEmail.style.color = <span style="color: maroon;">"black"</span>;</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>txtEmail.value = <span style="color: maroon;">""</span>;</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>}</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> }</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: maroon;">head</span><span style="color: blue;">></span><span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: maroon;">body</span><span style="color: blue;">></span><span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: maroon;">form</span> <span style="color: red;">id</span><span style="color: blue;">="form1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: maroon;">b</span><span style="color: blue;">></span>Email ID:<span style="color: blue;"></</span><span style="color: maroon;">b</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span> <span style="color: red;">ID</span><span style="color: blue;">="txtEmailID"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">="Enter EmailID Here"</span> <span style="color: red;">ForeColor</span><span style="color: blue;">="Gray"</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: red;">onblur</span><span style="color: blue;">="FuncWaterMark(this, event);"</span> <span style="color: red;">onfocus</span><span style="color: blue;">="FuncWaterMark(this, event);"</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: maroon;">form</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: maroon;">body</span><span style="color: blue;">></span><span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: maroon;">html</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><span>Output:</span></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><img alt="How to create watermark Text for Textbox by using JavaScript" src="http://www.mindstick.com/Articles/ffee4496-2c08-4b5b-a2d2-2febe61c622f/Images/image002.jpg" title="How to create watermark Text for Textbox by using JavaScript" /></b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> </b> <span disabled="disabled"><label for="ctl00_ctrlArticleComment_chkboxCommentEnable"> </label></span></span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-68802904637221420442013-09-07T15:29:00.000-07:002014-02-15T07:41:34.580-08:00How to Drop Primary Key Constraint<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Here I described how to drop primary key form table. There are two way for doing this. </span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> One is when we are not providing constraint key name during creating table.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Second is given constraint name during creating table.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Without giving constraint key</span></span></h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> First create a table in SQL server with primary key only like below code.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.65in;" valign="top" width="638"> <div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">create</span><span> <span style="color: blue;">table</span> info</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">(</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> id <span style="color: blue;">int</span> <span style="color: blue;">primary</span> <span style="color: blue;">key</span><span style="color: grey;">,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> [name] <span style="color: blue;">varchar</span><span style="color: grey;">(</span>50<span style="color: grey;">)</span> <span style="color: grey;">not</span> <span style="color: grey;">null,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> address <span style="color: blue;">varchar</span><span style="color: grey;">(</span>50<span style="color: grey;">)</span> <span style="color: grey;">not</span> <span style="color: grey;">null</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">)</span></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Copy the key value from created table ‘Keys’. This key automatic created by sql server. </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="How to Drop Primary Key Constraint" src="http://www.mindstick.com/Articles/c7c850d7-9a60-4dcc-af6b-9dabc7cd8096/Images/image001.png" title="How to Drop Primary Key Constraint" /></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Write code for drop primary key</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.65in;" valign="top" width="638"> <div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">alter</span><span> <span style="color: blue;">table</span> info</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">drop</span><span> PK__info__1A14E395</span></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> With giving constraint key</span></span></h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Create table like below </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.65in;" valign="top" width="638"> <div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">create</span><span> <span style="color: blue;">table</span> info</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">(</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> id <span style="color: blue;">int</span><span style="color: grey;">,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> [name] <span style="color: blue;">varchar</span><span style="color: grey;">(</span>50<span style="color: grey;">)</span> <span style="color: grey;">not</span> <span style="color: grey;">null,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> address <span style="color: blue;">varchar</span><span style="color: grey;">(</span>50<span style="color: grey;">)</span> <span style="color: grey;">not</span> <span style="color: grey;">null</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">constraint</span><span> pk_info_id <span style="color: blue;">primary</span> <span style="color: blue;">key</span> <span style="color: blue;">clustered</span><span style="color: grey;">(</span>id <span style="color: blue;">asc</span><span style="color: grey;">)</span> </span></span></span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">)</span></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Drop primary key</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">alter</span><span> <span style="color: blue;">table</span> info</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">drop</span><span> pk_info_id</span></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-29335928035317383492013-09-07T15:27:00.000-07:002014-02-15T07:41:34.653-08:00DELETE, TRUNCATE with RESEED Identity in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> There is miner difference between DELETE, TRUNCATE with RESEED Identity in SQL Server. For demonstration first we create a table with Identity column then perform DELETE and TRUNCATE operation.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.65in;" valign="top" width="638"> <div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- CREATE TABLE </span></span></span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">CREATE</span><span> <span style="color: blue;">TABLE</span> STUDENT_INFO</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">(</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> [ID] <span style="color: blue;">INT</span> <span style="color: blue;">IDENTITY</span><span style="color: grey;">(</span>1<span style="color: grey;">,</span>1<span style="color: grey;">)</span> <span style="color: blue;">PRIMARY</span> <span style="color: blue;">KEY</span><span style="color: grey;">,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> [ROLL_NO]<span style="color: blue;">INT</span> <span style="color: grey;">NOT</span> <span style="color: grey;">NULL,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> [NAME] <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>50<span style="color: grey;">)</span> <span style="color: grey;">NOT</span> <span style="color: grey;">NULL,</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">)</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: grey;"> </span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- INSERT RECORDS</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INSERT</span><span> <span style="color: blue;">INTO</span> STUDENT_INFO <span style="color: blue;"> VALUES</span><span style="color: grey;">(</span>101<span style="color: grey;">,</span><span style="color: red;">'HAIDAR'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INSERT</span><span> <span style="color: blue;">INTO</span> STUDENT_INFO <span style="color: blue;"> VALUES</span><span style="color: grey;">(</span>102<span style="color: grey;">,</span><span style="color: red;">'ARUN'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: grey;"> </span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- DISPLAY TABLE RECORD</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> STUDENT_INFO</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Screen Shot</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="DELETE, TRUNCATE with RESEED Identity in SQL Server" src="http://www.mindstick.com/Articles/84073184-bfed-4208-9dc6-84e956b171e5/Images/image007.jpg" title="DELETE, TRUNCATE with RESEED Identity in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3 style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Effect of DELETE statement</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Delete records from table using <b>DELETE</b> command then insert new record and see table records.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.65in;" valign="top" width="638"> <div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- DELETE RECORDS</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">DELETE</span><span> <span style="color: blue;">FROM</span> STUDENT_INFO</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">--INSERT SOME NEW RECORD</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INSERT</span><span> <span style="color: blue;">INTO</span> STUDENT_INFO <span style="color: blue;"> VALUES</span><span style="color: grey;">(</span>103<span style="color: grey;">,</span><span style="color: red;">'MANOJ'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INSERT</span><span> <span style="color: blue;">INTO</span> STUDENT_INFO <span style="color: blue;">VALUES</span><span style="color: grey;">(</span>104<span style="color: grey;">,</span><span style="color: red;">'SAURABH'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: grey;"> </span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- DISPLAY TABLE RECORDS</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> STUDENT_INFO</span></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Screen Shot</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="DELETE, TRUNCATE with RESEED Identity in SQL Server" src="http://www.mindstick.com/Articles/84073184-bfed-4208-9dc6-84e956b171e5/Images/image008.jpg" title="DELETE, TRUNCATE with RESEED Identity in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Here we see, When the DELETE statement is executed without WHERE clause it will delete all the rows. However, when a new record is inserted the identity value (ID column) is increased from 2 to 3. It does not reset but keep on increasing.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3 style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Effect of TRUNCATE statement</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Delete records from table using <b>TRUNCATE</b> command then insert new record and see table records.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2"> <tbody><tr> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 6.65in;" valign="top" width="638"> <div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- TRUNCATE RECORDS</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">TRUNCATE</span><span> <span style="color: blue;">TABLE</span> STUDENT_INFO</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- INSERT NEW RECORDS</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INSERT</span><span> <span style="color: blue;">INTO</span> STUDENT_INFO <span style="color: blue;"> VALUES</span><span style="color: grey;">(</span>105<span style="color: grey;">,</span><span style="color: red;">'SANDEEP'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INSERT</span><span> <span style="color: blue;">INTO</span> STUDENT_INFO <span style="color: blue;">VALUES</span><span style="color: grey;">(</span>106<span style="color: grey;">,</span><span style="color: red;">'ROHIT'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: grey;"> </span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: green;">-- DISPLAY TABLE RECORDS</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> STUDENT_INFO</span></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Screen Shot</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="DELETE, TRUNCATE with RESEED Identity in SQL Server" src="http://www.mindstick.com/Articles/84073184-bfed-4208-9dc6-84e956b171e5/Images/image009.jpg" title="DELETE, TRUNCATE with RESEED Identity in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Now we see, When the TRUNCATE statement is executed it will remove all the rows. However, when a new record is inserted the identity value (ID column) is increased from 1 (which is original value). TRUNCATE resets the identity value to the original seed value of the table.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span disabled="disabled"><label for="ctl00_ctrlArticleComment_chkboxCommentEnable"> </label></span></span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-44191646830673443892013-09-07T15:25:00.000-07:002014-02-15T07:41:34.728-08:00Create a user define function using SQL Server 2008 R2<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In this blog I am trying to explain how create a user define function using SQL Server 2008 R2.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In the SQL Server 2008 R2 have many predefined functions <b>aggregate functions</b> and <b>Scalar functions</b> which are worked for resolve our complex problems, and we are also known the method or functions resolve the complexity.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Aggregate functions:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> SQL aggregate functions return a single value, which is calculated from values in a column. Such as </span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> <span>1.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span>AVG () - Returns the average value.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpLast" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> <span>2.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span>COUNT () - Returns the number of rows.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Scalar functions:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> SQL scalar functions return a single value, based on the input value.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> <span>1.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span>UCASE () - Converts a field to upper case.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpLast" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> <span>2.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span>LCASE () - Converts a field to lower case.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> UDF (User Define Function):</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> UDF is the concept of User-Defined Functions that allow you to define your own T-SQL functions that can allow zero or more parameters and return a single scalar data value or a table data type.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> We can create three types of UDF in SQL Server 2008 R2 and they are:</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span><span>1.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span></b><b>Scalar</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span><span>2.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span></b><b>Inline Table-Valued</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpLast" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span><span>3.<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span></span></b><b> Multi-statement Table-valued.</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Below I am giving an example for User Define Scalar Function which is single parameterizes<span> </span>function.</span></span></h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Function:</span></span></h4><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> CREATE</span><b><span> </span></b> <span style="color: blue;"> FUNCTION</span><b><span> whichCountry </span></b></span></span> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> </span></span></span> </div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;"> (</span><span>@City <span style="color: blue;">nvarchar</span><span style="color: grey;">(</span>15<span style="color: grey;">))</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> RETURNS</span><b><span> </span></b> <span style="color: blue;"> varchar</span><span style="color: grey;">(</span><span>30<span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> AS</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> BEGIN</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> declare</span><b><span> @Return </span></b> <span style="color: blue;"> varchar</span><span style="color: grey;">(</span><span>30<span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> select</span><b><span> @return </span></b> <span style="color: grey;"> =</span><b><span> </span></b> <span style="color: blue;"> case</span><b><span> @City</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'New Delhi'</span><b><span> </span></b> <span style="color: blue;">then</span><b><span> </span></b> <span style="color: red;">'India'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'Banglore'</span><b><span> </span></b> <span style="color: blue;"> then</span><b><span> </span></b> <span style="color: red;"> 'India'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'Colombo'</span><b><span> </span></b> <span style="color: blue;"> then</span><b><span> </span></b> <span style="color: red;"> 'SriLanka'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'New York'</span><b><span> </span></b> <span style="color: blue;">then</span><b><span> </span></b> <span style="color: red;">'U.S.A'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'Chicago'</span><b><span> </span></b> <span style="color: blue;"> then</span><b><span> </span></b> <span style="color: red;"> 'U.S.A'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'Dhaka'</span><b><span> </span></b> <span style="color: blue;"> then</span><b><span> </span></b> <span style="color: red;"> 'Bangladesh'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'Beijing'</span><b><span> </span></b> <span style="color: blue;"> then</span><b><span> </span></b> <span style="color: red;"> 'China'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> when</span><b><span> </span></b> <span style="color: red;"> 'Kyoto'</span><b><span> </span></b> <span style="color: blue;"> then</span><b><span> </span></b> <span style="color: red;"> 'Japan'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> else</span><b><span> </span></b> <span style="color: red;"> 'Unknown'</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> end</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> return</span><b><span> @return</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">end</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Above function will accept a value City name and return its Country name .</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h5> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Now we will create a table:</span></span></span></h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> Create</span><b><span> </span></b> <span style="color: blue;"> table</span><b><span> tblEmployeeCity</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;"> (</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>vEmpID </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>10<span style="color: grey;">),</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>eName </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>50<span style="color: grey;">),</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>vCity </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>50<span style="color: grey;">)</span><b><span> </span> </b> </span></span></span> </div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey; line-height: 115%;">)</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h5> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Insert Values in table:</span></span></span></h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> INSERT</span><b><span> </span></b> <span style="color: blue;"> INTO</span><b><span> [dbo]</span></b><span style="color: grey;">.</span><span>[tblEmployeeCity] <span style="color: blue;">VALUES </span><span style="color: grey;">(</span><span style="color: red;">'E001'</span><span style="color: grey;">,</span><span style="color: red;">'Ajay Shukla'</span><span style="color: grey;">,</span><span style="color: red;">'New York'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> INSERT</span><b><span> </span></b> <span style="color: blue;"> INTO</span><b><span> [dbo]</span></b><span style="color: grey;">.</span><span>[tblEmployeeCity] <span style="color: blue;">VALUES </span><span style="color: grey;">(</span><span style="color: red;">'E002'</span><span style="color: grey;">,</span><span style="color: red;">'Sanjay Shukla'</span><span style="color: grey;">,</span><span style="color: red;">'Beijing'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"> INSERT</span><b><span style="line-height: 115%;"> </span></b> <span style="color: blue; line-height: 115%;">INTO</span><b><span style="line-height: 115%;"> [dbo]</span></b><span style="color: grey; line-height: 115%;">.</span><span style="line-height: 115%;">[tblEmployeeCity] <span style="color: blue;">VALUES </span><span style="color: grey;">(</span><span style="color: red;">'E003'</span><span style="color: grey;">,</span><span style="color: red;">'Vijay Shukla'</span><span style="color: grey;">,</span><span style="color: red;">'Banglore'</span><span style="color: grey;">)</span></span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Create a user define function using SQL Server 2008 R2" src="http://www.mindstick.com/Articles/ceff5194-4ef0-49b6-b9df-c4070fbb0d7c/Images/image001.jpg" title="Create a user define function using SQL Server 2008 R2" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Use our function:</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> select</span><b><span> Country</span></b><span style="color: grey;">=</span><span>dbo<span style="color: grey;">.</span>whichCountry<span style="color: grey;">(</span>tblEmployeeCity<span style="color: grey;">.</span>vCity<span style="color: grey;">),</span><b> tblEmployeeCity</b><span style="color: grey;">.*</span><b> </b> </span></span></span> </div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"> from</span><b><span style="line-height: 115%;"> tblEmployeeCity</span></b></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Above statement will make a virtual column Country’s name and <span style="background: none repeat scroll 0% 0% yellow;">whichCountry ()</span> method accepts the value of vCity column and <span style="background: none repeat scroll 0% 0% yellow;">whichCountry ()</span> method match the vCity columns values in its code such as if value is <span style="color: red; line-height: 115%;"> Banglore </span> <span>then </span><span style="background: none repeat scroll 0% 0% yellow;">whichCountry ()</span> method will return the <span style="color: red;">India</span>. After that below will show on your screen:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Create a user define function using SQL Server 2008 R2" src="http://www.mindstick.com/Articles/ceff5194-4ef0-49b6-b9df-c4070fbb0d7c/Images/image002.jpg" title="Create a user define function using SQL Server 2008 R2" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Below I’m using the UDF <span style="background: none repeat scroll 0% 0% yellow;"> whichCountry ()</span> method during creating a table:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> create</span><b><span> </span></b> <span style="color: blue;"> table</span><b><span> tblEmployeeFullInformation</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;"> (</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>vName </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>50<span style="color: grey;">),</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>vCity </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>15<span style="color: grey;">),</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>vCountry </span></b> <span style="color: blue;">as </span> <span style="color: grey;"> (</span><span>dbo<span style="color: grey;">.</span>WhichCountry<span style="color: grey;">(</span>vCity<span style="color: grey;">))</span></span></span></span></div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey; line-height: 115%;">)</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">When we will insert values in the <span style="background: none repeat scroll 0% 0% yellow;"> tblEmployeeFullInformation</span> table we need only name and Employee Name and its city but country name will automatically get via <span style="background: none repeat scroll 0% 0% yellow;">whichCountry ()</span> method.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h5> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Insert Values in </span> <span style="background: none repeat scroll 0% 0% yellow;"> tblEmployeeFullInformation</span><span>:</span></span></span></h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> INSERT</span><b><span> </span></b> <span style="color: blue;"> INTO</span><b><span> tblEmployeeFullInformation</span></b><span style="color: blue;"> </span> <span style="color: grey;">(</span><span>vName<span style="color: grey;">,</span>vCity<span style="color: grey;">)</span><span style="color: blue;"> VALUES</span><span style="color: grey;"> (</span><span style="color: red;">'Vijay Shukla'</span><span style="color: grey;">,</span><span style="color: red;">'Banglore'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> INSERT</span><b><span> </span></b> <span style="color: blue;"> INTO</span><b><span> tblEmployeeFullInformation</span></b><span style="color: blue;"> </span> <span style="color: grey;">(</span><span>vName<span style="color: grey;">,</span>vCity<span style="color: grey;">)</span><span style="color: blue;"> VALUES</span><span style="color: grey;"> (</span><span style="color: red;">'Ajay Shukla'</span><span style="color: grey;">,</span><span style="color: red;">'New York'</span><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"> INSERT</span><b><span style="line-height: 115%;"> </span></b> <span style="color: blue; line-height: 115%;">INTO</span><b><span style="line-height: 115%;"> tblEmployeeFullInformation</span></b><span style="color: blue; line-height: 115%;"> </span> <span style="color: grey; line-height: 115%;">(</span><span style="line-height: 115%;">vName<span style="color: grey;">,</span>vCity<span style="color: grey;">)</span><span style="color: blue;"> VALUES</span><span style="color: grey;"> (</span><span style="color: red;">'Sanjay Shukla'</span><span style="color: grey;">,</span><span style="color: red;">'Beijing'</span><span style="color: grey;">)</span></span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Create a user define function using SQL Server 2008 R2" src="http://www.mindstick.com/Articles/ceff5194-4ef0-49b6-b9df-c4070fbb0d7c/Images/image003.jpg" title="Create a user define function using SQL Server 2008 R2" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Inline table Value:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Its returns a table data type and is an extravagant alternative to a view as the user-defined function, it will take parameters into a T-SQL select command and in synopsis provide us with a parameterized, non-updateable view of the underlying tables.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt 1pt 0in;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> CREATE</span><b><span> </span></b> <span style="color: blue;"> FUNCTION</span><b><span> EmployeeByCountry</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;"> (</span><span>@Country <span style="color: blue;">varchar</span><span style="color: grey;">(</span>30<span style="color: grey;">))</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> RETURNS</span><b><span> </span></b> <span style="color: blue;"> TABLE</span><b><span> </span></b></span></span> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> </span></span></span> </div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> AS</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> RETURN</span><b><span> </span></b></span></span> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> </span></span></span> </div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span></span></b> <span style="color: blue;">SELECT</span><b><span> dbo</span></b><span style="color: grey;">.</span><span>WhichCountry<span style="color: grey;">(</span>tblEmployeeCity<span style="color: grey;">.</span>vCity<span style="color: grey;">)</span><b> </b><span style="color: blue;">as</span><b> tblEmployeeFullInformation</b><span style="color: grey;">,</span></span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span>tblEmployeeCity</span></b><span style="color: grey;">.*</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span></span></b> <span style="color: blue;">FROM</span><b><span> tblEmployeeCity</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> <span> <span> </span></span></b> <span style="color: blue;">WHERE</span><b><span> dbo</span></b><span style="color: grey;">.</span><span>WhichCountry<span style="color: grey;">(</span>tblEmployeeCity<span style="color: grey;">.</span>vCity<span style="color: grey;">)</span><b> </b><span style="color: grey;">=</span><b> @Country</b></span></span></span></div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">GO</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Above code will create a table with <span style="background: none repeat scroll 0% 0% yellow;">EmployeeByCountry</span> name. And when this table will execute with T-SQL select command then we also need to pass a parameter with the table name below is example:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"> select</span><b><span style="line-height: 115%;"> </span></b> <span style="color: grey; line-height: 115%;">*</span><b><span style="line-height: 115%;"> </span></b> <span style="color: blue; line-height: 115%;">from</span><b><span style="line-height: 115%;"> EmployeeByCountry</span></b><span style="color: grey; line-height: 115%;">(</span><span style="color: red; line-height: 115%;">'India'</span><span style="color: grey; line-height: 115%;">)</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Output:</span></span></h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Create a user define function using SQL Server 2008 R2" src="http://www.mindstick.com/Articles/ceff5194-4ef0-49b6-b9df-c4070fbb0d7c/Images/image004.jpg" title="Create a user define function using SQL Server 2008 R2" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Multi-statement Table-valued.</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> CREATE</span><b><span> </span></b> <span style="color: blue;"> FUNCTION</span><b><span> Employee</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;"> (</span><b><span> @ID </span></b> <span style="color: blue;"> varchar</span><span style="color: grey;">(</span><span>50<span style="color: grey;">)</span><b> </b><span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> RETURNS</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> @EmployeeInfo <span style="color: blue;">table </span><span style="color: grey;">(</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> Emp_name <span style="color: blue;">Varchar</span><span style="color: grey;">(</span>50<span style="color: grey;">),</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> Emp_City <span style="color: blue;">Varchar</span><span style="color: grey;">(</span>20<span style="color: grey;">)</span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;"> )</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> AS</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> BEGIN</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> INSERT</span><b><span> </span></b> <span style="color: blue;"> INTO</span><b><span> @EmployeeInfo </span></b> <span style="color: blue;">SELECT</span><b><span> eName</span></b><span style="color: grey;">,</span><span>vCity <span style="color: blue;">FROM</span><b> tblEmployeeCity </b> <span style="color: blue;">WHERE</span><b> vEmpID </b><span style="color: grey;">=</span><b> @ID</b></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> IF</span><b><span> </span></b> <span style="color: magenta;">@@ROWCOUNT</span><b><span> </span></b> <span style="color: grey;">=</span><b><span> 0</span></b><span></span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> BEGIN</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> INSERT</span><b><span> </span></b> <span style="color: blue;"> INTO</span><b><span> @EmployeeInfo </span></b> <span style="color: blue;">VALUES </span> <span style="color: grey;">(</span><span style="color: red;">''</span><span style="color: grey;">,</span><span style="color: red;">'No Enployee Found'</span><span style="color: grey;">)</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> END</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> RETURN</span></span></span></div><div class="MsoNormal" style="border: medium none; line-height: normal; margin-bottom: 0.0001pt; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"> END</span></span></span></div><div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">GO</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">Above code will create a virtual table which is shows the employee information as Employee Name and Employee City.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Execute:</span></span></h5><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div style="border: 1pt solid windowtext; padding: 1pt 4pt;"> <div class="MsoNormal" style="border: medium none; padding: 0in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"> SELECT</span><b><span style="line-height: 115%;"> </span></b> <span style="color: grey; line-height: 115%;">*</span><b><span style="line-height: 115%;"> </span></b> <span style="color: blue; line-height: 115%;">FROM</span><b><span style="line-height: 115%;"> Employee</span></b><span style="color: grey; line-height: 115%;">(</span><span style="color: red; line-height: 115%;">'E001'</span><span style="color: grey; line-height: 115%;">)</span></span></span></div></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Create a user define function using SQL Server 2008 R2" src="http://www.mindstick.com/Articles/ceff5194-4ef0-49b6-b9df-c4070fbb0d7c/Images/image005.jpg" title="Create a user define function using SQL Server 2008 R2" /></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-23734928249053058102013-09-07T15:21:00.000-07:002014-02-15T07:41:34.804-08:00Restart Computer Failed Error in SQL Server 2008 <div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">“<b>Restart Computer Fail</b>” error occurs when we try to install <b>SQL Server 2008 Developer Edition. </b>Trying to install SQL Server 2008 Developer edition setup <b>failed</b> at the <b>Setup Support Rules</b> page on the Rule "<b>Restart Computer</b>" see figure 1. The following error message appear on screen: "<b>Restart computer failed</b>" see figure 2.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Figure 1:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Restart Computer Failed Error in SQL Server 2008 " src="http://www.mindstick.com/Articles/5f7c41c3-7425-4c60-897a-49e53d3763ef/Images/image002.jpg" title="Restart Computer Failed Error in SQL Server 2008 " /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Figure 2:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Restart Computer Failed Error in SQL Server 2008 " src="http://www.mindstick.com/Articles/5f7c41c3-7425-4c60-897a-49e53d3763ef/Images/image004.jpg" title="Restart Computer Failed Error in SQL Server 2008 " /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style2"><span style="line-height: 115%;"> </span></span></span></span></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style2"><span style="line-height: 115%;">Error Reason:</span></span><span style="line-height: 115%;"> In general, a previous program installation created pending file operations on the installation machine.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Solution: </span></span> </h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style3"><span style="line-height: 115%;">Step 1:</span></span><span style="line-height: 115%;"> Open the registry. For open registry, press<b> window key + R </b>and type </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style3"><span style="line-height: 115%;">Step 2:</span></span><span style="line-height: 115%;"> Type <b>regedit </b>and press enter button</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style3"><span style="line-height: 115%;">Step 3:</span></span><span style="line-height: 115%;"> Now select <b> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session</b> <b>Manager</b></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style3"><span style="line-height: 115%;">Step 4:</span></span><span style="line-height: 115%;"> Double click "<b>PendingFileRenameOperations</b>"</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style3"><span style="line-height: 115%;">Step 5:</span></span><span style="line-height: 115%;"> Delete all data from <b>Value data </b>textbox<b>. </b></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style3"><span style="line-height: 115%;">Step 6:</span></span><span style="line-height: 115%;"> Press OK and close the registry.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="line-height: 115%;">Now try to run SQL Server 2008 setup again. I hope <b>Restart computer failed </b>error not come again. </span></span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-70318623559091075312013-09-07T15:19:00.000-07:002014-02-15T07:41:34.877-08:00 Cursor in SQL<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In this blog I am trying to explain the concept of Cursor in SQL Server.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Definition: </span></span> </h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Cursor is an object of database which is used to retrieve data from result set row by row. In other words a cursor is a set of rows together with a pointer that identifies a current row. We use cursor when we need to update records in a table row by row.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Cursor Life Cycle:</span></span></h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>1-Declare Cursor</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> A cursor is declared by DECLARE CURSOR SQL command. We can declare a cursor by following syntax:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style2" style="width: 616px;"> <tbody><tr style="height: 126.75pt;"> <td style="border: 1pt solid windowtext; height: 126.75pt; padding: 0in 5.4pt; width: 461.85pt;" valign="top" width="616"> <div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">DECLARE</span><b><span style="color: #393124;"> cur_name </span></b> <span style="color: blue;">CURSOR</span><b><span style="color: #9d9d9d;"></span></b></span></span></div><div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span style="color: #393124;">[LOCAL | GLOBAL] </span><i> <span style="color: #4e9b00;">--define the scope of cursor</span></i><span style="color: #9d9d9d;"></span></b></span></span></div><div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span style="color: #393124;">[FORWARD_ONLY | SCROLL] </span> <i> <span style="color: #4e9b00;">--define cursor movements </span></i> <span style="color: #9d9d9d;"> </span></b></span></span> </div><div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span style="color: #393124;">[STATIC | KEYSET | DYNAMIC | FAST_FORWARD] </span><i> <span style="color: #4e9b00;">-- type of cursor</span></i><span style="color: #9d9d9d;"></span></b></span></span></div><div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> <span style="color: #393124;">[READ_ONLY | SCROLL_LOCKS | OPTIMISTIC] </span><i> <span style="color: #4e9b00;">--define locks</span></i><span style="color: #9d9d9d;"></span></b></span></span></div><div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FOR</span><b><span style="color: #393124;"> select_statement </span><i> <span style="color: #4e9b00;">-- SQL Select statement</span></i><span style="color: #9d9d9d;"></span></b></span></span></div><div class="MsoNormal" style="line-height: 16.3pt; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FOR UPDATE</span><b><span style="color: #393124;"> [column1,column2,...columnn] </span><i> <span style="color: #4e9b00;">-- columns that to be updated</span></i></b></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>2-Open Cursor</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> A cursor can be open in two way either locally or globally. Syntax for open cursor:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style3"> <tbody><tr style="height: 18.2pt;"> <td style="border: 1pt solid windowtext; height: 18.2pt; padding: 0in 5.4pt; width: 466.65pt;" valign="top" width="622"> <div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">OPEN</span><b><span style="line-height: 115%;"> [GLOBAL] cur_name </span><i> <span style="color: #4e9b00; line-height: 115%;">--by default it is local</span></i></b></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> </b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>3-Fetch Cursor</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> After opening a you can fetch cursor. Syntax for fetch cursor:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style4"> <tbody><tr style="height: 22pt;"> <td style="border: 1pt solid windowtext; height: 22pt; padding: 0in 5.4pt; width: 460.55pt;" valign="top" width="614"> <div class="MsoNormal" style="line-height: normal; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FETCH</span><b><span style="color: #393124;"> [NEXT|PRIOR|FIRST|LAST|ABSOLUTE n|RELATIVE n]</span></b></span></span></div><div class="MsoNormal" style="line-height: normal; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FROM</span><b><span style="color: #393124;"> [GLOBAL] cur_name </span> <span style="color: #9d9d9d;"> </span></b></span></span> </div><div class="MsoNormal" style="line-height: normal; margin-left: 0.25in; text-align: justify;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">INTO</span><b><span style="color: #393124;"> @var1,@var2…..@varn</span></b></span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> </b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>4-Close Cursor</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Close statement close cursor explicitly. Syntax for close cursor:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style4"> <tbody><tr style="height: 19pt;"> <td style="border: 1pt solid windowtext; height: 19pt; padding: 0in 5.4pt; width: 461.2pt;" valign="top" width="615"> <div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">CLOSE</span><b> <span> </span></b>cur_name</span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> </b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>5-Deallocate Cursor</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> To free the resources allocated by cursor we deallocate the cursor.Syntax for <span style="background: none repeat scroll 0% 0% rgb(249, 249, 249); color: #161616; line-height: 115%;"> deallocate </span>cursor</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><table border="1" cellpadding="0" cellspacing="0" class="style5"> <tbody><tr style="height: 27.85pt;"> <td style="border: 1pt solid windowtext; height: 27.85pt; padding: 0in 5.4pt; width: 457.8pt;" valign="top" width="610"> <div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">DEALLCATE</span><b><span> </span></b>cur_name</span></span></div></td> </tr></tbody></table><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <b> </b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Example of Cursor</span></span></h1><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">DECLARE</span><b><span> @FirstName </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>50<span style="color: grey;">)</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">DECLARE</span><b><span> @LastName </span></b> <span style="color: blue;">varchar</span><span style="color: grey;">(</span><span>50<span style="color: grey;">)</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">DECLARE</span><b><span> cur_name </span></b> <span style="color: blue;">CURSOR</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">STATIC</span><b><span> </span></b> <span style="color: blue;">FOR</span><b><span> </span></b> <span style="color: blue;">SELECT</span><b><span> FirstName</span></b><span style="color: grey;">,</span><span>LastName <span style="color: blue;">FROM</span><b> user1</b></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">OPEN</span><b><span> cur_name</span></b><span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">if</span><b><span> </span></b> <span style="color: magenta;">@@CURSOR_ROWS</span><span style="color: grey;">></span><span>0</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">BEGIN</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FETCH</span><b><span> </span></b> <span style="color: blue;">NEXT</span><b><span> </span></b> <span style="color: blue;">FROM</span><b><span> cur_name </span></b> <span style="color: blue;">INTO</span><b><span> @FirstName</span></b><span style="color: grey;">,</span><span>@LastName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">WHILE</span><b><span> </span></b> <span style="color: magenta;">@@FETCH_STATUS</span><span style="color: grey;">=</span><span>0</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">BEGIN</span><b><span> </span></b></span></span> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">PRINT</span><b><span> </span></b> <span style="color: red;">'First Name:'</span><span style="color: grey;">+</span><span>@FirstName<span style="color: grey;">+</span><span style="color: red;">',Last Name:'</span><span style="color: grey;">+</span>@LastName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FETCH</span><b><span> </span></b> <span style="color: blue;">NEXT</span><b><span> </span></b> <span style="color: blue;">FROM</span><b><span> cur_name </span></b> <span style="color: blue;">INTO</span><b><span> @FirstName</span></b><span style="color: grey;">,</span><span>@LastName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">END</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">END</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">CLOSE</span><b><span> cur_name</span></b><span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue; line-height: 115%;">DEALLOCATE</span><b><span style="line-height: 115%;"> cur_name</span></b></span></span></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-6504604610250716672013-09-07T15:17:00.000-07:002014-02-15T07:41:34.960-08:00Joins in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In this blog, I’m trying to explain the concept of joins in SQL server and its types.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Databases are usually comprised of several tables that are related to one another in some way. You need to pull the information from more than one table at a time so that you get the desired result.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Joins are used to extract data from more than one table at a time and produce the information as a single result set. Join is used to link or connect tables on a common column and return the record that match in those columns.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="border: 1pt none windowtext; padding: 0in;">In SQL joins are used to get data from two or more tables based on relationship between some of the columns in tables. In most of the cases we will use</span><span> </span><b>primary key</b><span> <span style="border: 1pt none windowtext; padding: 0in;">of first table and</span> </span><b>foreign key</b><span> <span style="border: 1pt none windowtext; padding: 0in;">of secondary table to get data from tables by using this relationship we can reduce the duplication of data in every table.</span></span></span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="border: 1pt none windowtext; padding: 0in;">Before enter into Joins concept first design two tables in database and enter data like as shown below</span></span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image002.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> </span></span></span></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Give the table name as <b>CustomerTable</b>. Here CUSTID is the primary key.</span></span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image004.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span> </span></span></span></div><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Give the table name as <b>ProductTable</b>. Here PRODUCTID is the primary key and CUSTID is the foreign key.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span>Types of Joins</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span>Inner Join</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span>Outer Join</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpLast" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span>Self Join</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Inner Join</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> The join that displays only the rows that have a match in both the joined tables is known as inner join.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> This is default join in the query and view designer.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Syntax:</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> SELECT T1.ColumnName, T2.ColumnName</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> FROM TableName1 T1</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> INNER JOIN TableName2 T2</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> ON T1.ColumnName=T2.ColumnName</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Example</span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> C<span style="color: grey;">.</span>CUSTNAME<span style="color: grey;">,</span>C<span style="color: grey;">.</span><span style="color: blue;">ADDRESS</span><span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRODUCTNAME<span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRICE</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FROM</span><span> CustomerTable C</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">INNER</span><span> <span style="color: grey;">JOIN</span> ProductTable P</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">ON</span><span style="line-height: 115%;"> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">=</span>P<span style="color: grey;">.</span>CUSTID</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image006.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Types of Inner Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span><span>Equi Join</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span><span>Natural Join</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpLast" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span><span>Cross Join</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Equi Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>In an equi join, column values are compared for equality and even the duplicate columns are displayed.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Syntax:</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>SELECT * FROM TableName1 T1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Join TableName2 T2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>ON T1.ColumnName=T2.ColumnName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> CustomerTable C</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">Join</span><span> ProductTable P</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">ON</span><span style="line-height: 115%;"> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">=</span>P<span style="color: grey;">.</span>CUSTID</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image008.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Natural Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>In natural join, the duplicate columns are not there. Thus, when you join the two tables, you can select all the fields from one table and specify the fields that you want from the other table.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Syntax:</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>SELECT * FROM TableName1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>NATURAL JOIN TableName2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> CustomerTable </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">NATURAL <span style="color: grey;">Join</span> ProductTable</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Natural Joins won’t work in SQL Server(only supports in Oracle) it will throw a syntax error.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Cross Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>A cross join produces the Cartesian product of the tables those involved in the join. The size of the Cartesian product is the number of the rows in the first table multiplied by the number of the rows in the second table.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Syntax: </span></span></span> </h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>SELECT * FROM TableName1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>CROSS JOIN TableName2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> CustomerTable </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey; line-height: 115%;">CROSS</span><span style="line-height: 115%;"> <span style="color: grey;">JOIN</span> ProductTable</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image010.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Outer Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Outer joins restrict rows from one table while allowing all rows from the second table as a result set.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>There are three types of outer joins:</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span><span>Left Outer Join</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span><span>Right Outer Join</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoListParagraphCxSpLast" style="text-indent: -0.25in;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>·<span style="-moz-font-feature-settings: normal; -moz-font-language-override: normal; font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"> </span></span><span>Full Outer Join</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Left Outer Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>It includes all the rows from the first table and only the matching rows from the second table.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Syntax:</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>SELECT ColumnName FROM TableName1 T1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>LEFT OUTER JOIN TableName2 T2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>ON T1.ColumnName=T2.ColumnName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">,</span>C<span style="color: grey;">.</span>CUSTNAME<span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRODUCTNAME <span style="color: blue;">FROM</span> CustomerTable C</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">LEFT</span><span> <span style="color: grey;">OUTER</span> <span style="color: grey;">JOIN</span> ProductTable P</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">ON</span><span style="line-height: 115%;"> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">=</span>P<span style="color: grey;">.</span>CUSTID</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image012.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Right Outer Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>It includes all the rows from the second table and only the matching rows from the table.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Syntax:</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>SELECT ColumnName FROM TableName1 T1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>RIGHT OUTER JOIN TableName2 T2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>ON T1.ColumnName=T2.ColumnName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">,</span>C<span style="color: grey;">.</span>CUSTNAME<span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRODUCTNAME<span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRICE <span style="color: blue;">FROM</span> CustomerTable C</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">RIGHT</span><span> <span style="color: grey;">OUTER</span> <span style="color: grey;">JOIN</span> ProductTable P</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">ON</span><span> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">=</span>P<span style="color: grey;">.</span>CUSTID</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image014.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Full Outer Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>It includes all the rows, matching as well as non-matching.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Syntax: </span></span></span> </h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>SELECT ColumnName FROM TableName1 T1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>FULL OUTER JOIN TableName2 T2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>ON T1.ColumnName=T2.ColumnName</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">,</span>C<span style="color: grey;">.</span>CUSTNAME<span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRODUCTNAME<span style="color: grey;">,</span>P<span style="color: grey;">.</span>PRICE </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FROM</span><span> CustomerTable C</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FULL</span><span> <span style="color: grey;">OUTER</span> <span style="color: grey;">JOIN</span> ProductTable P</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">ON</span><span style="line-height: 115%;"> C<span style="color: grey;">.</span>CUSTID<span style="color: grey;">=</span>P<span style="color: grey;">.</span>CUSTID</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="line-height: 115%;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image016.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Self Join</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNoSpacing"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Self join correlates rows of a table with the other rows of the same table. It is used when a table has to be joined to itself to produce results.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h3> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Example</span></span></span></h3><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>First you have to create a table EmpTable and enter the details like this:</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image018.jpg" title="Joins in SQL Server" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">SELECT</span><span> E2<span style="color: grey;">.</span>EMPNAME<span style="color: grey;">,</span>E1<span style="color: grey;">.</span>EMPNAME <span style="color: blue;">as</span> <span style="color: red;">'MANAGER'</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;">FROM</span><span> EmpTable E1</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: grey;">INNER</span><span> <span style="color: grey;">JOIN</span> EmpTable E2</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;">ON</span><span style="line-height: 115%;"> E1<span style="color: grey;">.</span>EMPID<span style="color: grey;">=</span>E2<span style="color: grey;">.</span>EMPMGRID</span><span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Output</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="Joins in SQL Server" src="http://www.mindstick.com/Articles/cd69571b-bf8d-49c0-a88a-55f151904d2b/Images/image020.gif" title="Joins in SQL Server" /></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-22087066157967370632013-09-06T13:14:00.000-07:002014-02-15T07:41:35.038-08:00 JQuery append() method<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> JQuery append () method is used to add or insert one or more additional DOM elements in the set of matched elements .In this article I am trying to show you, <span> </span>how we can use append method in JQuery. <span> </span>I have list of images and I want to append image in <label> element.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Code:</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">title</span><span style="color: blue;">></span><span>JQeury append method<span style="color: blue;"></</span><span style="color: #a31515;">title</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="jquery.min.js"></span><span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> $(document).ready(<span style="color: blue;">function</span>() <span style="color: green;"><span> </span></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> {</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"button#btn1"</span>).click(<span style="color: blue;">function</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"label"</span>).append(<span style="color: #a31515;">"<img src='Desert.jpg' width='100' height='50'/>"</span>); <span style="color: green;">// append method will append image in <label> element </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"button#btn2"</span>).click(<span style="color: blue;">function</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"label"</span>).append(<span style="color: #a31515;">"<img src='Chrysanthemum.jpg' width='100' height='50'/>"</span>); </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"button#btn3"</span>).click(<span style="color: blue;">function</span>() <span style="color: green;"> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"label"</span>).append(<span style="color: #a31515;">"<img src='Lighthouse.jpg' width='100' height='50'/>"</span>);<span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: green;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> });</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> </span> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> JQuery append method<span style="color: blue;"></</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">table</span> <span style="color: red;">width</span><span style="color: blue;">="200"</span> <span style="color: red;">border</span><span style="color: blue;">="2"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">='Chrysanthemum.jpg'</span> <span style="color: red;">width</span><span style="color: blue;">='100'</span> <span style="color: red;">height</span><span style="color: blue;">='50'</span><span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">button</span> <span style="color: red;">id</span><span style="color: blue;">='btn1'></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>Add<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">='Desert.jpg'</span> <span style="color: red;">width</span><span style="color: blue;">='100'</span> <span style="color: red;">height</span><span style="color: blue;">='50'</span> <span style="color: blue;">/></span><span style="color: green;"> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">button</span> <span style="color: red;">id</span><span style="color: blue;">="btn2"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>Add<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">='Lighthouse.jpg'</span> <span style="color: red;">width</span><span style="color: blue;">='100'</span> <span style="color: red;">height</span><span style="color: blue;">='50'</span> <span style="color: blue;">/></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">button</span> <span style="color: red;">id</span><span style="color: blue;">="btn3"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>Add<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span> <span style="color: green;"> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">table</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">label</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">left</span>:<span style="color: blue;">245px</span>; <span style="color: red;">top</span>:<span style="color: blue;">62px</span>; <span style="color: red;">position</span>:<span style="color: blue;">absolute"></span>This is a example </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>of JQuery append method you can add image from list--<span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span> <span style="color: green;">label element with text--></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"></</span><span style="color: #a31515; line-height: 115%;">body</span><span style="color: blue; line-height: 115%;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Screenshot</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery append() method" src="http://www.mindstick.com/Articles/cc535e4a-41c7-42f2-b301-d3ecb59ceb01/Images/image002.jpg" title="JQuery append() method" /></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> If we want to append image in the <label>element we can click on particular image button and image will append as shown below:</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Screenshot</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery append() method" src="http://www.mindstick.com/Articles/cc535e4a-41c7-42f2-b301-d3ecb59ceb01/Images/image004.jpg" title="JQuery append() method" /></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-55598801352950925582013-09-06T13:13:00.000-07:002014-02-15T07:41:35.113-08:00JQuery noConflict method<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In JQuery generally ($) dollar sign is an indication of using JQuery function but jQuery give us functionality to rename ($) dollar sign instead of other user define variable name. By using noConflict () method, user can define own variable name. In this article I am trying to show you, how we can use noConflict method in JQuery as shown below:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style2"><span style="line-height: 115%;">Syntax:</span></span><b> var xyz=$.noConflict ();</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Code:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">title</span><span style="color: blue;">></span>JQuery noConflict method<span style="color: blue;"></</span><span style="color: #a31515;">title</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="jquery.min.js"></span><span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;">var</span> userdefine = $.noConflict();<span style="color: green;">//creating user define varaible </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> userdefine(document).ready(<span style="color: blue;">function</span>() {</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> userdefine(<span style="color: #a31515;">"label"</span>).append(<span style="color: #a31515;">"JQuery dollar($)sign has changed from user define variable name('userdefine'</span><span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> JQuery noConfilct method<span style="color: blue;"></</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span> </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"></</span><span style="color: #a31515; line-height: 115%;">html</span><span style="color: blue; line-height: 115%;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Screenshot</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery noConflict method" src="http://www.mindstick.com/Articles/7de623c7-a236-4263-984e-a731a0ef0600/Images/image003.jpg" title="JQuery noConflict method" /></span></span> </div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-77739530444400428642013-09-06T13:11:00.000-07:002014-02-15T07:41:35.185-08:00JQuery removeAttr () method<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In JQuery removeAtrr () method is used to remove attributes from each matched elements. By using this method<span> </span>we can create some custom attribute and remove <span> </span>attributes in element .In this article I am trying to show you, how we can use removeAttr () method to remove attributes of element on page as shown below:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style2"><span style="line-height: 115%;">Syntax</span></span> :<b>$( “element”).removeAttr (“name”);</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Code:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">title</span><span style="color: blue;">></span><span>JQuery removeAtrr method<span style="color: blue;"></</span><span style="color: #a31515;">title</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="jquery.min.js"></span><span style="color: green;">//add jquery library in script tag </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> $(document).ready(<span style="color: blue;">function</span>() <span style="color: green;">//ready function contain all jquery function</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> {</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"#rcolor"</span>).click(<span style="color: blue;">function</span>()<span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"input"</span>).removeAttr(<span style="color: #a31515;">"style"</span>);<span style="color: green;">//removeAttr method will remove style attribute from all input tags</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> });</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">table</span> <span style="color: red;">width</span><span style="color: blue;">="275"</span> <span style="color: red;">border</span><span style="color: blue;">="2"</span> <span style="color: blue;">></span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span>Name<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span>: <span style="color: blue;">Red"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span>Age<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span>: <span style="color: blue;">Red"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span>City<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span>: <span style="color: blue;">Red"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span>College<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span>: <span style="color: blue;">Red"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">table</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">button</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Submit<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: red;">&nbsp;&nbsp;</span> <span style="color: blue;"><</span><span style="color: #a31515;">button</span> <span style="color: red;">id</span><span style="color: blue;">="rcolor"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Remove Color<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span><span style="color: green;"><!—button element with id--></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"></</span><span style="color: #a31515; line-height: 115%;">body</span><span style="color: blue; line-height: 115%;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Screenshot</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="jQuery removeAttr method" src="http://www.mindstick.com/Articles/52bfad44-48bf-472d-9c38-89e84a305e20/Images/image002.jpg" title="jQuery removeAttr method" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> If we want to remove font color from textboxes click on remove color button and red color will remove from font as shown below:</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="jQuery removeAttr method" src="http://www.mindstick.com/Articles/52bfad44-48bf-472d-9c38-89e84a305e20/Images/image004.jpg" title="jQuery removeAttr method" /></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-90435766783409980032013-09-06T13:09:00.000-07:002014-02-15T07:41:35.260-08:00blur method in JQuery<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In JQuery blur method trigger blur event when element will lose their focus. In this article I am using blur () method on html page. In html page I had created some text boxes, if any textboxes got focus then back color of textboxes will white and if textboxes lost their focus then textboxes back color will change, as shown by below example:</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Code:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">title</span><span style="color: blue;">></</span><span style="color: #a31515;">title</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>$(document).ready(<span style="color: blue;">function</span>()<span style="color: green;"> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>$(<span style="color: #a31515;">"input"</span>).focus(<span style="color: blue;">function</span>() <span style="color: green;">//focus method will execute when input element got focus</span><span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>$(<span style="color: #a31515;">"input"</span>).css(<span style="color: #a31515;">"background-color"</span>, <span style="color: #a31515;"> "white"</span>);<span style="color: green;">//when input element got focus backcolor will white</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>$(<span style="color: #a31515;">"input"</span>).blur(<span style="color: blue;">function</span>() <span style="color: green;">//when input element lost its focus blur event will raise </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>$(<span style="color: #a31515;">"input"</span>).css(<span style="color: #a31515;">"background-color"</span>, <span style="color: #a31515;"> "gray </span><span style="color: green;">// css will change backcolor of textboxes</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span><span>Using JQuery blur event <span style="color: blue;"></</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>Enter name:</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: blue;">/></span><span style="color: green;"><!-- input element for textboxes--></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>Enter age: <span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: blue;">/></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/><span> </span> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>Enter City<span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: blue;">/></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span>Enter State<span style="color: blue;"><</span><span style="color: #a31515;">input</span> <span style="color: red;">type</span><span style="color: blue;">="text"</span> <span style="color: blue;">/></span><span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: red;"> </span></span> </span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">button</span><span style="color: blue;">></span>Submit<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"></</span><span style="color: #a31515; line-height: 115%;">html</span><span style="color: blue; line-height: 115%;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>If textboxes got focus backcolor will white as shown below:</span></span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="blur method in JQuery" src="http://www.mindstick.com/Articles/db2a3600-a3a2-402d-86d1-0c290e451efa/Images/image002.jpg" title="blur method in JQuery" /></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> If textboxes lost their focus back color of textboxes will change as shown below:</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="blur method in JQuery" src="http://www.mindstick.com/Articles/db2a3600-a3a2-402d-86d1-0c290e451efa/Images/image004.jpg" title="blur method in JQuery" /></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-44759643081563434442013-09-06T13:07:00.000-07:002014-02-15T07:41:35.333-08:00 JQuery fadeTo method<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> In JQuery fadeTo () method used to fade element on page. In this article I am trying to show you, how we can implement fadeTo method on the page. For example I have two images on page and I want to images fade from page to given opacity.</span></span></div><div class="MsoNormal"><br /></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span class="style2">Syntax:</span> <b>$(“target”).fadeTo (Time duration, Opacity);</b></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Time duration</b>=Pass time duration in string (“fast or medium or slow”)</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Opacity</b>=Opacity should be between 0 and 1.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> Code:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="jquery.min.js"></span> <span style="color: blue;"> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> $(document).ready(<span style="color: blue;">function</span><span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"button"</span>).click(<span style="color: blue;">function</span><span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"img"</span>).fadeTo(<span style="color: #a31515;">"medium"</span>, 0.15); <span style="color: green;">//img will fade by using fadeTo function given time duration and opacity</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> });</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Jquery fadeTo method<span style="color: blue;"></</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">table</span> <span style="color: red;">width</span><span style="color: blue;">="300"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">="Desert.jpg"</span> <span style="color: red;">width</span><span style="color: blue;">="200"</span> <span style="color: red;">height</span><span style="color: blue;">="100"</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">="Jellyfish.jpg"</span> <span style="color: red;">width</span><span style="color: blue;">="200"</span> <span style="color: red;">height</span><span style="color: blue;">="100"</span> ><span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">colspan</span><span style="color: blue;">="2"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"><</span><span style="color: #a31515;">button</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>Click to fade<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span><span style="color: blue;"></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">table</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"></</span><span style="color: #a31515; line-height: 115%;">body</span><span style="color: blue; line-height: 115%;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue; line-height: 115%;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Screenshot</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery fadeTo method" src="http://www.mindstick.com/Articles/4d2acc55-de69-48d3-a92b-5277b81fbeea/Images/image002.jpg" title="JQuery fadeTo method" /></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> When I will click on button image will be start to fade from page as shown below:</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Screenshot</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery fadeTo method" src="http://www.mindstick.com/Articles/4d2acc55-de69-48d3-a92b-5277b81fbeea/Images/image004.jpg" title="JQuery fadeTo method" /></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0tag:blogger.com,1999:blog-8919760615697611468.post-56360697328725792872013-09-06T13:05:00.000-07:002014-02-15T07:41:35.408-08:00 JQuery Event function<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> JQuery Event handlers are method that is called whenever any event is generated or raised in HTML control. For example if I will click on the button then event will raise and all <label> element will hide from page.</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> JQuery events:</span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">$(document).ready(<span style="color: blue;">function</span>(){})</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>This event raise one time html loading has finished.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">$(document).click(<span style="color: blue;">function</span>())</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>This event when raise if any element click like button.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">$(document).focus(<span style="color: blue;">function</span>())</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>This event when raise if any element is selected</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">$( selector).dblclick(<span style="color: blue;">function</span>())</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>This event when raise if any element double click like button.</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">$(selector).mouseover(<span style="color: blue;">function</span>())</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="line-height: 115%;">This event when raise if mouse pointer over on element</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><h2> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>Code:</span></span></span></h2><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">head</span><span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">title</span><span style="color: blue;">></</span><span style="color: #a31515;">title</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span> </span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> $(document).ready(<span style="color: blue;">function</span>()<span style="color: green;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"button"</span>).click(<span style="color: blue;">function</span>()<span style="color: green;">//click method will execute when button is clicked</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>{</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>$(<span style="color: #a31515;">"label"</span>).hide();<span style="color: green;">//label element will hide from page</span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>});</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> });</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span style="color: blue;"> </span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Information<span style="color: blue;"></</span><span style="color: #a31515;">h2</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>Name--><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Tom<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span> <span style="background: none repeat scroll 0% 0% yellow;"> </span></span></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>Age--><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> 23<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span><span> </span><span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>City--><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Newyork<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span><span style="background: none repeat scroll 0% 0% yellow;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span>School--><span style="color: blue;"><</span><span style="color: #a31515;">label</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> St.Thomas<span style="color: blue;"></</span><span style="color: #a31515;">label</span><span style="color: blue;">></span><span style="background: none repeat scroll 0% 0% yellow;"></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">br</span> <span style="color: blue;">/></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> <span style="color: blue;"><</span><span style="color: #a31515;">button</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> <span> <span> </span> Clear<span style="color: blue;"></</span><span style="color: #a31515;">button</span><span style="color: blue;">></</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span style="color: blue; line-height: 115%;"></</span><span style="color: #a31515; line-height: 115%;">html</span><span style="color: blue; line-height: 115%;">></span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span>All label will be visible on the page<span> </span>as shown below:</span></span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery Event function" src="http://www.mindstick.com/Articles/af5957f6-7c75-4d69-8803-13f0fee3d01f/Images/image005.jpg" title="JQuery Event function" /></span></span> </div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> If I click on the <b>clear</b> button all label will hide from page as shown below:</span></span></div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><div class="MsoNormal"> <span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><img alt="JQuery Event function" src="http://www.mindstick.com/Articles/af5957f6-7c75-4d69-8803-13f0fee3d01f/Images/image006.jpg" title="JQuery Event function" /></span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><span disabled="disabled"><label for="ctl00_ctrlArticleComment_chkboxCommentEnable"></label></span></span></span></div></div>Pankaj Tiwarihttp://www.blogger.com/profile/01953469114545944131noreply@blogger.com0