<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5498269097239166924</id><updated>2026-07-24T11:28:26.118+05:30</updated><category term="JOB"/><category term="General"/><category term="Jokes"/><category term="Health"/><category term="Funny Mails"/><category term="Management"/><category term="INFO FOR USE"/><category term="Love"/><category term="Computer Article And Tips"/><category term="Thought_Provoking_Article"/><category term="Event"/><category term="Miscelleous"/><category term="Career"/><category term="Mobile_Info"/><category term="NGO And Info"/><category term="Help"/><category term="Politics"/><category term="BeautyProducts"/><category term="Cellnique"/><category term="Contest"/><title type='text'>Connect To All</title><subtitle type='html'>This blog contains information for all.&#xa;Ranging from current job openings to joke, funny mails, Word Of the Day, Motivational Quotes, Learning through video, programming examples, Games, Free Download and Information you can take home....</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>865</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-5943739381974554454</id><published>2013-02-27T13:50:00.001+05:30</published><updated>2013-02-27T13:50:12.306+05:30</updated><title type='text'>Job Openings in Chennai for .Net Developers ( 3 to 7 years )</title><content type='html'>Jobs for &amp;quot;.Net Developer&amp;#39;​s&amp;quot; in Chennai&amp;lt;&lt;a href=&quot;http://jobs.cambio.co.in/job/jobs-for-net-developers-in/3261221?snauth=86H0W5G97NZRG6UZWk+J0J+gDtOdl8JdC3hE80n5K/Tn185nj6BH5A==&quot;&gt;http://jobs.cambio.co.in/job/jobs-for-net-developers-in/3261221?snauth=86H0W5G97NZRG6UZWk+J0J+gDtOdl8JdC3hE80n5K/Tn185nj6BH5A==&lt;/a&gt;&amp;gt;&lt;br&gt;Experience: 3.0 - 7.0 years&lt;br&gt;Location: Chennai&lt;br&gt;&lt;br&gt;Hello,&lt;br&gt;&lt;br&gt;I have huge openings for &amp;quot;.Net Developer&amp;#39;s&amp;quot; Junior, Senior &amp;amp; Team lead position in Chennai for a MNC&lt;br&gt;&lt;br&gt;Requirement:&lt;br&gt;3 - 7 Years of experience&lt;br&gt;Experience in developing with Microsoft .NET Framework 3.0 (or higher), C# 3.0 (or higher) and &lt;a href=&quot;http://ASP.NET&quot;&gt;ASP.NET&lt;/a&gt; 3.0 (or higher)&lt;br&gt;Strong knowledge of object-oriented programming with a background in one of the following: C#, C++, Java&lt;br&gt;Strong knowledge of web technologies and standards, including HTML, CSS, JavaScript, jQuery, XML&lt;br&gt;Strong knowledge of Microsoft SQL Server and well-honed SQL skills; ability to create relational data models (ER Diagrams) strongly desired&lt;br&gt;&lt;br&gt;If interested, Please send me your updated cv to &lt;a href=&quot;mailto:karthik@cambio.co.in&quot;&gt;karthik@cambio.co.in&lt;/a&gt;&amp;lt;mailto:&lt;a href=&quot;mailto:karthik@cambio.co.in&quot;&gt;karthik@cambio.co.in&lt;/a&gt;&amp;gt;&lt;br&gt;In case of query, please contact me @ 080-40205626&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;Karthik&lt;br&gt;080-40205626&lt;br&gt;read more...&amp;lt;&lt;a href=&quot;http://jobs.cambio.co.in/job/jobs-for-net-developers-in/3261221?snauth=86H0W5G97NZRG6UZWk+J0J+gDtOdl8JdC3hE80n5K/Tn185nj6BH5A==&quot;&gt;http://jobs.cambio.co.in/job/jobs-for-net-developers-in/3261221?snauth=86H0W5G97NZRG6UZWk+J0J+gDtOdl8JdC3hE80n5K/Tn185nj6BH5A==&lt;/a&gt;&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/5943739381974554454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/5943739381974554454' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/5943739381974554454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/5943739381974554454'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2013/02/job-openings-in-chennai-for-net.html' title='Job Openings in Chennai for .Net Developers ( 3 to 7 years )'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-4331781863558425184</id><published>2012-10-05T11:41:00.001+05:30</published><updated>2012-10-05T11:41:35.713+05:30</updated><title type='text'>Windows: How To Find a User&#39;s Security Identifier (SID) in Windows</title><content type='html'>Reference: &lt;a href=&quot;http://pcsupport.about.com/od/registry/ht/find-user-security-identifier.htm&quot;&gt;http://pcsupport.about.com/od/registry/ht/find-user-security-identifier.htm&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;How To Find a User&amp;#39;s Security Identifier (SID) in Windows&lt;br&gt;&lt;br&gt;&lt;br&gt;There are many reasons why you might want to find the security identifier&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termss/g/security-identifier.htm&quot;&gt;http://pcsupport.about.com/od/termss/g/security-identifier.htm&lt;/a&gt;&amp;gt; (SID) for a particular user&amp;#39;s account in Windows but in my corner of the world, the common reason for doing so is to determine which key&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termss/g/registy_subkey.htm&quot;&gt;http://pcsupport.about.com/od/termss/g/registy_subkey.htm&lt;/a&gt;&amp;gt; under HKEY_USERS&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termshm/g/hkey_users.htm&quot;&gt;http://pcsupport.about.com/od/termshm/g/hkey_users.htm&lt;/a&gt;&amp;gt; in the Windows Registry&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termsr/p/registrywindows.htm&quot;&gt;http://pcsupport.about.com/od/termsr/p/registrywindows.htm&lt;/a&gt;&amp;gt; to look for user-specific registry data for.&lt;br&gt;Regardless of the reason for your need, matching SIDs to user names is really easy thanks to the wmic command, a command&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termsc/g/commands.htm&quot;&gt;http://pcsupport.about.com/od/termsc/g/commands.htm&lt;/a&gt;&amp;gt; available from the Command Prompt&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termsc/p/command-prompt.htm&quot;&gt;http://pcsupport.about.com/od/termsc/p/command-prompt.htm&lt;/a&gt;&amp;gt; in most versions of Windows.&lt;br&gt;Follow these easy steps to display a table of user names and their corresponding SIDs:&lt;br&gt;Note: See Tip #1 for instructions on matching a user name to an SID via the Windows Registry, an alternative to the wmic command method described below. The wmic command didn&amp;#39;t exist before Windows XP so you&amp;#39;ll have to use the registry method in those older versions of Windows.&lt;br&gt;Difficulty: Easy&lt;br&gt;Time Required: It&amp;#39;ll take less than a minute to find a user&amp;#39;s SID in Windows&lt;br&gt;Here&amp;#39;s How:&lt;br&gt;1.     Open Command Prompt.&lt;br&gt;2.     Once Command Prompt is open, type the following command&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termsc/g/commands.htm&quot;&gt;http://pcsupport.about.com/od/termsc/g/commands.htm&lt;/a&gt;&amp;gt; exactly as shown here, including spaces or lack thereof:&lt;br&gt;3.  wmic useraccount get name,sid&lt;br&gt;and then press Enter.&lt;br&gt;4.     You should see a table, similar to the following, displayed in the Command Prompt window:&lt;br&gt;5. Name            SID&lt;br&gt;6. Administrator   S-1-5-21-1180699209-877415012-3182924384-500&lt;br&gt;7. Guest           S-1-5-21-1180699209-877415012-3182924384-501&lt;br&gt;8. HomeGroupUser$  S-1-5-21-1180699209-877415012-3182924384-1002&lt;br&gt;9. Tim             S-1-5-21-1180699209-877415012-3182924384-1004&lt;br&gt;10.UpdatusUser     S-1-5-21-1180699209-877415012-3182924384-1007&lt;br&gt;This is a list of each user account in Windows, listed by user name, followed by the account&amp;#39;s corresponding SID.&lt;br&gt;11.  Now that you&amp;#39;re confident that a particular user name corresponds to a particular SID, you can make whatever changes you need to in the registry or do whatever else you needed this information for.&lt;br&gt;Tips:&lt;br&gt;1.     How To Find User&amp;#39;s SIDs in the Registry:&lt;br&gt;You can also determine a user&amp;#39;s SID by looking through the ProfileImagePath values&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termsv/g/registryvalue.htm&quot;&gt;http://pcsupport.about.com/od/termsv/g/registryvalue.htm&lt;/a&gt;&amp;gt; in each S-1-5-21 prefixed SID listed under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList key.&lt;br&gt;The ProfileImagePath value within each SID-named registry key lists the profile directory, which includes the user name.&lt;br&gt;For example, the ProfileImagePath value under the S-1-5-21-1180699209-877415012-3182924384-1004 key on my computer is C:\Users\Tim so I know that the SID for the user &amp;quot;Tim&amp;quot; is &amp;quot;S-1-5-21-1180699209-877415012-3182924384-1004&amp;quot;.&lt;br&gt;Note: This method of matching users to SIDs will only show those users who are logged in or have logged in and switched users. To continue to use the registry method for determining other user&amp;#39;s SIDs, you&amp;#39;ll need to log in as each user on the system and repeat these steps. This is a big drawback so, assuming you&amp;#39;re able, you&amp;#39;re much better off using the wmic command method above.&lt;br&gt;Related Articles&lt;br&gt;* HKEY_USERS (HKU)&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termshm/g/hkey_users.htm&quot;&gt;http://pcsupport.about.com/od/termshm/g/hkey_users.htm&lt;/a&gt;&amp;gt;&lt;br&gt;* Security Identifier Definition (SID)&amp;lt;&lt;a href=&quot;http://pcsupport.about.com/od/termss/g/security-identifier.htm&quot;&gt;http://pcsupport.about.com/od/termss/g/security-identifier.htm&lt;/a&gt;&amp;gt;&lt;br&gt;* Emacs Documentation - Find Init&amp;lt;&lt;a href=&quot;http://linux.about.com/od/emacs_doc/a/emacsdoc163.htm&quot;&gt;http://linux.about.com/od/emacs_doc/a/emacsdoc163.htm&lt;/a&gt;&amp;gt;&lt;br&gt;* write - Linux Command - Unix Command&amp;lt;&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl1_write.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl1_write.htm&lt;/a&gt;&amp;gt;&lt;br&gt;* Windows&amp;#39; Command Line Puts You in Control&amp;lt;&lt;a href=&quot;http://pcworld.about.com/magazine/2309p146id121786.htm&quot;&gt;http://pcworld.about.com/magazine/2309p146id121786.htm&lt;/a&gt;&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/4331781863558425184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/4331781863558425184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4331781863558425184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4331781863558425184'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/10/windows-how-to-find-users-security.html' title='Windows: How To Find a User&#39;s Security Identifier (SID) in Windows'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-2832554898735846311</id><published>2012-09-07T15:47:00.001+05:30</published><updated>2012-09-07T15:47:35.669+05:30</updated><title type='text'>SQL: Partition switching in SQL Server 2005</title><content type='html'>&lt;a href=&quot;http://www.techrepublic.com/blog/datacenter/partition-switching-in-sql-server-2005/143&quot;&gt;http://www.techrepublic.com/blog/datacenter/partition-switching-in-sql-server-2005/143&lt;/a&gt;&lt;br&gt;&lt;br&gt;Partition switching in SQL Server 2005&lt;br&gt;2Comments&amp;lt;&lt;a href=&quot;http://www.techrepublic.com/blog/datacenter/partition-switching-in-sql-server-2005/143#talkback&quot;&gt;http://www.techrepublic.com/blog/datacenter/partition-switching-in-sql-server-2005/143#talkback&lt;/a&gt;&amp;gt;&lt;br&gt;more +&lt;br&gt;&lt;br&gt; *   Email&lt;br&gt; *   Print&lt;br&gt; *   Add to Favorites&lt;br&gt; *   &lt;a href=&quot;http://Del.icio.us&quot;&gt;Del.icio.us&lt;/a&gt;&lt;br&gt; *   Digg&lt;br&gt; *   Hacker News&lt;br&gt; *   LinkedIn&lt;br&gt; *   Reddit&lt;br&gt; *   Technorati&lt;br&gt;By Tim Chapman&amp;lt;&lt;a href=&quot;http://www.techrepublic.com/search?q=tim+chapman&quot;&gt;http://www.techrepublic.com/search?q=tim+chapman&lt;/a&gt;&amp;gt;&lt;br&gt;July 23, 2007, 11:21 AM PDT&lt;br&gt;&lt;br&gt;Takeaway: Tim Chapman demonstrates how you can modify defined partitions in SQL Server 2005 so that you can easily and efficiently add new data.&lt;br&gt;&lt;br&gt;Last week, I showed how you can use the new table and index partitioning features in SQL Server 2005 to split your table data across one or more filegroups&amp;lt;&lt;a href=&quot;http://blogs.techrepublic.com.com/datacenter/?p=139&quot;&gt;http://blogs.techrepublic.com.com/datacenter/?p=139&lt;/a&gt;&amp;gt;. In this article, I demonstrate how you can modify those defined partitions so that you can easily and efficiently add new data.&lt;br&gt;&lt;br&gt;Partitioning&lt;br&gt;&lt;br&gt;Partitioning is the separation of database rows from one large table into one or more smaller tables. There can be performance and administrative advantages in using partitioning because you are essentially using one or more tables as one large table. These advantages can be even greater when you take into account the ability to easily add and delete data to and from your partitions.&lt;br&gt;&lt;br&gt;Partition switching&lt;br&gt;&lt;br&gt;Partition functions are used to map table field values to defined partitions. These partitions are initially defined when the function is created. However, it is sometimes necessary to change how your partitions are set up to accommodate new data, move current data, or delete data. Partition switching is the process of moving a block of data around in one or more tables.&lt;br&gt;&lt;br&gt;An example&lt;br&gt;One common use for partition is the archiving of data, such as moving data from your OLTP database to your data warehouse for reporting purposes. This example looks at the importing of MP3 product data into a SalesHistoryArchive table. For the purpose of this example, assume that a list of MP3Player product sales have been imported into the database and placed in a table named MP3Import.&lt;br&gt;&lt;br&gt;This example is built upon the partitioning example I illustrated in my article on creating table partitions in SQL Server 2005&amp;lt;&lt;a href=&quot;http://blogs.techrepublic.com.com/datacenter/?p=139&quot;&gt;http://blogs.techrepublic.com.com/datacenter/?p=139&lt;/a&gt;&amp;gt;. The following script recreates the objects I used in that article. These objects include the partition function, partition scheme, and the SalesHistoryArchive table.&lt;br&gt;&lt;br&gt;CREATE PARTITION FUNCTION [pf_Product_Partition](VARCHAR(10)) AS RANGE LEFT&lt;br&gt;&lt;br&gt; FOR VALUES (N&amp;#39;BigScreen&amp;#39;, N&amp;#39;Computer&amp;#39;, N&amp;#39;PoolTable&amp;#39;)&lt;br&gt;&lt;br&gt; Go&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; CREATE PARTITION SCHEME [ps_Product_Scheme] AS PARTITION [pf_Product_Partition]&lt;br&gt;&lt;br&gt; ALL TO ([PRIMARY])&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; IF OBJECT_ID(&amp;#39;SalesHistoryArchive&amp;#39;)&amp;gt;0&lt;br&gt;&lt;br&gt; DROP TABLE [SalesHistoryArchive];&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt; CREATE TABLE [dbo].[SalesHistoryArchive]&lt;br&gt;&lt;br&gt; (&lt;br&gt;&lt;br&gt;        [SaleID] [int] IDENTITY(1,1),&lt;br&gt;&lt;br&gt;        [Product] [varchar](10) NULL,&lt;br&gt;&lt;br&gt;        [SaleDate] [datetime] NULL,&lt;br&gt;&lt;br&gt;        [SalePrice] [money] NULL&lt;br&gt;&lt;br&gt; )ON [ps_Product_Scheme](Product)&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; DECLARE @i SMALLINT&lt;br&gt;&lt;br&gt; SET @i = 1&lt;br&gt;&lt;br&gt; WHILE (@i &amp;lt;=10000)&lt;br&gt;&lt;br&gt; BEGIN&lt;br&gt;&lt;br&gt;     INSERT INTO SalesHistoryArchive(Product, SaleDate, SalePrice)&lt;br&gt;&lt;br&gt;     VALUES(&amp;#39;Computer&amp;#39;, DATEADD(mm, @i, &amp;#39;3/11/1919&amp;#39;), DATEPART(ms, GETDATE()) + (@i + 57))&lt;br&gt;&lt;br&gt;     INSERT INTO SalesHistoryArchive(Product, SaleDate, SalePrice)&lt;br&gt;&lt;br&gt;     VALUES(&amp;#39;BigScreen&amp;#39;, DATEADD(mm, @i, &amp;#39;3/11/1927&amp;#39;), DATEPART(ms, GETDATE()) + (@i + 13))&lt;br&gt;&lt;br&gt;     INSERT INTO SalesHistoryArchive(Product, SaleDate, SalePrice)&lt;br&gt;&lt;br&gt;     VALUES(&amp;#39;PoolTable&amp;#39;, DATEADD(mm, @i, &amp;#39;3/11/1908&amp;#39;), DATEPART(ms, GETDATE()) + (@i + 29))&lt;br&gt;&lt;br&gt;     SET @i = @i + 1&lt;br&gt;&lt;br&gt; END&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt;Now that I have data to use for the example, I can dig into the details of the new product import. The MP3Player product records that I will be importing will be placed in the SalesHistoryArchive table. This table is currently partitioned, and I want the MP3Player product to be placed on its own partition. To accomplish this, I will need to alter the partition function that I use on the SalesHistoryArchive table.&lt;br&gt;&lt;br&gt;ALTER PARTITION FUNCTION [pf_Product_Partition] ()&lt;br&gt;&lt;br&gt; SPLIT RANGE (&amp;#39;MP3Player&amp;#39;)&lt;br&gt;&lt;br&gt;Run the following query to verify that a new partition has been added for the SalesHistoryArchive table:&lt;br&gt;&lt;br&gt;SELECT * From sys.partitions&lt;br&gt;&lt;br&gt; WHERE OBJECT_NAME(object_id) = &amp;#39;SalesHistoryArchive&amp;#39;&lt;br&gt;&lt;br&gt;At this point, data can be inserted directly into the SalesHistory archive table, and any product of MP3Player will be placed in its own partition. However, data is inserted into the database from some type of external source and placed in its own individual database table. One great feature of partitioning in SQL Server 2005 is that it allows you to switch data from one table into another table very easily and quickly. It is so fast because the switching of the partition data only involves the changing of SQL Server&amp;#39;s internal metadata, so no data is actually moved. The script below creates the MP3Import table, which I will assume has been imported into the database from an external data source.&lt;br&gt;&lt;br&gt;CREATE TABLE [dbo].MP3Import&lt;br&gt;&lt;br&gt; (&lt;br&gt;&lt;br&gt;        [SaleID] [int] IDENTITY(1,1),&lt;br&gt;&lt;br&gt;        [Product] [varchar](10) NULL,&lt;br&gt;&lt;br&gt;        [SaleDate] [datetime] NULL,&lt;br&gt;&lt;br&gt;        [SalePrice] [money] NULL&lt;br&gt;&lt;br&gt; )ON [ps_Product_Scheme](Product)&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt; ALTER TABLE MP3Import&lt;br&gt;&lt;br&gt; ADD CONSTRAINT ck_Product CHECK(Product = &amp;#39;MP3Player&amp;#39;)&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt;There are a couple of specific things to notice in the script above. First, the table structure of the MP3Import table is the same as the SalesArchiveHistory table, and the MP3Import table uses the same partitioning scheme as the SalesHistoryArchive table. Using the same partitioning scheme isn&amp;#39;t really necessary to complete what I want to complete, but I think it makes it easier. Next, I am creating a check constraint on the table to ensure that only the MP3Player product is imported into the table. This will ensure that when I switch the data that all of the data goes into the exact partition that I want.&lt;br&gt;&lt;br&gt;The next step is to load some data into the import table:&lt;br&gt;&lt;br&gt;DECLARE @i SMALLINT&lt;br&gt;&lt;br&gt; SET @i = 1&lt;br&gt;&lt;br&gt; WHILE (@i &amp;lt;=10000)&lt;br&gt;&lt;br&gt; BEGIN&lt;br&gt;&lt;br&gt;     INSERT INTO MP3Import(Product, SaleDate, SalePrice)&lt;br&gt;&lt;br&gt;     VALUES(&amp;#39;MP3Player&amp;#39;, DATEADD(mm, @i, &amp;#39;3/11/1919&amp;#39;), DATEPART(ms, GETDATE()) + (@i + 57))&lt;br&gt;&lt;br&gt;     SET @i = @i + 1&lt;br&gt;&lt;br&gt; END&lt;br&gt;&lt;br&gt; GO&lt;br&gt;&lt;br&gt;I want to switch the data that is in the MP3Import table to the SalesHistoryArchive table. In previous versions of SQL Server, this would entail using an INSERT statement to add the data to the table. With SQL Server 2005, I can simply use the SWITCH statement to move the data pointers to point to the SalesHistoryArchive table. In the script below, I alter the MP3Import table and switch the data that resides in partition 3, where the data was initially inserted, to partition 3 on the SalesHistory archive table.&lt;br&gt;&lt;br&gt;ALTER TABLE MP3Import&lt;br&gt;&lt;br&gt; SWITCH PARTITION 3 TO SalesHistoryArchive PARTITION 3&lt;br&gt;&lt;br&gt;The following query shows that the SalesHistoryArchive table now contains 10000 records in partition 3. Because the data in the MP3Import table is no longer needed, I can simply issue a DROP command on the table to remove it from the database.&lt;br&gt;&lt;br&gt;DROP TABLE MP3Import&lt;br&gt;&lt;br&gt;Because I have associated the data pointers with the new partition in the SalesHistoryArchive table, I can safely remove the MP3Import table.&lt;br&gt;&lt;br&gt;To switch or not to switch&lt;br&gt;&lt;br&gt;This article explores one scenario where it is advantageous to use partitioning to easily add data to your partitoned tables. It is worth noting that data can be removed as easily as it is added when the full partition is involved. While partitioning is a great advantage when it is suitable, it is not appropriate for all circumstances. Only through testing and analysis can you determine if partitioning, and thus partitioning switching, can improve your overall database scenario.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/2832554898735846311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/2832554898735846311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2832554898735846311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2832554898735846311'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/09/sql-partition-switching-in-sql-server.html' title='SQL: Partition switching in SQL Server 2005'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-957897385396581701</id><published>2012-09-07T14:52:00.001+05:30</published><updated>2012-09-07T14:52:57.150+05:30</updated><title type='text'>Assign to a T-SQL variable from a CASE statement</title><content type='html'>References: &lt;a href=&quot;http://stackoverflow.com/questions/6945979/assign-to-a-t-sql-variable-from-a-case-statement&quot;&gt;http://stackoverflow.com/questions/6945979/assign-to-a-t-sql-variable-from-a-case-statement&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;The example you&amp;#39;ve given should work. You can assign to variables from a case statement. Just pretend that the entire CASE..WHEN..THEN..ELSE..END block is a field. Here is a generic example:&lt;br&gt;&lt;br&gt;&lt;br&gt;declare&lt;br&gt;  @string1 nvarchar(100) = null&lt;br&gt; ,@string2 nvarchar(100) = null&lt;br&gt; ;&lt;br&gt;&lt;br&gt;select top 1&lt;br&gt;  @string1 = case when 1=1 then &amp;#39;yes&amp;#39; else &amp;#39;no&amp;#39; end&lt;br&gt; ,@string2 = case when 1=0 then &amp;#39;yes&amp;#39; else &amp;#39;no&amp;#39; end&lt;br&gt;&lt;br&gt;print &amp;#39;string1 = &amp;#39; + @string1&lt;br&gt;print &amp;#39;string2 = &amp;#39; + @string2&lt;br&gt;Gives:&lt;br&gt;string1 = yes&lt;br&gt;string2 = no</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/957897385396581701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/957897385396581701' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/957897385396581701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/957897385396581701'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/09/assign-to-t-sql-variable-from-case.html' title='Assign to a T-SQL variable from a CASE statement'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-3938022482948317556</id><published>2012-09-07T11:39:00.001+05:30</published><updated>2012-09-07T11:39:49.709+05:30</updated><title type='text'>SQL Partitioning (Horizontal &amp; Vertical )</title><content type='html'>References:  &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms178148(v=sql.105).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms178148(v=sql.105).aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Partitioning&lt;br&gt;&lt;br&gt;Partitioning a database improves performance and simplifies maintenance. By splitting a large table into smaller, individual tables, queries that access only a fraction of the data can run faster because there is less data to scan. Maintenance tasks, such as rebuilding indexes or backing up a table, can run more quickly.&lt;br&gt;&lt;br&gt;Partitioning can be achieved without splitting tables by physically putting tables on individual disk drives. Putting a table on one physical drive and related tables on a separate drive can improve query performance because, when queries that involve joins between the tables are run, multiple disk heads read data at the same time. SQL Server filegroups can be used to specify on which disks to put the tables.&lt;br&gt;Hardware Partitioning&amp;lt;javascript:void(0)&amp;gt;&lt;br&gt;________________________________&lt;br&gt;&lt;br&gt;Hardware partitioning designs the database to take advantage of the available hardware architecture. Following are examples of hardware partitioning:&lt;br&gt;&lt;br&gt;*         Multiprocessors that enable multiple threads of operations, permitting many queries to run at the same time. Alternatively, a single query may be able to run faster on multiple processors by letting components of the query run at the same time. For example, each table referenced in the query can be scanned at the same time by a different thread.&lt;br&gt;&lt;br&gt;*         RAID (redundant array of independent disks) devices that enable data to be striped across multiple disk drives, permitting faster access to the data, because more read and write heads read data at the same time. A table striped across multiple drives can typically be scanned faster than the same table stored on a single drive. Alternatively, storing tables on separate drives from related tables can significantly improve the performance of queries joining those tables. For more information, see RAID&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms184252(v=sql.105).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms184252(v=sql.105).aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;Horizontal Partitioning&amp;lt;javascript:void(0)&amp;gt;&lt;br&gt;________________________________&lt;br&gt;&lt;br&gt;Horizontal partitioning divides a table into multiple tables. Each table then contains the same number of columns, but fewer rows. For example, a table that contains 1 billion rows could be partitioned horizontally into 12 tables, with each smaller table representing one month of data for a specific year. Any queries requiring data for a specific month only reference the appropriate table.&lt;br&gt;&lt;br&gt;Determining how to partition the tables horizontally depends on how data is analyzed. You should partition the tables so that queries reference as few tables as possible. Otherwise, excessive UNION queries, used to merge the tables logically at query time, can affect performance. For more information about querying horizontally partitioned tables, see Scenarios for Using Views&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms188250(v=sql.105).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms188250(v=sql.105).aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;&lt;br&gt;Partitioning data horizontally based on age and use is common. For example, a table may contain data for the last five years, but only data from the current year is regularly accessed. In this case, you may consider partitioning the data into five tables, with each table containing data from only one year.&lt;br&gt;&lt;br&gt;For more information, see Partitioned Tables and Indexes&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms188706(v=sql.105).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms188706(v=sql.105).aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;Vertical Partitioning&amp;lt;javascript:void(0)&amp;gt;&lt;br&gt;________________________________&lt;br&gt;&lt;br&gt;Vertical partitioning divides a table into multiple tables that contain fewer columns. The two types of vertical partitioning are normalization and row splitting:&lt;br&gt;&lt;br&gt;*         Normalization is the standard database process of removing redundant columns from a table and putting them in secondary tables that are linked to the primary table by primary key and foreign key relationships.&lt;br&gt;&lt;br&gt;*         Row splitting divides the original table vertically into tables with fewer columns. Each logical row in a split table matches the same logical row in the other tables as identified by a UNIQUE KEY column that is identical in all of the partitioned tables. For example, joining the row with ID 712 from each split table re-creates the original row.&lt;br&gt;&lt;br&gt;Like horizontal partitioning, vertical partitioning lets queries scan less data. This increases query performance. For example, a table that contains seven columns of which only the first four are generally referenced may benefit from splitting the last three columns into a separate table.&lt;br&gt;&lt;br&gt;Vertical partitioning should be considered carefully, because analyzing data from multiple partitions requires queries that join the tables. Vertical partitioning also could affect performance if partitions are very large.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/3938022482948317556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/3938022482948317556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3938022482948317556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3938022482948317556'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/09/sql-partitioning-horizontal-vertical.html' title='SQL Partitioning (Horizontal &amp; Vertical )'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-3840666042521879500</id><published>2012-09-05T18:59:00.001+05:30</published><updated>2012-09-05T18:59:43.251+05:30</updated><title type='text'>SQL: How to Truncate Log File in SQL Server 2005</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYMgbXetHr8pHImwwKHy-L4pEzf-Ft2lkYbHGRz_fK3V2U_juAa9XGXpyhP38coi-vPDxxdUpfM_NSd9E8zjM0RkQA9mhIjNOt3fuFJ9IupDxQOPudvIt7ebHmVyE8I3_7HGCFMLJ3b8i_/s1600/image001-783251.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYMgbXetHr8pHImwwKHy-L4pEzf-Ft2lkYbHGRz_fK3V2U_juAa9XGXpyhP38coi-vPDxxdUpfM_NSd9E8zjM0RkQA9mhIjNOt3fuFJ9IupDxQOPudvIt7ebHmVyE8I3_7HGCFMLJ3b8i_/s320/image001-783251.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784684364115392866&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/14400/How-to-Truncate-Log-File-in-SQL-Server-2005&quot;&gt;http://www.codeproject.com/Articles/14400/How-to-Truncate-Log-File-in-SQL-Server-2005&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;How to Truncate Log File in SQL Server 2005&lt;br&gt;&lt;br&gt;[cid:image001.jpg@01CD8B98.8F2B1E70]&lt;br&gt;Introduction&lt;br&gt;SQL Server 2005 is quite different from SQL Server 2000. To truncate log file is one thing which is different from SQL Server 2000. In SQL Server 2000, you just use Shrink to whatever file size you like. In SQL Server 2005, sometimes I cannot shrink the log file at all.&lt;br&gt;Here I want to describe some tricks to truncate log file for a database in SQL Server 2005. The work environment is Microsoft SQL Server Management Studio.&lt;br&gt;I. Shrink the Log File Size at the Right Time&lt;br&gt;I found out this trick:&lt;br&gt;Immediately after I use the SSIS package or Import the data to the database (highlight the database-&amp;gt;Tasks-&amp;gt;Import data ...), or Export the data from the database (highlight the database-&amp;gt;Tasks-&amp;gt;Export data ...), I can shrink the log file to the desired size, for example, 1MB. That is, highlight the database-&amp;gt;Tasks-&amp;gt;Shrink-&amp;gt;Files , set the file size, say, 1MB.&lt;br&gt;Then, click OK and you are done.&lt;br&gt;II. Eliminate the Log File Completely&lt;br&gt;Sometimes, we just do not need the big log file. For example, I have a 40GB log file. I am sure I do not need this log file and want to get rid of it completely to free up the hard drive space. The logic is:&lt;br&gt;&lt;br&gt; 1.  Detach the database&lt;br&gt; 2.  Rename the log file&lt;br&gt; 3.  Attach the database without the log file&lt;br&gt; 4.  Delete the log file&lt;br&gt;Let&amp;#39;s say, the database name is testDev. In the SQL Server Management Studio,&lt;br&gt;&lt;br&gt; 1.  Highlight the database-&amp;gt; Tasks-&amp;gt;Detach..-&amp;gt; Click OK&lt;br&gt; 2.  Go to log file folder -&amp;gt; rename the testDev_log.ldf to be like testDev_log-aa.ldf&lt;br&gt; 3.  Highlight Databases-&amp;gt;Attach...-&amp;gt; Click Add -&amp;gt; add the database testDev, highlight the log file and click the &amp;#39;Remove&amp;#39; button. This means you only attach testDev.mdf&lt;br&gt; 4.  After this is done, you can verify the contents of the attached database and then delete the log file&lt;br&gt;This way we can safely delete the log file and free up the space.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/3840666042521879500/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/3840666042521879500' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3840666042521879500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3840666042521879500'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/09/sql-how-to-truncate-log-file-in-sql.html' title='SQL: How to Truncate Log File in SQL Server 2005'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYMgbXetHr8pHImwwKHy-L4pEzf-Ft2lkYbHGRz_fK3V2U_juAa9XGXpyhP38coi-vPDxxdUpfM_NSd9E8zjM0RkQA9mhIjNOt3fuFJ9IupDxQOPudvIt7ebHmVyE8I3_7HGCFMLJ3b8i_/s72-c/image001-783251.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-4077815173065715687</id><published>2012-09-05T12:30:00.000+05:30</published><updated>2012-09-05T12:31:02.213+05:30</updated><title type='text'>SQL : Row_Number() to delete duplicate records</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLH0mSB0wL-HQ-KlSaMg59tXVljNQSrGJ1DeUU5yrQFv4dk0KB1mPc9rwmjZmyc-rnuGn4JVvrAXip7cfhl4y_dSvcdHqoUZpeVJkcA4I2APCxaI8ulH66RfAvlJL6A8K_tZmFpb77Eijs/s1600/image001-762214.gif&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLH0mSB0wL-HQ-KlSaMg59tXVljNQSrGJ1DeUU5yrQFv4dk0KB1mPc9rwmjZmyc-rnuGn4JVvrAXip7cfhl4y_dSvcdHqoUZpeVJkcA4I2APCxaI8ulH66RfAvlJL6A8K_tZmFpb77Eijs/s320/image001-762214.gif&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784584200562901234&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3577481/RowNumber-function-in-SQL-Server-2005-150-Part-II.htm&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/3577481/RowNumber-function-in-SQL-Server-2005-150-Part-II.htm&lt;/a&gt;&lt;br&gt;Row_Number() function in SQL Server 2005 - Part II&lt;br&gt;&lt;br&gt;By Muthusamy Anantha Kumar aka The MAK&amp;lt;&lt;a href=&quot;http://www.databasejournal.com/feedback.php/http:/www.databasejournal.com/features/mssql/article.php/3577481/RowNumber-function-in-SQL-Server-2005-150-Part-II.htm&quot;&gt;http://www.databasejournal.com/feedback.php/http:/www.databasejournal.com/features/mssql/article.php/3577481/RowNumber-function-in-SQL-Server-2005-150-Part-II.htm&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;In part I&amp;lt;&lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3572301&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/3572301&lt;/a&gt;&amp;gt; of this article, we saw how to generate row numbers and delete a simple single duplicate row. This article walks you through how to delete multiple duplicate rows. This article uses the new feature Row_Number() function, common table expression and the ANSI co-related subquery.&lt;br&gt;&lt;br&gt;Let us assume we have the following table, Mytable, in the database MyDB. Let us create the database MyDB and MyTable by using the following script.&lt;br&gt;&lt;br&gt;USE [MASTER]&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;IF  EXISTS&lt;br&gt;&lt;br&gt;  [cid:image001.gif@01CD8B62.46AF4580] (SELECT NAME FROM SYS.DATABASES&lt;br&gt;&lt;br&gt;   [cid:image001.gif@01CD8B62.46AF4580] WHERE NAME = N&amp;#39;MYDB&amp;#39;)&lt;br&gt;&lt;br&gt;DROP DATABASE [MYDB]&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;CREATE DATABASE MYDB&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;USE [MYDB]&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;IF  EXISTS&lt;br&gt;&lt;br&gt;  [cid:image001.gif@01CD8B62.46AF4580] (SELECT * FROM SYS.OBJECTS&lt;br&gt;&lt;br&gt;  [cid:image001.gif@01CD8B62.46AF4580] WHERE OBJECT_ID =&lt;br&gt;&lt;br&gt;    [cid:image001.gif@01CD8B62.46AF4580] OBJECT_ID(N&amp;#39;[DBO].[MYTABLE]&amp;#39;)&lt;br&gt;&lt;br&gt;  [cid:image001.gif@01CD8B62.46AF4580] AND TYPE IN (N&amp;#39;U&amp;#39;))&lt;br&gt;&lt;br&gt;DROP TABLE [DBO].[MYTABLE]&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;CREATE TABLE MYTABLE&lt;br&gt;&lt;br&gt;  [cid:image001.gif@01CD8B62.46AF4580] (ID INT, FNAME VARCHAR(50),&lt;br&gt;&lt;br&gt;  [cid:image001.gif@01CD8B62.46AF4580] LNAME VARCHAR(50))&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;insert into mytable select 1,&amp;#39;Jen&amp;#39;,&amp;#39;Ambelang&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 11,&amp;#39;Jiong&amp;#39;,&amp;#39;Hong&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 25,&amp;#39;Sandra&amp;#39;,&amp;#39;Mator&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 35,&amp;#39;Chun&amp;#39;,&amp;#39;Chang&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 21,&amp;#39;Yuki&amp;#39;,&amp;#39;Fukushima&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 1,&amp;#39;Jen&amp;#39;,&amp;#39;Ambelang&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 1,&amp;#39;Jen&amp;#39;,&amp;#39;Ambelang&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 25,&amp;#39;Sandra&amp;#39;,&amp;#39;Mator&amp;#39;&lt;br&gt;&lt;br&gt;insert into mytable select 25,&amp;#39;Sandra&amp;#39;,&amp;#39;Mator&amp;#39;&lt;br&gt;&lt;br&gt;go&lt;br&gt;&lt;br&gt;Let us query all the rows from the table MyTable using the following Select query.&lt;br&gt;&lt;br&gt;SELECT * FROM MYTABLE ORDER BY ID&lt;br&gt;&lt;br&gt;This query displays the following results.&lt;br&gt;&lt;br&gt;Related Articles&lt;br&gt;&lt;br&gt; *   Row_Number() function in SQL Server 2005&amp;lt;&lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3572301/RowNumber-function-in-SQL-Server-2005.htm&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/3572301/RowNumber-function-in-SQL-Server-2005.htm&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;11&lt;br&gt;&lt;br&gt;&lt;br&gt;Jiong&lt;br&gt;&lt;br&gt;&lt;br&gt;Hong&lt;br&gt;&lt;br&gt;&lt;br&gt;21&lt;br&gt;&lt;br&gt;&lt;br&gt;Yuki&lt;br&gt;&lt;br&gt;&lt;br&gt;Fukushima&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;35&lt;br&gt;&lt;br&gt;&lt;br&gt;Chun&lt;br&gt;&lt;br&gt;&lt;br&gt;Chang&lt;br&gt;&lt;br&gt;&lt;br&gt;From the results, it is very clear that we have duplicate rows: 1, Jen, Ambelang and 25, Sandra, Mator.&lt;br&gt;&lt;br&gt;Step 1&lt;br&gt;&lt;br&gt;The first step in deleting duplicate rows is to generate a unique row id for the entire table. This can be done using the Row_Number() function.&lt;br&gt;&lt;br&gt;Let us generate the unique numbers by executing the following query:&lt;br&gt;&lt;br&gt;SELECT ROW_NUMBER() OVER (ORDER BY ID) AS ROW,&lt;br&gt;&lt;br&gt;ID,LNAME,FNAME FROM MYTABLE&lt;br&gt;&lt;br&gt;This query produces the following results.&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;2&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;3&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;4&lt;br&gt;&lt;br&gt;&lt;br&gt;11&lt;br&gt;&lt;br&gt;&lt;br&gt;Hong&lt;br&gt;&lt;br&gt;&lt;br&gt;Jiong&lt;br&gt;&lt;br&gt;&lt;br&gt;5&lt;br&gt;&lt;br&gt;&lt;br&gt;21&lt;br&gt;&lt;br&gt;&lt;br&gt;Fukushima&lt;br&gt;&lt;br&gt;&lt;br&gt;Yuki&lt;br&gt;&lt;br&gt;&lt;br&gt;6&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;7&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;8&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;9&lt;br&gt;&lt;br&gt;&lt;br&gt;35&lt;br&gt;&lt;br&gt;&lt;br&gt;Chang&lt;br&gt;&lt;br&gt;&lt;br&gt;Chun&lt;br&gt;&lt;br&gt;&lt;br&gt;Step 2&lt;br&gt;&lt;br&gt;The second step in deleting duplicate rows is to generate unique row ids for every group.&lt;br&gt;&lt;br&gt;Now, by using a co-related sub-query we can produce unique row ids for each group.&lt;br&gt;&lt;br&gt;SELECT ROW,GROUPROW= CASE WHEN ID=ID&lt;br&gt;&lt;br&gt;THEN&lt;br&gt;&lt;br&gt;(SELECT COUNT(*) FROM (SELECT ROW_NUMBER() OVER (ORDER BY ID) AS ROW,&lt;br&gt;&lt;br&gt;ID,LNAME,FNAME FROM MYTABLE&lt;br&gt;&lt;br&gt;) AS A WHERE &lt;a href=&quot;http://A.ID&quot;&gt;A.ID&lt;/a&gt;=&lt;a href=&quot;http://B.ID&quot;&gt;B.ID&lt;/a&gt; AND&lt;br&gt;&lt;br&gt;A.ROW&amp;lt;B.ROW)+1 END,ID,FNAME,LNAME FROM (SELECT ROW_NUMBER() OVER (ORDER&lt;br&gt;&lt;br&gt;BY ID) AS ROW,&lt;br&gt;&lt;br&gt;ID,LNAME,FNAME FROM MYTABLE&lt;br&gt;&lt;br&gt;)AS B&lt;br&gt;&lt;br&gt;This query would produce the following results with a unique id for each group.&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;2&lt;br&gt;&lt;br&gt;&lt;br&gt;2&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;3&lt;br&gt;&lt;br&gt;&lt;br&gt;3&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;4&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;11&lt;br&gt;&lt;br&gt;&lt;br&gt;Jiong&lt;br&gt;&lt;br&gt;&lt;br&gt;Hong&lt;br&gt;&lt;br&gt;&lt;br&gt;5&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;21&lt;br&gt;&lt;br&gt;&lt;br&gt;Yuki&lt;br&gt;&lt;br&gt;&lt;br&gt;Fukushima&lt;br&gt;&lt;br&gt;&lt;br&gt;6&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;7&lt;br&gt;&lt;br&gt;&lt;br&gt;2&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;8&lt;br&gt;&lt;br&gt;&lt;br&gt;3&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;9&lt;br&gt;&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;35&lt;br&gt;&lt;br&gt;&lt;br&gt;Chun&lt;br&gt;&lt;br&gt;&lt;br&gt;Chang&lt;br&gt;&lt;br&gt;&lt;br&gt;Step 3&lt;br&gt;&lt;br&gt;The last step in deleting duplicate rows is to use the common table expression, as shown below.&lt;br&gt;&lt;br&gt;WITH DUPLICATE(ROW,GROUPROW,ID,FNAME,LNAME)&lt;br&gt;&lt;br&gt;AS&lt;br&gt;&lt;br&gt;(&lt;br&gt;&lt;br&gt;SELECT ROW,GROUPROW= CASE WHEN ID=ID&lt;br&gt;&lt;br&gt;THEN&lt;br&gt;&lt;br&gt;(SELECT COUNT(*) FROM (SELECT ROW_NUMBER() OVER (ORDER BY ID) AS ROW,&lt;br&gt;&lt;br&gt;ID,LNAME,FNAME FROM MYTABLE&lt;br&gt;&lt;br&gt;) AS A WHERE &lt;a href=&quot;http://A.ID&quot;&gt;A.ID&lt;/a&gt;=&lt;a href=&quot;http://B.ID&quot;&gt;B.ID&lt;/a&gt; AND&lt;br&gt;&lt;br&gt;A.ROW&amp;lt;B.ROW)+1 END,ID,FNAME,LNAME FROM (SELECT ROW_NUMBER() OVER (ORDER&lt;br&gt;&lt;br&gt;BY ID) AS ROW,&lt;br&gt;&lt;br&gt;ID,LNAME,FNAME FROM MYTABLE&lt;br&gt;&lt;br&gt;)AS B&lt;br&gt;&lt;br&gt;)&lt;br&gt;&lt;br&gt;DELETE FROM DUPLICATE WHERE GROUPROW&amp;lt;&amp;gt;1&lt;br&gt;&lt;br&gt;Let us query all the rows from the source table, Mytable, by using the following Select Query.&lt;br&gt;&lt;br&gt;SELECT * FROM MYTABLE ORDER BY ID&lt;br&gt;&lt;br&gt;This query displays the following results:&lt;br&gt;&lt;br&gt;1&lt;br&gt;&lt;br&gt;&lt;br&gt;Jen&lt;br&gt;&lt;br&gt;&lt;br&gt;Ambelang&lt;br&gt;&lt;br&gt;&lt;br&gt;11&lt;br&gt;&lt;br&gt;&lt;br&gt;Jiong&lt;br&gt;&lt;br&gt;&lt;br&gt;Hong&lt;br&gt;&lt;br&gt;&lt;br&gt;21&lt;br&gt;&lt;br&gt;&lt;br&gt;Yuki&lt;br&gt;&lt;br&gt;&lt;br&gt;Fukushima&lt;br&gt;&lt;br&gt;&lt;br&gt;25&lt;br&gt;&lt;br&gt;&lt;br&gt;Sandra&lt;br&gt;&lt;br&gt;&lt;br&gt;Mator&lt;br&gt;&lt;br&gt;&lt;br&gt;35&lt;br&gt;&lt;br&gt;&lt;br&gt;Chun&lt;br&gt;&lt;br&gt;&lt;br&gt;Chang&lt;br&gt;&lt;br&gt;&lt;br&gt;From the results, it is clear that duplicates from the table, Mytable, have been removed.&lt;br&gt;&lt;br&gt;Conclusion&lt;br&gt;&lt;br&gt;The main intent of this article was to demonstrate the use of SQL Server 2005&amp;#39;s new feature Row_number() function and Common Table Expression, with the help of co-related sub-query, to delete duplicate rows.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/4077815173065715687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/4077815173065715687' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4077815173065715687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4077815173065715687'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/09/sql-rownumber-to-delete-duplicate.html' title='SQL : Row_Number() to delete duplicate records'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLH0mSB0wL-HQ-KlSaMg59tXVljNQSrGJ1DeUU5yrQFv4dk0KB1mPc9rwmjZmyc-rnuGn4JVvrAXip7cfhl4y_dSvcdHqoUZpeVJkcA4I2APCxaI8ulH66RfAvlJL6A8K_tZmFpb77Eijs/s72-c/image001-762214.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-1904469663773448479</id><published>2012-09-04T18:29:00.001+05:30</published><updated>2012-09-04T18:29:24.409+05:30</updated><title type='text'>SQL: Data partitioning in SQL Server 2005 - Part V (nice example)</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheHakEtQ8deuR31DjsUNK_4lNhvafu_dN4S6NPl0EzniQZ7aENC6PoE7hgOGfQXOT8GAExbRXP3tU1_LfU404zDCbqTNXmFePKK5RQyozd_2J5DlyXNFJF3NXTLB7xGuUUILTrLqVLtrSf/s1600/image001-764409.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheHakEtQ8deuR31DjsUNK_4lNhvafu_dN4S6NPl0EzniQZ7aENC6PoE7hgOGfQXOT8GAExbRXP3tU1_LfU404zDCbqTNXmFePKK5RQyozd_2J5DlyXNFJF3NXTLB7xGuUUILTrLqVLtrSf/s320/image001-764409.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784305463103493954&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9IpPl0YnYCQAnFNMn974NAh4Q3cssgcEyEAGCLVQJzbqZ0d-lUqfFJtWEpxLYO3-gUYxkHJnlgFfcd8iZhh1yAPR-p_ES6GWJCw6zfvvA06ks0UnhBLiW776cDTiwemIoeASsoqmtQEjd/s1600/image002-767024.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9IpPl0YnYCQAnFNMn974NAh4Q3cssgcEyEAGCLVQJzbqZ0d-lUqfFJtWEpxLYO3-gUYxkHJnlgFfcd8iZhh1yAPR-p_ES6GWJCw6zfvvA06ks0UnhBLiW776cDTiwemIoeASsoqmtQEjd/s320/image002-767024.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784305476996990962&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD4_8QuAmGgwGnYNW_6wrcvXaaRDLv3fos4jKUXzeGtCYuazHgOOR4o42_BhVKp24qW_f_lMZ0EiXG6Zy1hUPciV0-ZlF2KOnb76Rs7oQFyxfc38OFa4VzRiKDmckaTWYlFIFPQOBOxPC8/s1600/image003-769318.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD4_8QuAmGgwGnYNW_6wrcvXaaRDLv3fos4jKUXzeGtCYuazHgOOR4o42_BhVKp24qW_f_lMZ0EiXG6Zy1hUPciV0-ZlF2KOnb76Rs7oQFyxfc38OFa4VzRiKDmckaTWYlFIFPQOBOxPC8/s320/image003-769318.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784305484521635362&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfLqGzlCNeTDzBcOXTBng79CXxAh6O1wHTVz2fbKiZeUeWew1vqghUkVI5Cd8n4d87RrPnFvFkG7RK9fu6gjn34G5cSuFLYx7zv7MCKmmojEEBs4wBlNQUXnTmOyrNVmWiMViVrDu6Rf9u/s1600/image004-770969.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfLqGzlCNeTDzBcOXTBng79CXxAh6O1wHTVz2fbKiZeUeWew1vqghUkVI5Cd8n4d87RrPnFvFkG7RK9fu6gjn34G5cSuFLYx7zv7MCKmmojEEBs4wBlNQUXnTmOyrNVmWiMViVrDu6Rf9u/s320/image004-770969.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784305494441517794&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZotbHPHV3AvcSTfG0uKpa9e-wqZ2HLI96brl3Hm_HPgw4ttKZuVT-bYDoRiIUEyaO8YzXwxleD70_dfU3vjXn9wYfbIpmlM_teqj-qjKp9CRZYtNoY5AJzUerDysQ_Nz9XIhmfbfSOzDz/s1600/image005-772965.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZotbHPHV3AvcSTfG0uKpa9e-wqZ2HLI96brl3Hm_HPgw4ttKZuVT-bYDoRiIUEyaO8YzXwxleD70_dfU3vjXn9wYfbIpmlM_teqj-qjKp9CRZYtNoY5AJzUerDysQ_Nz9XIhmfbfSOzDz/s320/image005-772965.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5784305503028898642&quot; /&gt;&lt;/a&gt;&lt;/p&gt;Reference:  &lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3647561/Data-partitioning-in-SQL-Server-2005---Part-V.htm&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/3647561/Data-partitioning-in-SQL-Server-2005---Part-V.htm&lt;/a&gt;&lt;br&gt;&lt;br&gt;Data partitioning in SQL Server 2005 - Part V&lt;br&gt;&lt;br&gt;&lt;br&gt;By Muthusamy Anantha Kumar aka The MAK&amp;lt;&lt;a href=&quot;http://www.databasejournal.com/feedback.php/http:/www.databasejournal.com/features/mssql/article.php/3647561/Data-partitioning-in-SQL-Server-2005---Part-V.htm&quot;&gt;http://www.databasejournal.com/feedback.php/http:/www.databasejournal.com/features/mssql/article.php/3647561/Data-partitioning-in-SQL-Server-2005---Part-V.htm&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;In Part IV&amp;lt;&lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/3647271&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/3647271&lt;/a&gt;&amp;gt; of this article series, we have seen how to partition an existing table based on certain range of dates.&lt;br&gt;&lt;br&gt;Part V illustrates how to merge and split existing partitions.&lt;br&gt;&lt;br&gt;First let us create a database with a table. Then let us insert data and then partition the table.&lt;br&gt;&lt;br&gt;Step 1&lt;br&gt;Let us assume we have created the folder, C:\Data2, and the following subfolders. [Refer Fig 1.0]&lt;br&gt;C:\Data2\Primary&lt;br&gt;C:\Data2\FG1&lt;br&gt;C:\Data2\FG2&lt;br&gt;C:\Data2\FG3&lt;br&gt;C:\Data2\FG4&lt;br&gt;[cid:image001.jpg@01CD8ACB.2C95A050]&lt;br&gt;Fig 1.0&lt;br&gt;Step 2&lt;br&gt;Let us assume that we have a database, Data Partition DB3, with five different file groups, as shown below.&lt;br&gt;use master&lt;br&gt;IF  EXISTS (SELECT name FROM sys.databases WHERE name = N&amp;#39;Data Partition DB5&amp;#39;)&lt;br&gt;DROP DATABASE [Data Partition DB5]&lt;br&gt;GO&lt;br&gt;CREATE DATABASE [Data Partition DB5]&lt;br&gt;      ON PRIMARY&lt;br&gt;       (NAME=&amp;#39;Data Partition DB5&amp;#39;,&lt;br&gt;        FILENAME=&lt;br&gt;          &amp;#39;C:\Data2\Primary\Data Partition DB5.mdf&amp;#39;,&lt;br&gt;        SIZE=5,&lt;br&gt;        MAXSIZE=500,&lt;br&gt;        FILEGROWTH=1 ),&lt;br&gt;      FILEGROUP [Data Partition DB5 FG1]&lt;br&gt;       (NAME = &amp;#39;Data Partition DB5 FG1&amp;#39;,&lt;br&gt;        FILENAME =&lt;br&gt;         &amp;#39;C:\Data2\FG1\Data Partition DB5 FG1.ndf&amp;#39;,&lt;br&gt;        SIZE = 5MB,&lt;br&gt;        MAXSIZE=500,&lt;br&gt;        FILEGROWTH=1 ),&lt;br&gt;      FILEGROUP [Data Partition DB5 FG2]&lt;br&gt;       (NAME = &amp;#39;Data Partition DB5 FG2&amp;#39;,&lt;br&gt;        FILENAME =&lt;br&gt;         &amp;#39;C:\Data2\FG2\Data Partition DB5 FG2.ndf&amp;#39;,&lt;br&gt;        SIZE = 5MB,&lt;br&gt;        MAXSIZE=500,&lt;br&gt;        FILEGROWTH=1 ),&lt;br&gt;      FILEGROUP [Data Partition DB5 FG3]&lt;br&gt;       (NAME = &amp;#39;Data Partition DB5 FG3&amp;#39;,&lt;br&gt;        FILENAME =&lt;br&gt;         &amp;#39;C:\Data2\FG3\Data Partition DB5 FG3.ndf&amp;#39;,&lt;br&gt;        SIZE = 5MB,&lt;br&gt;        MAXSIZE=500,&lt;br&gt;        FILEGROWTH=1 ),&lt;br&gt;      FILEGROUP [Data Partition DB5 FG4]&lt;br&gt;       (NAME = &amp;#39;Data Partition DB5 FG4&amp;#39;,&lt;br&gt;        FILENAME =&lt;br&gt;         &amp;#39;C:\Data2\FG4\Data Partition DB5 FG4.ndf&amp;#39;,&lt;br&gt;        SIZE = 5MB,&lt;br&gt;        MAXSIZE=500,&lt;br&gt;        FILEGROWTH=1 )&lt;br&gt;Step 3&lt;br&gt;Let us assume that we have a table on the primary file group. You could create that table by executing the following T-SQL statement.&lt;br&gt;USE [Data Partition DB5]&lt;br&gt;go&lt;br&gt;CREATE TABLE MyTable&lt;br&gt;       (ID INT NOT NULL,&lt;br&gt;        Date DATETIME,&lt;br&gt;        Cost money ) on [primary]&lt;br&gt;Step 4&lt;br&gt;Now let us create a unique clustered index on the table by executing the following T-SQL statement.&lt;br&gt;USE [Data Partition DB5]&lt;br&gt;go&lt;br&gt;CREATE UNIQUE CLUSTERED INDEX MyTable_IXC&lt;br&gt;       ON MyTable(ID) on [PRIMARY]&lt;br&gt;Step 5&lt;br&gt;Now let us insert some data onto the table, MyTable, using the following T-SQL statements.&lt;br&gt;USE [Data Partition DB5]&lt;br&gt;go&lt;br&gt;declare @count int&lt;br&gt;set @count =-25&lt;br&gt;while @count &amp;lt;=100&lt;br&gt;begin&lt;br&gt;insert into MyTable select @count,getdate(),100.00&lt;br&gt;set @count=@count+1&lt;br&gt;end&lt;br&gt;set @count =101&lt;br&gt;while @count &amp;lt;=200&lt;br&gt;begin&lt;br&gt;insert into MyTable select @count,getdate(),200.00&lt;br&gt;set @count=@count+1&lt;br&gt;end&lt;br&gt;set @count =201&lt;br&gt;while @count &amp;lt;=300&lt;br&gt;begin&lt;br&gt;insert into MyTable select @count,getdate(),300.00&lt;br&gt;set @count=@count+1&lt;br&gt;end&lt;br&gt;set @count =301&lt;br&gt;while @count &amp;lt;=400&lt;br&gt;begin&lt;br&gt;insert into MyTable select @count,getdate(),400.00&lt;br&gt;set @count=@count+1&lt;br&gt;end&lt;br&gt;set @count =401&lt;br&gt;while @count &amp;lt;=800&lt;br&gt;begin&lt;br&gt;insert into MyTable select @count,getdate(),500.00&lt;br&gt;set @count=@count+1&lt;br&gt;end&lt;br&gt;Let us query the table using the T-SQL statement shown below.&lt;br&gt;&lt;br&gt;select * from MyTable&lt;br&gt;&lt;br&gt;ID          Date                    Cost&lt;br&gt;&lt;br&gt;----------- ----------------------- ---------------------&lt;br&gt;&lt;br&gt;-25         2006-11-09 15:12:01.177 100.00&lt;br&gt;&lt;br&gt;-24         2006-11-09 15:12:01.207 100.00&lt;br&gt;&lt;br&gt;-23         2006-11-09 15:12:01.207 100.00&lt;br&gt;&lt;br&gt;-22         2006-11-09 15:12:01.223 100.00&lt;br&gt;&lt;br&gt;-21         2006-11-09 15:12:01.223 100.00&lt;br&gt;&lt;br&gt;-20         2006-11-09 15:12:01.223 100.00&lt;br&gt;&lt;br&gt;-19         2006-11-09 15:12:01.240 100.00&lt;br&gt;&lt;br&gt;.&lt;br&gt;&lt;br&gt;.&lt;br&gt;&lt;br&gt;.&lt;br&gt;&lt;br&gt;0           2006-11-09 15:12:01.347 100.00&lt;br&gt;&lt;br&gt;1           2006-11-09 15:12:01.347 100.00&lt;br&gt;&lt;br&gt;2           2006-11-09 15:12:01.363 100.00&lt;br&gt;&lt;br&gt;3           2006-11-09 15:12:01.363 100.00&lt;br&gt;&lt;br&gt;.&lt;br&gt;&lt;br&gt;.&lt;br&gt;&lt;br&gt;792         2006-11-09 15:12:06.270 500.00&lt;br&gt;&lt;br&gt;793         2006-11-09 15:12:06.270 500.00&lt;br&gt;&lt;br&gt;794         2006-11-09 15:12:06.287 500.00&lt;br&gt;&lt;br&gt;795         2006-11-09 15:12:06.287 500.00&lt;br&gt;&lt;br&gt;796         2006-11-09 15:12:06.287 500.00&lt;br&gt;&lt;br&gt;797         2006-11-09 15:12:06.300 500.00&lt;br&gt;&lt;br&gt;798         2006-11-09 15:12:06.300 500.00&lt;br&gt;&lt;br&gt;799         2006-11-09 15:12:06.317 500.00&lt;br&gt;&lt;br&gt;800         2006-11-09 15:12:06.317 500.00&lt;br&gt;&lt;br&gt;Now let us query the partition information of this table by executing the following query.&lt;br&gt;&lt;br&gt;select * from sys.partitions where object_name(object_id)=&amp;#39;MyTable&amp;#39;&lt;br&gt;&lt;br&gt;You can see the result as shown below [Refer Fig 1.1]. It is obvious that all of the 826 rows are in the same partition.&lt;br&gt;&lt;br&gt;[cid:image002.jpg@01CD8ACB.2C95A050]&lt;br&gt;Fig 1.1&lt;br&gt;&lt;br&gt;Step 6&lt;br&gt;&lt;br&gt;Partitioning of the tables depends on the partition range defined by Partition Function. Let us assume that we are going to partition the table into four parts, onto four different file groups.&lt;br&gt;&lt;br&gt;use [Data Partition DB5]&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;CREATE PARTITION FUNCTION [Data Partition Range](int)&lt;br&gt;&lt;br&gt;        AS RANGE LEFT FOR VALUES (100,200,300)&lt;br&gt;&lt;br&gt;When we use LEFT clause in the range, the first partition could hold values from negative infinity to 100, the second partition could hold values from 101 to 200, the third partition could hold values from 201 to 300 and the fourth partition could hold values from 301 to infinity or whatever the max range of the integer value.&lt;br&gt;&lt;br&gt;When we use RIGHT clause in the range, the first partition could hold values from negative infinity to 99, the second partition could hold values from 100 to 199, the third partition could hold values from 200 to 299 and the fourth partition could hold values from 300 to Infinity or whatever the max range of the integer value.&lt;br&gt;&lt;br&gt;Execute the following query to see the partition information.&lt;br&gt;&lt;br&gt;SELECT * FROM sys.partition_range_values&lt;br&gt;&lt;br&gt;Step 7&lt;br&gt;&lt;br&gt;Partition Function is not useful, unless it is associated with the proper file groups that we have created.&lt;br&gt;&lt;br&gt;Let us assume that we are going to use file group [Data Partition DB5 FG1], [Data Partition DB5 FG2], [Data Partition DB5 FG3], [Data Partition DB5 FG4] for the partition table that we are going to create. This can be created as shown below.&lt;br&gt;&lt;br&gt;USE [Data Partition DB5]&lt;br&gt;&lt;br&gt;go&lt;br&gt;&lt;br&gt;CREATE PARTITION SCHEME [Data Partition Scheme]&lt;br&gt;&lt;br&gt;        AS PARTITION [Data Partition Range]&lt;br&gt;&lt;br&gt;        TO ([Data Partition DB5 FG1], [Data Partition DB5 FG2], [Data Partition DB5 FG3],[Data Partition DB5 FG4]);&lt;br&gt;&lt;br&gt;Step 8&lt;br&gt;Now, let us move the table to the new partition by using the following TSQL command.&lt;br&gt;&lt;br&gt;Drop index MyTable_IXC on MyTable with (Move To [Data Partition Scheme] (ID) )&lt;br&gt;&lt;br&gt;Now, let us query the partition information by using the following query.&lt;br&gt;&lt;br&gt;select * from sys.partitions where object_name(object_id)=&amp;#39;MyTable&amp;#39;&lt;br&gt;&lt;br&gt;You can see the result as shown below [Refer Fig 1.2]. It is obvious that all of the 826 rows are spread across all four file groups, based on the partition range.&lt;br&gt;&lt;br&gt;[cid:image003.jpg@01CD8ACB.2C95A050]&lt;br&gt;Fig 1.2&lt;br&gt;&lt;br&gt;Now we have MyTable partitioned in to four different partitions. It is time to merge the first two partitions.&lt;br&gt;&lt;br&gt;Merge partition&lt;br&gt;&lt;br&gt;Execute the following T-SQL statement to merge the first two partitions together.&lt;br&gt;&lt;br&gt;Alter partition function [Data Partition Range]()&lt;br&gt;&lt;br&gt;merge range(100)&lt;br&gt;&lt;br&gt;Now, let us query the partition information by using the following query.&lt;br&gt;&lt;br&gt;select * from sys.partitions where object_name(object_id)=&amp;#39;MyTable&amp;#39;&lt;br&gt;&lt;br&gt;You will the see the following results showing the merge of partition number 1 and 2. [Refer Fig 1.3]&lt;br&gt;&lt;br&gt;[cid:image004.jpg@01CD8ACB.2C95A050]&lt;br&gt;Fig 1.3&lt;br&gt;&lt;br&gt;Split partition&lt;br&gt;&lt;br&gt;Execute the following T-SQL statement to split last partition into two partitions.&lt;br&gt;&lt;br&gt;Alter partition function [Data Partition Range]()&lt;br&gt;&lt;br&gt;split range(300)&lt;br&gt;&lt;br&gt;When executed you will get the following error.&lt;br&gt;&lt;br&gt;Msg 7707, Level 16, State 1, Line 1&lt;br&gt;&lt;br&gt;The associated partition function &amp;#39;Data Partition Range&amp;#39; generates&lt;br&gt;&lt;br&gt;more partitions than there are file groups mentioned in the scheme&lt;br&gt;&lt;br&gt;&amp;#39;Data Partition Scheme&amp;#39;.&lt;br&gt;&lt;br&gt;In order to avoid this, we have to add another file group to the database.&lt;br&gt;&lt;br&gt;Let us execute the below T-SQl statement, which will add a new file group to the database.&lt;br&gt;&lt;br&gt;Alter database [Data Partition DB5] add FILEGROUP [Data Partition DB5 FG5]&lt;br&gt;&lt;br&gt;go&lt;br&gt;&lt;br&gt;alter database [Data Partition DB5]&lt;br&gt;&lt;br&gt;ADD FILE&lt;br&gt;&lt;br&gt;       (NAME = &amp;#39;Data Partition DB5 FG5&amp;#39;,&lt;br&gt;&lt;br&gt;        FILENAME =&lt;br&gt;&lt;br&gt;         &amp;#39;C:\Data2\FG4\Data Partition DB5 FG5.ndf&amp;#39;,&lt;br&gt;&lt;br&gt;        SIZE = 5MB,&lt;br&gt;&lt;br&gt;        MAXSIZE=500,&lt;br&gt;&lt;br&gt;        FILEGROWTH=1 )&lt;br&gt;&lt;br&gt;TO FILEGROUP [Data Partition DB5 FG5]&lt;br&gt;&lt;br&gt;Go&lt;br&gt;&lt;br&gt;Now let us try again to split the partition range by executing the following T-SQL statement.&lt;br&gt;&lt;br&gt;Use [Data Partition DB5]&lt;br&gt;&lt;br&gt;go&lt;br&gt;&lt;br&gt;ALTER PARTITION SCHEME [Data Partition Scheme]&lt;br&gt;&lt;br&gt;NEXT USED [Data Partition DB5 FG5]&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;Alter partition function [Data Partition Range]()&lt;br&gt;&lt;br&gt;split range(500)&lt;br&gt;&lt;br&gt;Note: We should make SQL Server aware that it should use the next partition when it is splitting. The clause NEXT USED does that.&lt;br&gt;&lt;br&gt;Now, let us query the partition information by using the following query.&lt;br&gt;&lt;br&gt;select * from sys.partitions where object_name(object_id)=&amp;#39;MyTable&amp;#39;&lt;br&gt;&lt;br&gt;You will the see the following results showing the split of partition number 3. [Refer Fig 1.4]&lt;br&gt;&lt;br&gt;[cid:image005.jpg@01CD8ACB.2C95A050]&lt;br&gt;Fig 1.4&lt;br&gt;&lt;br&gt;You can see that any ID values between 300 and 500 are moved to partition 3 and any ID values more than 500 are moved to partition 4.&lt;br&gt;&lt;br&gt;Conclusion&lt;br&gt;&lt;br&gt;Part V of this article series has illustrated how to merge and split existing partitions.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/1904469663773448479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/1904469663773448479' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/1904469663773448479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/1904469663773448479'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/09/sql-data-partitioning-in-sql-server.html' title='SQL: Data partitioning in SQL Server 2005 - Part V (nice example)'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheHakEtQ8deuR31DjsUNK_4lNhvafu_dN4S6NPl0EzniQZ7aENC6PoE7hgOGfQXOT8GAExbRXP3tU1_LfU404zDCbqTNXmFePKK5RQyozd_2J5DlyXNFJF3NXTLB7xGuUUILTrLqVLtrSf/s72-c/image001-764409.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-7198134945843150498</id><published>2012-08-27T19:03:00.001+05:30</published><updated>2012-08-27T19:03:30.989+05:30</updated><title type='text'>Implementing Semaphore At Database Level (SQL Server)</title><content type='html'>Hi,&lt;br&gt;&lt;br&gt;   I am Bishnu Patro.&lt;br&gt;   Recently, I had an requirement to execute a particular stored proc certain number of times (it should be configurable depending upon the available Memory). The reason, is if the stored proc is executed certain number of times simultaneously, it used to take more time to execute since the all available memory is consumed and there is no free memory left. So, we decided to limit the number of parallel execution at the stored procedure level and it should be configurable. If it configured to run the stored proc simultaneouly to a maximum of 2. Then when the next request comes for execution of the stored proc, this request will wait for one of the execution to complete.&lt;br&gt;&lt;br&gt;I have implemented this by way of implementing customized semaphore at database level.&lt;br&gt;&lt;br&gt;I have created a table MultipleInstanceJobConfiguration, to keep track of the number of simultaneous execution of the stored proc.&lt;br&gt;&lt;br&gt;&lt;br&gt;CREATE TABLE [dbo].[MultipleInstanceJobConfiguration](&lt;br&gt;                [JobType] [nvarchar](50) NULL,&lt;br&gt;                [Total] [smallint] NULL,&lt;br&gt;                [Available] [smallint] NULL,&lt;br&gt;                [IsEnabled] [bit] NULL&lt;br&gt;) ON [PRIMARY]&lt;br&gt;&lt;br&gt;&lt;br&gt;Here, jobtype is the name of the stored proc.&lt;br&gt;         Total is the number of simultaneous execution of the stored proc.&lt;br&gt;         Available is at any point how many simultaneous execution available.&lt;br&gt;         IsEnabled is to whether you want to enable this feature or disable it.&lt;br&gt;&lt;br&gt;&lt;br&gt;The following statement inserts for a jobtype SI:&lt;br&gt;&lt;br&gt;INSERT INTO [dbo].[MultipleInstanceJobConfiguration]  ([JobType] ,[Total] ,[Available] ,[IsEnabled])  VALUES  (&amp;#39;SI&amp;#39;,2,2,1)&lt;br&gt;GO&lt;br&gt;&lt;br&gt;&lt;br&gt;The following stored proc is used to take a lock on an object:&lt;br&gt;&lt;br&gt;&lt;br&gt;CREATE Proc [dbo].[AcqLock]&lt;br&gt;@Resource_Name1 as nvarchar(255),&lt;br&gt;@Lock_Mode1 as nvarchar(32),&lt;br&gt;@Lock_TimeOut1 as int&lt;br&gt;As&lt;br&gt;&lt;br&gt;                                DECLARE @LockResult int&lt;br&gt;&lt;br&gt;                                EXECUTE @LockResult = sp_getapplock&lt;br&gt;                                @Resource    = @Resource_Name1,&lt;br&gt;                                @LockMode    = @Lock_Mode1,&lt;br&gt;                                @LockOwner = &amp;#39;Session&amp;#39;,&lt;br&gt;                                @LockTimeout = @Lock_TimeOut1&lt;br&gt;&lt;br&gt;&lt;br&gt;                                while( @LockResult &amp;lt;&amp;gt; 0)&lt;br&gt;                                BEGIN&lt;br&gt;                                WAITFOR DELAY &amp;#39;00:00:01&amp;#39;&lt;br&gt;                                EXECUTE @LockResult = sp_getapplock&lt;br&gt;                                @Resource    = @Resource_Name1,&lt;br&gt;                                @LockMode    = @Lock_Mode1,&lt;br&gt;                                @LockOwner = &amp;#39;Session&amp;#39;,&lt;br&gt;                                @LockTimeout = @Lock_TimeOut1&lt;br&gt;                                END&lt;br&gt;GO&lt;br&gt;&lt;br&gt;&lt;br&gt;The following stored proc is used to release a lock on an object:&lt;br&gt;&lt;br&gt;&lt;br&gt;CREATE Proc [dbo].[ReleseLock]&lt;br&gt;@Resource_Name1 as nvarchar(255)&lt;br&gt;As&lt;br&gt;EXECUTE sp_releaseapplock&lt;br&gt;                                                @Resource = @Resource_Name1, @LockOwner = &amp;#39;Session&amp;#39;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;&lt;br&gt;The following stored proc is an example implementing semphore:&lt;br&gt;&lt;br&gt;&lt;br&gt;CREATE PROC [dbo].[StoredProcUsingSemaphore]&lt;br&gt;AS&lt;br&gt;&lt;br&gt;                --Updating Configuation Available Count On Start of stored proc&lt;br&gt;                declare @total int&lt;br&gt;                declare @available int&lt;br&gt;                declare @isEnabled bit&lt;br&gt;                select @total = Total,@available = Available,@isEnabled = IsEnabled from dbo.MultipleInstanceJobConfiguration with (nolock) where JobType like &amp;#39;SI&amp;#39;&lt;br&gt;                WHILE(@total &amp;gt; 0 and @isEnabled = 1)&lt;br&gt;                BEGIN&lt;br&gt;                                if( @available &amp;gt; 0)&lt;br&gt;                                BEGIN&lt;br&gt;                                Begin Try&lt;br&gt;                                                EXEC dbo. AcqLock &amp;#39;MY_MULTIPLEINSTANCES&amp;#39;,&amp;#39;Exclusive&amp;#39;,0&lt;br&gt;                                                select @available = Available,@isEnabled = IsEnabled from dbo.MultipleInstanceJobConfiguration with (nolock) where JobType like &amp;#39;SI&amp;#39;&lt;br&gt;                                                if(@available &amp;gt; 0 and @isEnabled = 1)&lt;br&gt;                                                BEGIN&lt;br&gt;                                                                Update dbo.MultipleInstanceJobConfiguration&lt;br&gt;                                                                Set Available = Available - 1&lt;br&gt;                                                                where JobType like &amp;#39;SI&amp;#39;&lt;br&gt;&lt;br&gt;                                                                 INSERT INTO MetricsLoadProcessingLog VALUES (@loadID,&amp;#39;SI_Job_Configuration&amp;#39;,null ,1 ,&amp;#39;Decremented Available Count&amp;#39;,GETUTCDATE())&lt;br&gt;&lt;br&gt;                                                                 Exec dbo. ReleseLock &amp;#39;MY_MULTIPLEINSTANCES&amp;#39;&lt;br&gt;                                                                 BREAK&lt;br&gt;                                                END&lt;br&gt;                                End Try&lt;br&gt;                                Begin Catch&lt;br&gt;                                  Exec dbo. ReleseLock &amp;#39;MY_MULTIPLEINSTANCES&amp;#39;&lt;br&gt;                                End Catch&lt;br&gt;&lt;br&gt;                                END&lt;br&gt;                                WAITFOR DELAY &amp;#39;00:00:15&amp;#39;&lt;br&gt;                                select @available = Available,@isEnabled = IsEnabled from dbo.MultipleInstanceJobConfiguration with (nolock) where JobType like &amp;#39;SI&amp;#39;&lt;br&gt;&lt;br&gt;                END&lt;br&gt;&lt;br&gt;&lt;br&gt;                ----Your piece of code will go here.....&lt;br&gt;&lt;br&gt;&lt;br&gt;                -----Updating Available Count on Finish&lt;br&gt;                if(@total &amp;gt; 0 and @isEnabled = 1)&lt;br&gt;                BEGIN&lt;br&gt;                                EXEC dbo. AcqLock &amp;#39;MY_MULTIPLEINSTANCES &amp;#39;,&amp;#39;Exclusive&amp;#39;,0&lt;br&gt;&lt;br&gt;                                Update dbo.MultipleInstanceJobConfiguration&lt;br&gt;                                                Set Available = Available + 1&lt;br&gt;                                                where JobType like &amp;#39;SI&amp;#39; and Available &amp;lt; Total&lt;br&gt;&lt;br&gt;&lt;br&gt;                                Exec dbo. ReleseLock &amp;#39;MY_MULTIPLEINSTANCES&amp;#39;&lt;br&gt;                END&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;&lt;br&gt;Please let me know if the post was useful....</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/7198134945843150498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/7198134945843150498' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/7198134945843150498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/7198134945843150498'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/08/implementing-semaphore-at-database.html' title='Implementing Semaphore At Database Level (SQL Server)'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-965918429008138654</id><published>2012-08-16T14:15:00.001+05:30</published><updated>2012-08-16T14:15:47.421+05:30</updated><title type='text'>SQL: Tips For Lightning-Fast Insert Performance On SQL Server</title><content type='html'>&lt;a href=&quot;http://arnosoftwaredev.blogspot.in/2011/10/tips-for-lightning-fast-insert.html&quot;&gt;http://arnosoftwaredev.blogspot.in/2011/10/tips-for-lightning-fast-insert.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;Tips For Lightning-Fast Insert Performance On SQL Server&lt;br&gt;1. Increase &lt;a href=&quot;http://ADO.NET&quot;&gt;ADO.NET&lt;/a&gt; BatchSize to eliminate unnecessary network roundtrips, e.g. SqlDataAdapter.UpdateBatchSize&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/xw5z0hdd(v=VS.100).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/xw5z0hdd(v=VS.100).aspx&lt;/a&gt;&amp;gt; when working with DataAdapters, or SqlBulkCopy.BatchSize&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.batchsize.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.batchsize.aspx&lt;/a&gt;&amp;gt; when applying SqlBulkCopy.&lt;br&gt;&lt;br&gt;2. Limit the number of indices on the target table to what is really essential for query performance.&lt;br&gt;&lt;br&gt;3. Place indices on master table columns referenced by the target table&amp;#39;s foreign keys.&lt;br&gt;&lt;br&gt;4. Choose the target table&amp;#39;s clustered index wisely, so that inserts won&amp;#39;t lead to clustered index node splits. Usually an identity column (AKA &amp;quot;autoinc&amp;quot;) is a good choice. If you don&amp;#39;t have autoinc primary keys, consider introducing a new identity column just for the sake of making it your clustered index.&lt;br&gt;&lt;br&gt;5. Let the client insert into a temporary heap table first (that is, a table that has no clustered index, resp. no index at all). Then, issue one big &amp;quot;insert-into-select&amp;quot;&amp;lt;&lt;a href=&quot;http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/&quot;&gt;http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/&lt;/a&gt;&amp;gt; statement to push all that staging table data into the actual target table. The &amp;quot;insert-into-select&amp;quot;-statement must contain an &amp;quot;order-by&amp;quot;-clause which guarantees ordering by clustered index.&lt;br&gt;&lt;br&gt;6. Apply SqlBulkCopy&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;&lt;br&gt;7. Decrease transaction logging by choosing bulk-logged recovery model&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms189275.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms189275.aspx&lt;/a&gt;&amp;gt;, resp. setting SqlServer traceflag 610&amp;lt;&lt;a href=&quot;http://sqlserverplanet.com/sql-server-2008/sql-server-2008-minimally-logged-inserts/&quot;&gt;http://sqlserverplanet.com/sql-server-2008/sql-server-2008-minimally-logged-inserts/&lt;/a&gt;&amp;gt;.&lt;br&gt;&lt;br&gt;8. If your business scenario allows for it, place a table lock before inserting. This will make any further locking unnecessary, and is especially a viable option on staging tables as described in (5). SqlBulkCopy also supports table locks via SqlBulkCopyOptions&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopyoptions.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopyoptions.aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;&lt;br&gt;9. Place database datafile and logfile on two physically separated devices, e.g. on two disks or two SAN LUNs configured for different spindles.&lt;br&gt;&lt;br&gt;10. Prefer server-side processsing (e.g. by means of &amp;quot;insert-into-select&amp;quot;) to client-to-server-roundtrips wherever possible.&lt;br&gt;&lt;br&gt;11. This is probably the fastest insert-approach I have ever heard of (taken from this sqlbi whitepaper&amp;lt;&lt;a href=&quot;http://www.sqlbi.eu/LinkClick.aspx?fileticket=svahq1Mpp9A%3D&amp;amp;tabid=169&amp;amp;mid=375&quot;&gt;http://www.sqlbi.eu/LinkClick.aspx?fileticket=svahq1Mpp9A%3D&amp;amp;tabid=169&amp;amp;mid=375&lt;/a&gt;&amp;gt;, see final paragraph): Create a new heap table just for the current insert batch, SqlBulk-Copy data into that table, then create a suited clustered index on the table, and add the table as a new table partition to an existing partitioned table.&lt;br&gt;&lt;br&gt;12. Check execution plan when inserting, and go sure it does not contain anything unexpected or dispensable that might slow down your inserts, e.g. UDF-calls during check constraint execution, heavyweight trigger code, referential integrity checks without index usage or indexed view updates.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/965918429008138654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/965918429008138654' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/965918429008138654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/965918429008138654'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/08/sql-tips-for-lightning-fast-insert.html' title='SQL: Tips For Lightning-Fast Insert Performance On SQL Server'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-8033813965974712281</id><published>2012-08-09T11:00:00.001+05:30</published><updated>2012-08-09T11:00:27.035+05:30</updated><title type='text'>SQL Server 2005: Immediate Deadlock notifications (example)</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0c4uuZPMkgmZ9-lfhg5xZKKCzIbu9mfOoNqka4ABP2g80edltvVb5UvPmV_eiKZ1ZRE-jYm7ZLcmugtlWz3DPas8fgmvpAzBkiqHzGIVjggrwYOCjQPmNGhU28SHB3U6Huq5y_Lb6PLZY/s1600/image001-727036.png&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0c4uuZPMkgmZ9-lfhg5xZKKCzIbu9mfOoNqka4ABP2g80edltvVb5UvPmV_eiKZ1ZRE-jYm7ZLcmugtlWz3DPas8fgmvpAzBkiqHzGIVjggrwYOCjQPmNGhU28SHB3U6Huq5y_Lb6PLZY/s320/image001-727036.png&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5774541556930926210&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;a href=&quot;http://weblogs.sqlteam.com/mladenp/archive/2008/05/21/SQL-Server-2005-Immediate-Deadlock-notifications.aspx&quot;&gt;http://weblogs.sqlteam.com/mladenp/archive/2008/05/21/SQL-Server-2005-Immediate-Deadlock-notifications.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;SQL Server 2005: Immediate Deadlock notifications&amp;lt;&lt;a href=&quot;http://weblogs.sqlteam.com/mladenp/archive/2008/05/21/SQL-Server-2005-Immediate-Deadlock-notifications.aspx&quot;&gt;http://weblogs.sqlteam.com/mladenp/archive/2008/05/21/SQL-Server-2005-Immediate-Deadlock-notifications.aspx&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Deadlocks... huh??&lt;br&gt;Deadlocks can be a pain to debug since they&amp;#39;re so rare and unpredictable. The problem lies in repeating them in your dev environment. That&amp;#39;s why it&amp;#39;s crucial to have as much information about them from the production environment as possible.&lt;br&gt;There are two ways to monitor deadlocks, about which I&amp;#39;ll talk about in the future posts. Those are SQL Server tracing and Error log checking. Unfortunately both of them suffer from the same thing: you don&amp;#39;t know immediately when a deadlock occurs. Getting this info as soon as possible is sometimes crucial in production environments. Sure you can always set the trace flag 1222 on, but this still doesn&amp;#39;t solve the immediate notification problem.&lt;br&gt;One problem for some might be that this method is only truly useful if you limit data access to stored procedures. &amp;lt;joke&amp;gt; So all you ORM lovers stop reading since this doesn&amp;#39;t apply to you anymore! &amp;lt;/joke&amp;gt;&lt;br&gt;The other problem is that it requires a rewrite of the problematic stored procedures to support it. However since SQL Server 2005 came out my opinion is that every stored procedure should have the try ... catch block implemented. There&amp;#39;s no visible performance hit from this and the benefits can be huge. One of those benefits are the instant deadlocking notifications.&lt;br&gt;Needed &amp;quot;infrastructure&amp;quot;&lt;br&gt;So let&amp;#39;s see how it done. This must be implemented in the database you wish to monitor of course.&lt;br&gt;First we need a view that will get lock info about the deadlock that just happened. You can read why this type of query gives info we need in my previous post&amp;lt;&lt;a href=&quot;http://weblogs.sqlteam.com/mladenp/archive/2008/04/29/SQL-Server-2005-Get-full-information-about-transaction-locks.aspx&quot;&gt;http://weblogs.sqlteam.com/mladenp/archive/2008/04/29/SQL-Server-2005-Get-full-information-about-transaction-locks.aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;CREATE VIEW vLocks&lt;br&gt;AS&lt;br&gt;SELECT  L.request_session_id AS SPID,&lt;br&gt;        DB_NAME(L.resource_database_id) AS DatabaseName,&lt;br&gt;        O.Name AS LockedObjectName,&lt;br&gt;        P.object_id AS LockedObjectId,&lt;br&gt;        L.resource_type AS LockedResource,&lt;br&gt;        L.request_mode AS LockType,&lt;br&gt;        ST.text AS SqlStatementText,&lt;br&gt;        ES.login_name AS LoginName,&lt;br&gt;        ES.host_name AS HostName,&lt;br&gt;        TST.is_user_transaction AS IsUserTransaction,&lt;br&gt;        AT.name AS TransactionName&lt;br&gt;FROM    sys.dm_tran_locks L&lt;br&gt;        LEFT JOIN sys.partitions P ON P.hobt_id = L.resource_associated_entity_id&lt;br&gt;        LEFT JOIN sys.objects O ON O.object_id = P.object_id&lt;br&gt;        LEFT JOIN sys.dm_exec_sessions ES ON ES.session_id = L.request_session_id&lt;br&gt;        LEFT JOIN sys.dm_tran_session_transactions TST ON ES.session_id = TST.session_id&lt;br&gt;        LEFT JOIN sys.dm_tran_active_transactions AT ON TST.transaction_id = AT.transaction_id&lt;br&gt;        LEFT JOIN sys.dm_exec_requests ER ON AT.transaction_id = ER.transaction_id&lt;br&gt;        CROSS APPLY sys.dm_exec_sql_text(ER.sql_handle) AS ST&lt;br&gt;WHERE   resource_database_id = db_id()&lt;br&gt;GO&lt;br&gt;Next we have to create our stored procedure template:&lt;br&gt;CREATE PROC &amp;lt;ProcedureName&amp;gt;&lt;br&gt;AS&lt;br&gt;  BEGIN TRAN&lt;br&gt;    BEGIN TRY&lt;br&gt;&lt;br&gt;      &amp;lt;SPROC TEXT GOES HERE&amp;gt;&lt;br&gt;&lt;br&gt;    COMMIT&lt;br&gt;  END TRY&lt;br&gt;  BEGIN CATCH&lt;br&gt;    -- check transaction state&lt;br&gt;    IF XACT_STATE() = -1&lt;br&gt;    BEGIN&lt;br&gt;      DECLARE @message xml&lt;br&gt;      -- get our deadlock info FROM the VIEW&lt;br&gt;      SET @message = &amp;#39;&amp;lt;TransactionLocks&amp;gt;&amp;#39; + (SELECT * FROM vLocks ORDER BY SPID FOR XML PATH(&amp;#39;TransactionLock&amp;#39;)) + &amp;#39;&amp;lt;/TransactionLocks&amp;gt;&amp;#39;&lt;br&gt;&lt;br&gt;      -- issue ROLLBACK so we don&amp;#39;t ROLLBACK mail sending&lt;br&gt;      ROLLBACK&lt;br&gt;&lt;br&gt;      -- get our error message and number&lt;br&gt;      DECLARE @ErrorNumber INT, @ErrorMessage NVARCHAR(2048)&lt;br&gt;      SELECT @ErrorNumber = ERROR_NUMBER(), @ErrorMessage = ERROR_MESSAGE()&lt;br&gt;&lt;br&gt;      -- if it&amp;#39;s deadlock error send mail notification&lt;br&gt;      IF @ErrorNumber = 1205&lt;br&gt;      BEGIN&lt;br&gt;        DECLARE @MailBody NVARCHAR(max)&lt;br&gt;        -- create out mail body in the xml format. you can change this to your liking.&lt;br&gt;        SELECT  @MailBody = &amp;#39;&amp;lt;DeadlockNotification&amp;gt;&amp;#39;&lt;br&gt;                            +&lt;br&gt;                            (SELECT &amp;#39;Error number: &amp;#39; + isnull(CAST(@ErrorNumber AS VARCHAR(5)), &amp;#39;-1&amp;#39;) + CHAR(10) +&lt;br&gt;                                    &amp;#39;Error message: &amp;#39; + isnull(@ErrorMessage, &amp;#39; NO error message&amp;#39;) + CHAR(10)&lt;br&gt;                             FOR XML PATH(&amp;#39;ErrorMeassage&amp;#39;))&lt;br&gt;                            +&lt;br&gt;                            CAST(ISNULL(@message, &amp;#39;&amp;#39;) AS NVARCHAR(MAX))&lt;br&gt;                            +&lt;br&gt;                            &amp;#39;&amp;lt;/DeadlockNotification&amp;gt;&amp;#39;&lt;br&gt;        -- for testing purposes&lt;br&gt;        -- SELECT CAST(@MailBody AS XML)&lt;br&gt;&lt;br&gt;        -- send an email with the defined email profile.&lt;br&gt;        -- since this is async it doesn&amp;#39;t halt execution&lt;br&gt;        EXEC msdb.dbo.sp_send_dbmail&lt;br&gt;                       @profile_name = &amp;#39;your mail profile&amp;#39;,&lt;br&gt;                       @recipients = &amp;#39;dba@yourCompany.com&amp;#39;,&lt;br&gt;                       @subject = &amp;#39;Deadlock occured notification&amp;#39;,&lt;br&gt;                       @body = @MailBody;&lt;br&gt;      END&lt;br&gt;    END&lt;br&gt;  END CATCH&lt;br&gt;GO&lt;br&gt;The main part of this stored procedure is of course the CATCH block. The first line in there is check of the XACT_STATE()&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms189797.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms189797.aspx&lt;/a&gt;&amp;gt; value. This is a scalar function that reports the user transaction state. -1 means that the transaction is uncommittable and has to be rolled back. This is the state of the victim transaction in the internal deadlock killing process. Next we read from our vLocks view to get the full info (SPID, both SQL statements text, values, etc...) about both SPIDs that created a deadlock. This is possible since our deadlock victim transaction hasn&amp;#39;t been rolled back yet and the locks are still present. We save this data into an XML message. Next we rollback our transaction to release locks. With error message and it&amp;#39;s corresponding number we check if the error is 1205 - deadlock and if it is we send our message in an email. How to configure database mail can be seen here&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms175887.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms175887.aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;Both the view and the stored procedures template can and probably should be customized to suit your needs.&lt;br&gt;Testing the theory&lt;br&gt;Let&amp;#39;s try it out and see how it works with a textbook deadlock example that you can find in every book or tutorial.&lt;br&gt;-- create our deadlock table with 2 simple rows&lt;br&gt;CREATE TABLE DeadlockTest ( id INT)&lt;br&gt;INSERT INTO DeadlockTest&lt;br&gt;SELECT 1 UNION ALL&lt;br&gt;SELECT 2&lt;br&gt;GO&lt;br&gt;Next create two stored procedures (spProc1 and spProc2) with our template:&lt;br&gt;For spProc1 replace &amp;lt;SPROC TEXT GOES HERE&amp;gt; in the template with:&lt;br&gt;UPDATE DeadlockTest&lt;br&gt;SET id = 12&lt;br&gt;WHERE id = 2&lt;br&gt;&lt;br&gt;-- wait 5 secs TO SET up deadlock condition IN other window&lt;br&gt;WAITFOR DELAY &amp;#39;00:00:05&amp;#39;&lt;br&gt;&lt;br&gt;UPDATE DeadlockTest&lt;br&gt;SET id = 11&lt;br&gt;WHERE id = 1&lt;br&gt;For spProc2 replace &amp;lt;SPROC TEXT GOES HERE&amp;gt; in the template with:&lt;br&gt;UPDATE DeadlockTest&lt;br&gt;SET id = 11&lt;br&gt;WHERE id = 1&lt;br&gt;&lt;br&gt;-- wait 5 secs TO SET up deadlock condition IN other window&lt;br&gt;WAITFOR DELAY &amp;#39;00:00:05&amp;#39;&lt;br&gt;&lt;br&gt;UPDATE DeadlockTest&lt;br&gt;SET id = 12&lt;br&gt;WHERE id = 2&lt;br&gt;Next open 2 query windows in SSMS:&lt;br&gt;In window 1 run put this script:&lt;br&gt;exec spProc1&lt;br&gt;In window 2 put this script:&lt;br&gt;exec spProc2&lt;br&gt;Run the script in the first window and after a second or two run the script in the second window. A deadlock will happen and a few moments after the victim transaction fails you should get the notification mail. Mail profile has to be properly configured of course.&lt;br&gt;The resulting email should contain an XML with full info about the deadlock. You can view it by commenting msdb.dbo.sp_send_dbmail execution and uncommenting the SELECT CAST(@MailBody AS XML) line.&lt;br&gt;If you fire up the SQL Profiler, reset the table values, rerun both scripts and observe the deadlock graph event you should get a picture similar to this one:&lt;br&gt;[cid:image001.png@01CD761E.26957D40]&amp;lt;&lt;a href=&quot;http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/SQLServer2005SendmailwhenDeadlockhappens_124F2/deadlockProfiler_6.png&quot;&gt;http://weblogs.sqlteam.com/images/weblogs_sqlteam_com/mladenp/WindowsLiveWriter/SQLServer2005SendmailwhenDeadlockhappens_124F2/deadlockProfiler_6.png&lt;/a&gt;&amp;gt;&lt;br&gt;End ? ... for now... but more to come soon!&lt;br&gt;With the upper technique we can get mostly the same info as with trace flags with the advantage of knowing immediately after happening, plus if we want we can extend this to notify/log about every error which I actually prefer to do.&lt;br&gt;We can see just how awesome is the new async functionality like database mail built on top of the SQL Server Service Broker&amp;lt;&lt;a href=&quot;http://weblogs.sqlteam.com/mladenp/archive/2007/08/21/Service-Broker-goodies-Cross-Server-Many-to-One-One-to.aspx&quot;&gt;http://weblogs.sqlteam.com/mladenp/archive/2007/08/21/Service-Broker-goodies-Cross-Server-Many-to-One-One-to.aspx&lt;/a&gt;&amp;gt;. And instead of sending mail you can put the error in an error logging table in the same async way which I&amp;#39;ve demonstrated here&amp;lt;&lt;a href=&quot;http://www.sqlteam.com/article/centralized-asynchronous-auditing-with-service-broker&quot;&gt;http://www.sqlteam.com/article/centralized-asynchronous-auditing-with-service-broker&lt;/a&gt;&amp;gt;.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/8033813965974712281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/8033813965974712281' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/8033813965974712281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/8033813965974712281'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/08/sql-server-2005-immediate-deadlock.html' title='SQL Server 2005: Immediate Deadlock notifications (example)'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0c4uuZPMkgmZ9-lfhg5xZKKCzIbu9mfOoNqka4ABP2g80edltvVb5UvPmV_eiKZ1ZRE-jYm7ZLcmugtlWz3DPas8fgmvpAzBkiqHzGIVjggrwYOCjQPmNGhU28SHB3U6Huq5y_Lb6PLZY/s72-c/image001-727036.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-5791711925263592371</id><published>2012-07-05T12:57:00.001+05:30</published><updated>2012-07-05T12:57:58.323+05:30</updated><title type='text'>SQL Server Isolation Levels By Example  (Nice One)</title><content type='html'>&lt;a href=&quot;http://www.gavindraper.co.uk/2012/02/18/sql-server-isolation-levels-by-example/&quot;&gt;http://www.gavindraper.co.uk/2012/02/18/sql-server-isolation-levels-by-example/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;SQL Server Isolation Levels By Example&lt;br&gt;Posted on February 18, 2012&amp;lt;&lt;a href=&quot;http://www.gavindraper.co.uk/2012/02/18/sql-server-isolation-levels-by-example/&quot;&gt;http://www.gavindraper.co.uk/2012/02/18/sql-server-isolation-levels-by-example/&lt;/a&gt;&amp;gt; by Gavin&amp;lt;&lt;a href=&quot;http://www.gavindraper.co.uk/author/admin/&quot;&gt;http://www.gavindraper.co.uk/author/admin/&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Isolation levels in SQL Server control the way locking works between transactions.&lt;br&gt;SQL Server 2008 supports the following isolation levels&lt;br&gt;&amp;#167;  Read Uncommitted&lt;br&gt;&amp;#167;  Read Committed (The default)&lt;br&gt;&amp;#167;  Repeatable Read&lt;br&gt;&amp;#167;  Serializable&lt;br&gt;&amp;#167;  Snapshot&lt;br&gt;Before I run through each of these in detail you may want to create a new database to run the examples, run the following script on the new database to create the sample data. Note : You&amp;#39;ll also want to drop the IsolationTests table and re-run this script before each example to reset the data.&lt;br&gt;CREATE TABLE IsolationTests&lt;br&gt;(&lt;br&gt;Id INT IDENTITY,&lt;br&gt;Col1 INT,&lt;br&gt;Col2 INT,&lt;br&gt;Col3 INT&lt;br&gt;)&lt;br&gt;INSERT INTO IsolationTests(Col1,Col2,Col3)&lt;br&gt;SELECT 1,2,3&lt;br&gt;UNION ALL SELECT 1,2,3&lt;br&gt;UNION ALL SELECT 1,2,3&lt;br&gt;UNION ALL SELECT 1,2,3&lt;br&gt;UNION ALL SELECT 1,2,3&lt;br&gt;UNION ALL SELECT 1,2,3&lt;br&gt;UNION ALL SELECT 1,2,3&lt;br&gt;&lt;br&gt;Also before we go any further it is important to understand these two terms....&lt;br&gt;1.       Dirty Reads - This is when you read uncommitted data, when doing this there is no guarantee that data read will ever be committed meaning the data could well be bad.&lt;br&gt;2.      Phantom Reads - This is when data that you are working with has been changed by another transaction since you first read it in. This means subsequent reads of this data in the same transaction could well be different.&lt;br&gt;Read Uncommitted&lt;br&gt;This is the lowest isolation level there is. Read uncommitted causes no shared locks to be requested which allows you to read data that is currently being modified in other transactions. It also allows other transactions to modify data that you are reading.&lt;br&gt;As you can probably imagine this can cause some unexpected results in a variety of different ways. For example data returned by the select could be in a half way state if an update was running in another transaction causing some of your rows to come back with the updated values and some not to.&lt;br&gt;To see read uncommitted in action lets run Query1 in one tab of Management Studio and then quickly run Query2 in another tab before Query1 completes.&lt;br&gt;Query1&lt;br&gt;BEGIN TRAN&lt;br&gt;UPDATE Tests SET Col1 = 2&lt;br&gt;--Simulate having some intensive processing here with a wait&lt;br&gt;WAITFOR DELAY &amp;#39;00:00:10&amp;#39;&lt;br&gt;ROLLBACK&lt;br&gt;&lt;br&gt;Query2&lt;br&gt;SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED&lt;br&gt;SELECT * FROM IsolationTests&lt;br&gt;&lt;br&gt;Notice that Query2 will not wait for Query1 to finish, also more importantly Query2 returns dirty data. Remember Query1 rolls back all its changes however Query2 has returned the data anyway, this is because it didn&amp;#39;t wait for all the other transactions with exclusive locks on this data it just returned what was there at the time.&lt;br&gt;There is a syntactic shortcut for querying data using the read uncommitted isolation level by using the NOLOCK table hint. You could change the above Query2 to look like this and it would do the exact same thing.&lt;br&gt;SELECT * FROM IsolationTests WITH(NOLOCK)&lt;br&gt;&lt;br&gt;Read Committed&lt;br&gt;This is the default isolation level and means selects will only return committed data. Select statements will issue shared lock requests against data you&amp;#39;re querying this causes you to wait if another transaction already has an exclusive lock on that data. Once you have your shared lock any other transactions trying to modify that data will request an exclusive lock and be made to wait until your Read Committed transaction finishes.&lt;br&gt;You can see an example of a read transaction waiting for a modify transaction to complete before returning the data by running the following Queries in separate tabs as you did with Read Uncommitted.&lt;br&gt;Query1&lt;br&gt;BEGIN TRAN&lt;br&gt;UPDATE Tests SET Col1 = 2&lt;br&gt;--Simulate having some intensive processing here with a wait&lt;br&gt;WAITFOR DELAY &amp;#39;00:00:10&amp;#39;&lt;br&gt;ROLLBACK&lt;br&gt;&lt;br&gt;Query2&lt;br&gt;SELECT * FROM IsolationTests&lt;br&gt;&lt;br&gt;Notice how Query2 waited for the first transaction to complete before returning and also how the data returned is the data we started off with as Query1 did a rollback. The reason no isolation level was specified is because Read Committed is the default isolation level for SQL Server. If you want to check what isolation level you are running under you can run &amp;quot;DBCC useroptions&amp;quot;. Remember isolation levels are Connection/Transaction specific so different queries on the same database are often run under different isolation levels.&lt;br&gt;Repeatable Read&lt;br&gt;This is similar to Read Committed but with the additional guarantee that if you issue the same select twice in a transaction you will get the same results both times. It does this by holding on to the shared locks it obtains on the records it reads until the end of the transaction, This means any transactions that try to modify these records are force to wait for the read transaction to complete.&lt;br&gt;As before run Query1 then while its running run Query2&lt;br&gt;Query1&lt;br&gt;SET TRANSACTION ISOLATION LEVEL REPEATABLE READ&lt;br&gt;BEGIN TRAN&lt;br&gt;SELECT * FROM IsolationTests&lt;br&gt;WAITFOR DELAY &amp;#39;00:00:10&amp;#39;&lt;br&gt;SELECT * FROM IsolationTests&lt;br&gt;ROLLBACK&lt;br&gt;&lt;br&gt;Query2&lt;br&gt;UPDATE IsolationTests SET Col1 = -1&lt;br&gt;&lt;br&gt;Notice that Query1 returns the same data for both selects even though you ran a query to modify the data before the second select ran. This is because the Update query was forced to wait for Query1 to finish due to the exclusive locks that were opened as you specified Repeatable Read.&lt;br&gt;If you rerun the above Queries but change Query1 to Read Committed you will notice the two selects return different data and that Query2 does not wait for Query1 to finish.&lt;br&gt;One last thing to know about Repeatable Read is that the data can change between 2 queries if more records are added. Repeatable Read guarantees records queried by a previous select will not be changed or deleted, it does not stop new records being inserted so it is still very possible to get Phantom Reads at this isolation level.&lt;br&gt;Serializable&lt;br&gt;This isolation level takes Repeatable Read and adds the guarantee that no new data will be added eradicating the chance of getting Phantom Reads. It does this by placing range locks on the queried data. This causes any other transactions trying to modify or insert data touched on by this transaction to wait until it has finished.&lt;br&gt;You know the drill by now run these queries side by side...&lt;br&gt;Query1&lt;br&gt;SET TRANSACTION ISOLATION LEVEL SERIALIZABLE&lt;br&gt;BEGIN TRAN&lt;br&gt;SELECT * FROM IsolationTests&lt;br&gt;WAITFOR DELAY &amp;#39;00:00:10&amp;#39;&lt;br&gt;SELECT * FROM IsolationTests&lt;br&gt;ROLLBACK&lt;br&gt;&lt;br&gt;Query2&lt;br&gt;INSERT INTO IsolationTests(Col1,Col2,Col3)&lt;br&gt;VALUES (100,100,100)&lt;br&gt;&lt;br&gt;You&amp;#39;ll see that the insert in Query2 waits for Query1 to complete before it runs eradicating the chance of a phantom read. If you change the isolation level in Query1 to repeatable read, you&amp;#39;ll see the insert no longer gets blocked and the two select statements in Query1 return a different amount of rows.&lt;br&gt;Snapshot&lt;br&gt;This provides the same guarantees as serializable. So what&amp;#39;s the difference? Well it&amp;#39;s more in the way it works, using snapshot doesn&amp;#39;t block other Queries from inserting or updating the data touched by the snapshot transaction. Instead it creates it&amp;#39;s own little snapshot of the data being read at that time, if you then read that data again in the same transaction it reads it from its snapshot, This means that even if another transaction has made changes you will always get the same results as you did the first time you read the data.&lt;br&gt;So on the plus side your not blocking anyone else from modifying the data whilst you run your transaction but.... You&amp;#39;re using extra resources on the SQL Server to allocate each snapshot transaction the additional resources to store the snapshot data which can be quite significant if your transaction is working with a large amount of data.&lt;br&gt;To use the snapshot isolation level you need to enable it on the database by running the following command&lt;br&gt;ALTER DATABASE IsolationTests&lt;br&gt;SET ALLOW_SNAPSHOT_ISOLATION ON&lt;br&gt;&lt;br&gt;If you rerun the examples from serializable but change the isolation level to snapshot you will notice that you still get the same data returned but Query2 no longer waits for Query1 to complete.&lt;br&gt;Summary&lt;br&gt;You should now have a good idea how each of the different isolation levels work. You can see how the higher the level you use the less concurrency you are offering and the more blocking you bring to the table. You should always try to use the lowest isolation level you can which is usually read committed.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/5791711925263592371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/5791711925263592371' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/5791711925263592371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/5791711925263592371'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/07/sql-server-isolation-levels-by-example.html' title='SQL Server Isolation Levels By Example  (Nice One)'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-7921071989753422663</id><published>2012-07-03T09:48:00.001+05:30</published><updated>2012-07-03T09:48:24.550+05:30</updated><title type='text'>SQL: How to Create Dynamic Table Names in SQL Server</title><content type='html'>&lt;a href=&quot;http://support.microsoft.com/kb/175850&quot;&gt;http://support.microsoft.com/kb/175850&lt;/a&gt;&lt;br&gt;&lt;br&gt;INF: How to Create Dynamic Table Names in SQL Server&lt;br&gt;&lt;br&gt;&lt;br&gt;-- Variable that will contain the name of the table&lt;br&gt;   declare @mytable varchar(30)&lt;br&gt;   -- Creates a temp table name&lt;br&gt;   select @mytable =&amp;#39;TEMP&amp;#39;+ CONVERT(char(12), GETDATE(), 14)&lt;br&gt;   print @mytable&lt;br&gt;&lt;br&gt;   -- Table cannot be created with the character  &amp;quot;:&amp;quot;  in it&lt;br&gt;   -- The following while loop strips off the colon&lt;br&gt;   declare  @pos int&lt;br&gt;   select   @pos = charindex(&amp;#39;:&amp;#39;,@mytable)&lt;br&gt;&lt;br&gt;   while @pos &amp;gt; 0&lt;br&gt;      begin&lt;br&gt;           select @mytable = substring(@mytable,1,@pos - 1)   +&lt;br&gt;                             substring(@mytable,@pos + 1,30-@pos )&lt;br&gt;           select @pos = charindex(&amp;#39;:&amp;#39;,@mytable)&lt;br&gt;      end&lt;br&gt;   print &amp;#39;Name without colon is :&amp;#39;&lt;br&gt;   print @mytable&lt;br&gt;&lt;br&gt;--create table  @mytable (col1 int)&lt;br&gt;&lt;br&gt;   -- Create the temporary table&lt;br&gt;   execute (&amp;#39;create table &amp;#39;+ @mytable +&lt;br&gt;             &amp;#39;(col1 int)&amp;#39; )&lt;br&gt;&lt;br&gt;   -- Insert two rows in the table&lt;br&gt;   execute (&amp;#39;insert into &amp;#39; + @mytable +&lt;br&gt;                 &amp;#39; values(1)&amp;#39;)&lt;br&gt;&lt;br&gt;   execute (&amp;#39;insert into &amp;#39; + @mytable +&lt;br&gt;                 &amp;#39; values(2)&amp;#39;)&lt;br&gt;&lt;br&gt;   -- Select from the temporary table&lt;br&gt;   execute (&amp;#39;select col1 from &amp;#39; + @mytable )&lt;br&gt;   -- Drop the temporary table&lt;br&gt;   execute (&amp;#39;drop table &amp;#39; + @mytable)</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/7921071989753422663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/7921071989753422663' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/7921071989753422663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/7921071989753422663'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/07/sql-how-to-create-dynamic-table-names.html' title='SQL: How to Create Dynamic Table Names in SQL Server'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-3371275366965553818</id><published>2012-06-22T11:55:00.001+05:30</published><updated>2012-06-22T11:55:10.044+05:30</updated><title type='text'>division in SQL results in 0</title><content type='html'>&lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/483c81d4-8e6d-41fb-9a6e-cc61b42772e6/&quot;&gt;http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/483c81d4-8e6d-41fb-9a6e-cc61b42772e6/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;declare @x int, @y int, @f float&lt;br&gt;set @x = 100&lt;br&gt;set @y = 2000&lt;br&gt;set @f = @x / (@y * 1.0)&lt;br&gt;print @x&lt;br&gt;print @y&lt;br&gt;print @f</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/3371275366965553818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/3371275366965553818' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3371275366965553818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3371275366965553818'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/06/division-in-sql-results-in-0.html' title='division in SQL results in 0'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-2836783608100243338</id><published>2012-06-15T15:57:00.001+05:30</published><updated>2012-06-15T15:57:27.566+05:30</updated><title type='text'>SQL : Apply (Cross Apply / Outer Apply)</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1SdRifteAqLRbMNXI0AaC_E3jlq2Z7_D-pZ__hVZ3lkRMUddflT-ZxwBrr9cgq_vVisK3qaaIyj8TNbsSZvpaO8EGMY4yqdNxrcoZEKNCoVCukshIvtaZL-1WU7WxIeb-X4YXSMP5qGQ7/s1600/image001-747566.gif&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1SdRifteAqLRbMNXI0AaC_E3jlq2Z7_D-pZ__hVZ3lkRMUddflT-ZxwBrr9cgq_vVisK3qaaIyj8TNbsSZvpaO8EGMY4yqdNxrcoZEKNCoVCukshIvtaZL-1WU7WxIeb-X4YXSMP5qGQ7/s320/image001-747566.gif&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5754208408117404066&quot; /&gt;&lt;/a&gt;&lt;/p&gt;Reference: &lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx&quot;&gt;http://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;Using APPLY&lt;br&gt;SQL Server 2008 R2&lt;br&gt;Other Versions &amp;lt;javascript:;&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; *   SQL Server 2008&amp;lt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms175156(v=sql.100).aspx&quot;&gt;http://technet.microsoft.com/en-us/library/ms175156(v=sql.100).aspx&lt;/a&gt;&amp;gt;&lt;br&gt; *   SQL Server 2005&amp;lt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms175156(v=sql.90).aspx&quot;&gt;http://technet.microsoft.com/en-us/library/ms175156(v=sql.90).aspx&lt;/a&gt;&amp;gt;&lt;br&gt;17 out of 32 rated this helpful - Rate this topic&amp;lt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx#feedback&quot;&gt;http://technet.microsoft.com/en-us/library/ms175156(v=sql.105).aspx#feedback&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;The APPLY operator allows you to invoke a table-valued function for each row returned by an outer table expression of a query. The table-valued function acts as the right input and the outer table expression acts as the left input. The right input is evaluated for each row from the left input and the rows produced are combined for the final output. The list of columns produced by the APPLY operator is the set of columns in the left input followed by the list of columns returned by the right input.&lt;br&gt;[cid:image001.gif@01CD4B0F.8C893F90]Note&lt;br&gt;&lt;br&gt;&lt;br&gt;To use APPLY, the database compatibility level must be at least 90.&lt;br&gt;&lt;br&gt;&lt;br&gt;There are two forms of APPLY: CROSS APPLY and OUTER APPLY. CROSS APPLY returns only rows from the outer table that produce a result set from the table-valued function. OUTER APPLY returns both rows that produce a result set, and rows that do not, with NULL values in the columns produced by the table-valued function.&lt;br&gt;&lt;br&gt;As an example, consider the following tables, Employees and Departments:&lt;br&gt;Copy&amp;lt;javascript:CodeSnippet_CopyCode(&amp;#39;CodeSnippetContainerCode_089d4fd8-1e08-4186-9cdf-71ca05351d3a&amp;#39;);&amp;gt;&lt;br&gt;&lt;br&gt;--Create Employees table and insert values.&lt;br&gt;&lt;br&gt;CREATE TABLE Employees&lt;br&gt;&lt;br&gt;(&lt;br&gt;&lt;br&gt;    empid   int         NOT NULL&lt;br&gt;&lt;br&gt;    ,mgrid   int         NULL&lt;br&gt;&lt;br&gt;    ,empname varchar(25) NOT NULL&lt;br&gt;&lt;br&gt;    ,salary  money       NOT NULL&lt;br&gt;&lt;br&gt;    CONSTRAINT PK_Employees PRIMARY KEY(empid)&lt;br&gt;&lt;br&gt;);&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(1 , NULL, &amp;#39;Nancy&amp;#39;   , $10000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(2 , 1   , &amp;#39;Andrew&amp;#39;  , $5000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(3 , 1   , &amp;#39;Janet&amp;#39;   , $5000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(4 , 1   , &amp;#39;Margaret&amp;#39;, $5000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(5 , 2   , &amp;#39;Steven&amp;#39;  , $2500.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(6 , 2   , &amp;#39;Michael&amp;#39; , $2500.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(7 , 3   , &amp;#39;Robert&amp;#39;  , $2500.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(8 , 3   , &amp;#39;Laura&amp;#39;   , $2500.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(9 , 3   , &amp;#39;Ann&amp;#39;     , $2500.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(10, 4   , &amp;#39;Ina&amp;#39;     , $2500.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(11, 7   , &amp;#39;David&amp;#39;   , $2000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(12, 7   , &amp;#39;Ron&amp;#39;     , $2000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(13, 7   , &amp;#39;Dan&amp;#39;     , $2000.00);&lt;br&gt;&lt;br&gt;INSERT INTO Employees VALUES(14, 11  , &amp;#39;James&amp;#39;   , $1500.00);&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;--Create Departments table and insert values.&lt;br&gt;&lt;br&gt;CREATE TABLE Departments&lt;br&gt;&lt;br&gt;(&lt;br&gt;&lt;br&gt;    deptid    INT NOT NULL PRIMARY KEY&lt;br&gt;&lt;br&gt;    ,deptname  VARCHAR(25) NOT NULL&lt;br&gt;&lt;br&gt;    ,deptmgrid INT NULL REFERENCES Employees&lt;br&gt;&lt;br&gt;);&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;INSERT INTO Departments VALUES(1, &amp;#39;HR&amp;#39;,           2);&lt;br&gt;&lt;br&gt;INSERT INTO Departments VALUES(2, &amp;#39;Marketing&amp;#39;,    7);&lt;br&gt;&lt;br&gt;INSERT INTO Departments VALUES(3, &amp;#39;Finance&amp;#39;,      8);&lt;br&gt;&lt;br&gt;INSERT INTO Departments VALUES(4, &amp;#39;R&amp;amp;D&amp;#39;,          9);&lt;br&gt;&lt;br&gt;INSERT INTO Departments VALUES(5, &amp;#39;Training&amp;#39;,     4);&lt;br&gt;&lt;br&gt;INSERT INTO Departments VALUES(6, &amp;#39;Gardening&amp;#39;, NULL);&lt;br&gt;&lt;br&gt;Most departments in the Departments table have a manager ID that corresponds to an employee in the Employees table. The following table-valued function accepts an employee ID as an argument and returns that employee and all of his or her subordinates.&lt;br&gt;Copy&amp;lt;javascript:CodeSnippet_CopyCode(&amp;#39;CodeSnippetContainerCode_49c631ea-0bf3-4c16-848d-0cbb92ffb354&amp;#39;);&amp;gt;&lt;br&gt;&lt;br&gt;CREATE FUNCTION dbo.fn_getsubtree(@empid AS INT)&lt;br&gt;&lt;br&gt;    RETURNS @TREE TABLE&lt;br&gt;&lt;br&gt;(&lt;br&gt;&lt;br&gt;    empid   INT NOT NULL&lt;br&gt;&lt;br&gt;    ,empname VARCHAR(25) NOT NULL&lt;br&gt;&lt;br&gt;    ,mgrid   INT NULL&lt;br&gt;&lt;br&gt;    ,lvl     INT NOT NULL&lt;br&gt;&lt;br&gt;)&lt;br&gt;&lt;br&gt;AS&lt;br&gt;&lt;br&gt;BEGIN&lt;br&gt;&lt;br&gt;  WITH Employees_Subtree(empid, empname, mgrid, lvl)&lt;br&gt;&lt;br&gt;  AS&lt;br&gt;&lt;br&gt;  (&lt;br&gt;&lt;br&gt;    -- Anchor Member (AM)&lt;br&gt;&lt;br&gt;    SELECT empid, empname, mgrid, 0&lt;br&gt;&lt;br&gt;    FROM Employees&lt;br&gt;&lt;br&gt;    WHERE empid = @empid&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;    UNION all&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;    -- Recursive Member (RM)&lt;br&gt;&lt;br&gt;    SELECT e.empid, e.empname, e.mgrid, es.lvl+1&lt;br&gt;&lt;br&gt;    FROM Employees AS e&lt;br&gt;&lt;br&gt;      JOIN Employees_Subtree AS es&lt;br&gt;&lt;br&gt;        ON e.mgrid = es.empid&lt;br&gt;&lt;br&gt;  )&lt;br&gt;&lt;br&gt;  INSERT INTO @TREE&lt;br&gt;&lt;br&gt;    SELECT * FROM Employees_Subtree;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;  RETURN&lt;br&gt;&lt;br&gt;END&lt;br&gt;&lt;br&gt;GO&lt;br&gt;&lt;br&gt;To return all of the subordinates in all levels for the manager of each department, use the following query.&lt;br&gt;Copy&amp;lt;javascript:CodeSnippet_CopyCode(&amp;#39;CodeSnippetContainerCode_11e1c87e-7a8e-423a-b94a-9c74afd15b59&amp;#39;);&amp;gt;&lt;br&gt;&lt;br&gt;SELECT D.deptid, D.deptname, D.deptmgrid&lt;br&gt;&lt;br&gt;    ,ST.empid, ST.empname, ST.mgrid&lt;br&gt;&lt;br&gt;FROM Departments AS D&lt;br&gt;&lt;br&gt;    CROSS APPLY fn_getsubtree(D.deptmgrid) AS ST;&lt;br&gt;&lt;br&gt;Here is the result set.&lt;br&gt;Copy&amp;lt;javascript:CodeSnippet_CopyCode(&amp;#39;CodeSnippetContainerCode_982ac3b1-7369-41ee-8cb6-c8d5369e7e18&amp;#39;);&amp;gt;&lt;br&gt;&lt;br&gt;deptid      deptname   deptmgrid   empid       empname    mgrid       lvl&lt;br&gt;&lt;br&gt;----------- ---------- ----------- ----------- ---------- ----------- ---&lt;br&gt;&lt;br&gt;1           HR         2           2           Andrew     1           0&lt;br&gt;&lt;br&gt;1           HR         2           5           Steven     2           1&lt;br&gt;&lt;br&gt;1           HR         2           6           Michael    2           1&lt;br&gt;&lt;br&gt;2           Marketing  7           7           Robert     3           0&lt;br&gt;&lt;br&gt;2           Marketing  7           11          David      7           1&lt;br&gt;&lt;br&gt;2           Marketing  7           12          Ron        7           1&lt;br&gt;&lt;br&gt;2           Marketing  7           13          Dan        7           1&lt;br&gt;&lt;br&gt;2           Marketing  7           14          James      11          2&lt;br&gt;&lt;br&gt;3           Finance    8           8           Laura      3           0&lt;br&gt;&lt;br&gt;4           R&amp;amp;D        9           9           Ann        3           0&lt;br&gt;&lt;br&gt;5           Training   4           4           Margaret   1           0&lt;br&gt;&lt;br&gt;5           Training   4           10          Ina        4           1&lt;br&gt;&lt;br&gt;Notice that each row from the Departments table is duplicated as many times as there are rows returned from fn_getsubtree for the department&amp;#39;s manager.&lt;br&gt;&lt;br&gt;Also, the Gardening department does not appear in the results. Because this department has no manager, fn_getsubtree returned an empty set for it. By using OUTER APPLY, the Gardening department will also appear in the result set, with null values in the deptmgrid field, as well as in the fields returned by fn_getsubtree.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/2836783608100243338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/2836783608100243338' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2836783608100243338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2836783608100243338'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/06/sql-apply-cross-apply-outer-apply.html' title='SQL : Apply (Cross Apply / Outer Apply)'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1SdRifteAqLRbMNXI0AaC_E3jlq2Z7_D-pZ__hVZ3lkRMUddflT-ZxwBrr9cgq_vVisK3qaaIyj8TNbsSZvpaO8EGMY4yqdNxrcoZEKNCoVCukshIvtaZL-1WU7WxIeb-X4YXSMP5qGQ7/s72-c/image001-747566.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-5576888844650223039</id><published>2012-05-31T12:29:00.001+05:30</published><updated>2012-05-31T12:29:54.577+05:30</updated><title type='text'>SQL SERVER - Intorduction to Service Broker and Sample Script</title><content type='html'>SQL SERVER - Intorduction to Service Broker and Sample Script&lt;br&gt;&lt;br&gt;&lt;br&gt;Service Broker in Microsoft SQL Server 2005 is a new technology that provides messaging and queuing functions between instances. The basic functions of sending and receiving messages forms a part of a &amp;quot;conversation.&amp;quot; Each conversation is considered to be a complete channel of communication. Each Service Broker conversation is considered to be a dialog where two participants are involved.&lt;br&gt;&lt;br&gt;Service broker find applications when single or multiple SQL server instances are used. This functionality helps in sending messages to remote databases on different servers and processing of the messages within a single database. In order to send messages between the instances, the Service Broker uses TCP/IP.&lt;br&gt;&lt;br&gt;This transaction message queuing system enables the developers to build secure and reliable applications, which are scalable. The developers can design applications from independent components known as &amp;quot;services.&amp;quot; If the applications need to avail the functionality of these services, then it sends message to the particular &amp;quot;service.&amp;quot;&lt;br&gt;&lt;br&gt;Loosely coupled applications (programs that exchange messages independently) are supported by the Service broker. The three components of the Service broker are as follows: conversation components (which consist of the conversation groups, conversations and messages); service definition components (which define the conversations); and networking and security components (defines the infrastructure used for exchanging messages between instances)&lt;br&gt;&lt;br&gt;The maintenance of Service Broker is easy and it is a part of the routine database administration procedure. This is because this functionality forms a part of the Database Engine. Service Broker also provides security by preventing unauthorized access from networks and by message encryption.&lt;br&gt;&lt;br&gt;Let us understand Service Broker with simple script. Script contains necessary comments to explain what exactly script is doing.&lt;br&gt;---------------------------- Service Broker -----------------------&lt;br&gt;In this exercise we will learn how to cofigure Servie Broker and send and recieve messages.&lt;br&gt;-------------------------------------------------------------------&lt;br&gt;&lt;br&gt;CREATE DATABASE ServiceBrokerTest&lt;br&gt;GO&lt;br&gt;USE ServiceBrokerTest&lt;br&gt;GO&lt;br&gt;-- Enable Service Broker&lt;br&gt;ALTER DATABASE ServiceBrokerTest SET ENABLE_BROKER&lt;br&gt;GO&lt;br&gt;-- Create Message Type&lt;br&gt;CREATE MESSAGE TYPE SBMessage&lt;br&gt;VALIDATION = NONE&lt;br&gt;GO&lt;br&gt;-- Create Contract&lt;br&gt;CREATE CONTRACT SBContract&lt;br&gt;(SBMessage SENT BY INITIATOR)&lt;br&gt;GO&lt;br&gt;-- Create Send Queue&lt;br&gt;CREATE QUEUE SBSendQueue&lt;br&gt;GO&lt;br&gt;-- Create Receive Queue&lt;br&gt;CREATE QUEUE SBReceiveQueue&lt;br&gt;GO&lt;br&gt;-- Create Send Service on Send Queue&lt;br&gt;CREATE SERVICE SBSendService&lt;br&gt;ON QUEUE SBSendQueue (SBContract)&lt;br&gt;GO&lt;br&gt;-- Create Receive Service on Recieve Queue&lt;br&gt;CREATE SERVICE SBReceiveService&lt;br&gt;ON QUEUE SBReceiveQueue (SBContract)&lt;br&gt;GO&lt;br&gt;-- Begin Dialog using service on contract&lt;br&gt;DECLARE @SBDialog uniqueidentifier&lt;br&gt;DECLARE @Message NVARCHAR(128)&lt;br&gt;BEGIN DIALOG CONVERSATION @SBDialog&lt;br&gt;FROM SERVICE SBSendService&lt;br&gt;TO SERVICE &amp;#39;SBReceiveService&amp;#39;&lt;br&gt;ON CONTRACT SBContract&lt;br&gt;WITH ENCRYPTION = OFF&lt;br&gt;-- Send messages on Dialog&lt;br&gt;SET @Message = N&amp;#39;Very First Message&amp;#39;;&lt;br&gt;SEND ON CONVERSATION @SBDialog&lt;br&gt;MESSAGE TYPE SBMessage (@Message)&lt;br&gt;SET @Message = N&amp;#39;Second Message&amp;#39;;&lt;br&gt;SEND ON CONVERSATION @SBDialog&lt;br&gt;MESSAGE TYPE SBMessage (@Message)&lt;br&gt;SET @Message = N&amp;#39;Third Message&amp;#39;;&lt;br&gt;SEND ON CONVERSATION @SBDialog&lt;br&gt;MESSAGE TYPE SBMessage (@Message)&lt;br&gt;GO&lt;br&gt;-- View messages from Receive Queue&lt;br&gt;SELECT CONVERT(NVARCHAR(MAX), message_body) AS Message&lt;br&gt;FROM SBReceiveQueue&lt;br&gt;GO&lt;br&gt;-- Receive messages from Receive Queue&lt;br&gt;RECEIVE TOP(1) CONVERT(NVARCHAR(MAX), message_body) AS Message&lt;br&gt;FROM SBReceiveQueue&lt;br&gt;GO&lt;br&gt;-- Receive messages from Receive Queue&lt;br&gt;RECEIVE CONVERT(NVARCHAR(MAX), message_body) AS Message&lt;br&gt;FROM SBReceiveQueue&lt;br&gt;GO&lt;br&gt;-- Clean Up&lt;br&gt;USE master&lt;br&gt;GO&lt;br&gt;DROP DATABASE ServiceBrokerTest&lt;br&gt;GO&lt;br&gt;&lt;br&gt;&lt;br&gt;You can download the above script from here&amp;lt;&lt;a href=&quot;http://www.pinaldave.com/sql-download/scripts/Service_Broker.zip&quot;&gt;http://www.pinaldave.com/sql-download/scripts/Service_Broker.zip&lt;/a&gt;&amp;gt;.&lt;br&gt;&lt;br&gt;Let me know what do you think of this script and how simply one can configure service broker.&lt;br&gt;&lt;br&gt;Reference : Pinal Dave (&lt;a href=&quot;http://blog.sqlauthority.com&quot;&gt;http://blog.sqlauthority.com&lt;/a&gt;&amp;lt;&lt;a href=&quot;http://blog.sqlauthority.com/&quot;&gt;http://blog.sqlauthority.com/&lt;/a&gt;&amp;gt;)&lt;br&gt;&lt;a href=&quot;http://blog.sqlauthority.com/2009/09/21/sql-server-intorduction-to-service-broker-and-sample-script/&quot;&gt;http://blog.sqlauthority.com/2009/09/21/sql-server-intorduction-to-service-broker-and-sample-script/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/5576888844650223039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/5576888844650223039' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/5576888844650223039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/5576888844650223039'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/05/sql-server-intorduction-to-service.html' title='SQL SERVER - Intorduction to Service Broker and Sample Script'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-4170353799819801970</id><published>2012-05-24T14:10:00.001+05:30</published><updated>2012-05-24T14:10:51.890+05:30</updated><title type='text'>Learn English</title><content type='html'>&lt;a href=&quot;http://www.englishclub.com/&quot;&gt;http://www.englishclub.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.englishclub.com/pronunciation/tongue-twisters.htm&quot;&gt;http://www.englishclub.com/pronunciation/tongue-twisters.htm&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/4170353799819801970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/4170353799819801970' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4170353799819801970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4170353799819801970'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/05/learn-english.html' title='Learn English'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-1379447303427580628</id><published>2012-05-22T16:45:00.001+05:30</published><updated>2012-05-22T16:45:29.447+05:30</updated><title type='text'>SQL Server 2008 - HierarchyID - Part I</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifBSkSeS_RFAMz7Z-P_SlZtVC2PH0m7lP9BpSDk5BVwDrPyg_u1MsUCXAzuiVOAXtM7k1PE1_ZC6fkZ253M8hzOEbeEfAmnBha53SyHwSe9N5oY26z97cO_ALzA5OXFhgyrTq9uxiXCks8/s1600/image001-729448.gif&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifBSkSeS_RFAMz7Z-P_SlZtVC2PH0m7lP9BpSDk5BVwDrPyg_u1MsUCXAzuiVOAXtM7k1PE1_ZC6fkZ253M8hzOEbeEfAmnBha53SyHwSe9N5oY26z97cO_ALzA5OXFhgyrTq9uxiXCks8/s320/image001-729448.gif&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5745314745277729506&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgASpPnqq0rUIBpxH3Z2kcGNKp8CSF1jjZ7ogdepYHR9PX5IvzAHqedMsLVOpvzq6JLrNwJ6UjxlKLri6l_wSOCjrEJYUbKfJWHo2UCzKEojrRBdYDNQqFQTH3Ng9fLtDp1NAw60gN-zPOp/s1600/image002-731682.gif&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgASpPnqq0rUIBpxH3Z2kcGNKp8CSF1jjZ7ogdepYHR9PX5IvzAHqedMsLVOpvzq6JLrNwJ6UjxlKLri6l_wSOCjrEJYUbKfJWHo2UCzKEojrRBdYDNQqFQTH3Ng9fLtDp1NAw60gN-zPOp/s320/image002-731682.gif&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5745314750109220066&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;a href=&quot;http://blogs.msdn.com/b/manisblog/archive/2007/08/17/sql-server-2008-hierarchyid.aspx&quot;&gt;http://blogs.msdn.com/b/manisblog/archive/2007/08/17/sql-server-2008-hierarchyid.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;SQL Server 2008 - HierarchyID - Part I&lt;br&gt;&lt;br&gt;I am excited by the cool new features that SQL Server 2008 is binging up !&lt;br&gt;SQL Server 2008 is bringing some commendable new features one of the nice feature is HierarchyID. This a new data type that is available in the in the latest July CTP of the SQL Server 2008 Developer Edition.&lt;br&gt;Organizations have struggled in past with the representation of tree like structures in the databases, lot of joins lots of complex logic goes into the place, whether it is organization hierarchy or defining a BOM (Bill of Materials) where one finished product is dependent on another semi finished materials / kit items and these kit items are dependent on another semi finished items or raw materials.&lt;br&gt;SQL Server 2008 has the solution to the problem where we store the entire hierarchy in the data type HierarchyID. HierarchyID is a variable length system data type. HierarchyID is used to locate the position in the hierarchy of the element like Scott is the CEO and Mark as well as Ravi reports to Scott and Ben and Laura report to Mark, Vijay, James and Frank report to Ravi.&lt;br&gt;Scott&lt;br&gt;|&lt;br&gt;Mark &amp;lt;- &amp;gt; Ravi&lt;br&gt;| |&lt;br&gt;Ben&amp;lt;-&amp;gt; Laura Vijay &amp;lt;-&amp;gt; Frank &amp;lt;-&amp;gt; James&lt;br&gt;This tree can expand to n nodes.&lt;br&gt;The average number of bits that are required to represent a node in a tree with n nodes depends on the average fanout (the average number of children of a node). For small fanouts (0-7), the size is about 6*logAn bits, where A is the average fanout. A node in an organizational hierarchy of 100,000 people with an average fanout of 6 levels takes about 38 bits. This is rounded up to 40 bits, or 5 bytes, for storage. It supports the insertion and deletion of nodes.&lt;br&gt;The HierarchyID can be indexed in two ways&lt;br&gt;1) Depth First strategy: A depth-first index, rows in a subtree are stored near each other. For example, all employees that report through a manager are stored near their managers&amp;#39; record.&lt;br&gt;[cid:image001.gif@01CD383A.42FF5220]&amp;lt;&lt;a href=&quot;http://blogs.msdn.com/blogfiles/manisblog/WindowsLiveWriter/SQLServer2008HierarchyID_13519/DF.gif&quot;&gt;http://blogs.msdn.com/blogfiles/manisblog/WindowsLiveWriter/SQLServer2008HierarchyID_13519/DF.gif&lt;/a&gt;&amp;gt;&lt;br&gt;2) Breadth First Strategy : A breadth-first stores the rows each level of the hierarchy together. For example, the records of employees who directly report to the same manager are stored near each other.&lt;br&gt;[cid:image002.gif@01CD383A.42FF5220]&amp;lt;&lt;a href=&quot;http://blogs.msdn.com/blogfiles/manisblog/WindowsLiveWriter/SQLServer2008HierarchyID_13519/BF.gif&quot;&gt;http://blogs.msdn.com/blogfiles/manisblog/WindowsLiveWriter/SQLServer2008HierarchyID_13519/BF.gif&lt;/a&gt;&amp;gt;&lt;br&gt;We can change the strategy as and when we want but the index needs to be dropped and then a new index has to be rebuilt. If if the data is huge and the index is clustered then the table is converted to heap and then indexed again.&lt;br&gt;The following are the methods in the SQL Server 2008 Database Engine to support HierarchyID data type.&lt;br&gt;1) GetAncestor&lt;br&gt;2) GetDescendant&lt;br&gt;3) GetLevel&lt;br&gt;4) GetRoot&lt;br&gt;5) IsDescendant&lt;br&gt;6) Parse&lt;br&gt;7) Read&lt;br&gt;8) Reparent&lt;br&gt;9) ToString&lt;br&gt;10) Write&lt;br&gt;&lt;br&gt;GetAncestor()&lt;br&gt;This method is useful to find the (nth ancestor of the given child node.&lt;br&gt;Syntax: child.GetAncestor ( n )&lt;br&gt;GetDescendant()&lt;br&gt;This method is very useful to get the descendant of a given node. It has a great significance in terms of finding the new descendant position get the descendants etc.&lt;br&gt;Syntax: parent.GetDescendant ( child1 , child2 )&lt;br&gt;This function returns one child node that is a descendant of the parent.&lt;br&gt;1.  If parent is NULL, returns NULL.&lt;br&gt;2.  If parent is not NULL, and both child1 and child2 are NULL, returns a child of parent.&lt;br&gt;3.  If parent and child1 are not NULL, and child2 is NULL, returns a child of parent greater than child1.&lt;br&gt;4.  If parent and child2 are not NULL and child1 is NULL, returns a child of parent less than child2.&lt;br&gt;5.  If parent, child1, and child2 are all not NULL, returns a child of parent greater than child1 and less than child2.&lt;br&gt;6.  If child1 or child2 is not NULL but is not a child of parent, an exception is raised.&lt;br&gt;7.  If child1 &amp;gt;= child2, an exception is raised.&lt;br&gt;GetLevel()&lt;br&gt;This method is useful to find the Level of the current node.&lt;br&gt;Syntax: node.GetLevel ( )&lt;br&gt;This function will return an integer that represents the depth of this node in the current tree.&lt;br&gt;GetRoot()&lt;br&gt;This method will return the root of the hierarchy tree and this is a static method if you are using it within CLR.&lt;br&gt;Syntax: hierarchyid::GetRoot ( )&lt;br&gt;It will return the data type hierarchyID.&lt;br&gt;IsDescendant()&lt;br&gt;This method returns true/false (BIT) if the node is a descendant of the parent.&lt;br&gt;Syntax: parent.IsDescendant ( child )&lt;br&gt;Parse()&lt;br&gt;Parse converts the canonical string representation of a hierarchyid to a hierarchyid value. Parse is called implicitly when a conversion from a string type to hierarchyid occurs. Acts as the opposite of ToString(). Parse() is a static method.&lt;br&gt;Syntax: hierarchyid::Parse ( input )&lt;br&gt;Read()&lt;br&gt;Read reads binary representation of SqlHierarchyId from the passed-in BinaryReader and sets the SqlHierarchyId object to that value. Read cannot be called by using Transact-SQL. Use CAST or CONVERT instead.&lt;br&gt;Syntax: void Read( BinaryReader r )&lt;br&gt;Reparent()&lt;br&gt;This is a very useful method which helps you to reparent a node i.e. suppose if we want to align an existing node to a new parent or any other existing parent then this method is very useful.&lt;br&gt;Syntax: node.Reparent ( oldRoot, newRoot )&lt;br&gt;ToString()&lt;br&gt;This method is useful to get the string representation of the HierarchyID. The method returns a string that is a nvarchar(4000) data type.&lt;br&gt;Syntax: node.ToString ( )&lt;br&gt;Write()&lt;br&gt;Write writes out a binary representation of SqlHierarchyId to the passed-in BinaryWriter. Write cannot be called by using Transact-SQL. Use CAST or CONVERT instead.&lt;br&gt;Syntax: void Write( BinaryWriter w )&lt;br&gt;Sample Code&lt;br&gt;Create Table and Index&lt;br&gt;Use AdventureWorksLT&lt;br&gt;Go&lt;br&gt;--Scheme Creation&lt;br&gt;Create Schema HumanResources&lt;br&gt;Go&lt;br&gt;--Table Creation&lt;br&gt;CREATE TABLE HumanResources.EmployeeDemo&lt;br&gt;(&lt;br&gt;OrgNode HIERARCHYID,&lt;br&gt;EmployeeID INT,&lt;br&gt;LoginID VARCHAR(100),&lt;br&gt;Title VARCHAR(200),&lt;br&gt;HireDate DATETIME&lt;br&gt;)&lt;br&gt;Go&lt;br&gt;--Index Creation&lt;br&gt;CREATE UNIQUE CLUSTERED INDEX idxEmployeeDemo&lt;br&gt;ON HumanResources.EmployeeDemo (OrgNode,EmployeeID)&lt;br&gt;&lt;br&gt;Data Insertion&lt;br&gt;--Insert First Row&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (hierarchyid                             GetRoot(), 1,&amp;#39;adventure-works\scott&amp;#39;, &amp;#39;CEO&amp;#39;, &amp;#39;3/11/05&amp;#39;) ;&lt;br&gt;Go&lt;br&gt;--Insert Second Row&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;SELECT @Manager = hierarchyid                           GetRoot() FROM HumanResources.EmployeeDemo;&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(NULL,NULL), 2, &amp;#39;adventure-works\Mark&amp;#39;,&lt;br&gt;&amp;#39;CTO&amp;#39;, &amp;#39;4/05/07&amp;#39;)&lt;br&gt;Go&lt;br&gt;--Insert Third Row&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;DECLARE @FirstChild hierarchyid&lt;br&gt;SELECT @Manager = hierarchyid                           GetRoot() FROM HumanResources.EmployeeDemo;&lt;br&gt;Select @FirstChild = @Manager.GetDescendant(NULL,NULL)&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(@FirstChild,NULL), 3, &amp;#39;adventure-works\ravi&amp;#39;,&lt;br&gt;&amp;#39;Director Marketing&amp;#39;, &amp;#39;4/08/07&amp;#39;)&lt;br&gt;Go&lt;br&gt;--Insert the First Descendant of a Child Node&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;SELECT @Manager = CAST(&amp;#39;/1/&amp;#39; AS hierarchyid)&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(NULL, NULL),45,&lt;br&gt;&amp;#39;adventure-works\Ben&amp;#39;,&amp;#39;Application Developer&amp;#39;, &amp;#39;6/11/07&amp;#39;) ;&lt;br&gt;Go&lt;br&gt;--Insert the Second Descendant of a Child Node&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;DECLARE @FirstChild hierarchyid&lt;br&gt;SELECT @Manager = CAST(&amp;#39;/1/&amp;#39; AS hierarchyid)&lt;br&gt;SELECT @FirstChild = @Manager.GetDescendant(NULL,NULL)&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(@FirstChild, NULL),55,&lt;br&gt;&amp;#39;adventure-works\Laura&amp;#39;,&amp;#39;Trainee Developer&amp;#39;, &amp;#39;6/11/07&amp;#39;) ;&lt;br&gt;Go&lt;br&gt;--Insert the first node who is the Descendant of Director Marketing&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;DECLARE @FirstChild hierarchyid&lt;br&gt;SELECT @Manager = CAST(&amp;#39;/2/&amp;#39; AS hierarchyid)&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(NULL, NULL),551,&lt;br&gt;&amp;#39;adventure-works\frank&amp;#39;,&amp;#39;Trainee Sales Exec.&amp;#39;, &amp;#39;12/11/07&amp;#39;) ;&lt;br&gt;Go&lt;br&gt;--Insert the second node who is the Descendant of Director Marketing&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;DECLARE @FirstChild hierarchyid&lt;br&gt;SELECT @Manager = CAST(&amp;#39;/2/&amp;#39; AS hierarchyid)&lt;br&gt;SELECT @FirstChild = @Manager.GetDescendant(NULL,NULL)&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(@FirstChild, NULL),531,&lt;br&gt;&amp;#39;adventure-works\vijay&amp;#39;,&amp;#39;Manager Industrial Sales&amp;#39;, &amp;#39;12/09/06&amp;#39;) ;&lt;br&gt;Go&lt;br&gt;--Insert the third node who is the Descendant of Director Marketing&lt;br&gt;--in between 2 existing descendants&lt;br&gt;DECLARE @Manager hierarchyid&lt;br&gt;DECLARE @FirstChild hierarchyid&lt;br&gt;DECLARE @SecondChild hierarchyid&lt;br&gt;SELECT @Manager = CAST(&amp;#39;/2/&amp;#39; AS hierarchyid)&lt;br&gt;SELECT @FirstChild = @Manager.GetDescendant(NULL,NULL)&lt;br&gt;SELECT @SecondChild = @Manager.GetDescendant(@FirstChild,NULL)&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES (@Manager.GetDescendant(@FirstChild, @SecondChild),543,&lt;br&gt;&amp;#39;adventure-works\james&amp;#39;,&amp;#39;Manager Consumer Sales&amp;#39;, &amp;#39;12/04/06&amp;#39;) ;&lt;br&gt;&lt;br&gt;Procedure to insert Employee Record&lt;br&gt;--Use Serializable Transaction&lt;br&gt;CREATE PROCEDURE AddEmployee(@ManagerID hierarchyid, @EmpID int,&lt;br&gt;@LogID varchar(100), @JobTitle as varchar(200), @JoiningDate datetime)&lt;br&gt;AS&lt;br&gt;BEGIN&lt;br&gt;DECLARE @LastChild hierarchyid&lt;br&gt;SET TRANSACTION ISOLATION LEVEL SERIALIZABLE&lt;br&gt;BEGIN TRANSACTION&lt;br&gt;SELECT @LastChild = Max(OrgNode) From HumanResources.EmployeeDemo&lt;br&gt;WHERE OrgNode = @ManagerID&lt;br&gt;INSERT HumanResources.EmployeeDemo (OrgNode, EmployeeID, LoginID, Title, HireDate)&lt;br&gt;VALUES(@LastChild, @EmpID,@LogID , @JobTitle, @JoiningDate)&lt;br&gt;COMMIT&lt;br&gt;END ;&lt;br&gt;&lt;br&gt;Hope you like this article I will write more about HierarchyID very soon. If you like the article or have any doubts then drop me an post.&lt;br&gt;I am attaching the sample SQL Script along so that you can test it in your test environment.</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/1379447303427580628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/1379447303427580628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/1379447303427580628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/1379447303427580628'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/05/sql-server-2008-hierarchyid-part-i.html' title='SQL Server 2008 - HierarchyID - Part I'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifBSkSeS_RFAMz7Z-P_SlZtVC2PH0m7lP9BpSDk5BVwDrPyg_u1MsUCXAzuiVOAXtM7k1PE1_ZC6fkZ253M8hzOEbeEfAmnBha53SyHwSe9N5oY26z97cO_ALzA5OXFhgyrTq9uxiXCks8/s72-c/image001-729448.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-4853915730079574052</id><published>2012-05-21T19:45:00.000+05:30</published><updated>2012-05-21T19:47:49.030+05:30</updated><title type='text'>SQL: How Can I Sort A &#39;Version Number&#39; Column Generically Using a SQL Server Query  : Good One</title><content type='html'>&lt;a href=&quot;http://stackoverflow.com/questions/3474870/how-can-i-sort-a-version-number-column-generically-using-a-sql-server-query&quot;&gt;http://stackoverflow.com/questions/3474870/how-can-i-sort-a-version-number-column-generically-using-a-sql-server-query&lt;/a&gt;&lt;br&gt;&lt;br&gt;How Can I Sort A &amp;#39;Version Number&amp;#39; Column Generically Using a SQL Server Query&amp;lt;&lt;a href=&quot;http://stackoverflow.com/questions/3474870/how-can-i-sort-a-version-number-column-generically-using-a-sql-server-query&quot;&gt;http://stackoverflow.com/questions/3474870/how-can-i-sort-a-version-number-column-generically-using-a-sql-server-query&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;2down votefavorite&amp;lt;&lt;a href=&quot;http://stackoverflow.com/questions/3474870/how-can-i-sort-a-version-number-column-generically-using-a-sql-server-query&quot;&gt;http://stackoverflow.com/questions/3474870/how-can-i-sort-a-version-number-column-generically-using-a-sql-server-query&lt;/a&gt;&amp;gt;&lt;br&gt;1&lt;br&gt;share [g+]share [fb]share [tw]&lt;br&gt;&lt;br&gt;&lt;br&gt;I wonder if the SQL geniuses amongst us could lend me a helping hand.&lt;br&gt;&lt;br&gt;I have a column VersionNo in a table Versions that contains &amp;#39;version number&amp;#39; values like&lt;br&gt;&lt;br&gt;VersionNo&lt;br&gt;&lt;br&gt;---------&lt;br&gt;&lt;br&gt;1.2.3.1&lt;br&gt;&lt;br&gt;1.10.3.1&lt;br&gt;&lt;br&gt;1.4.7.2&lt;br&gt;&lt;br&gt;etc.&lt;br&gt;&lt;br&gt;I am looking to sort this, but unfortunately, when I do a standard order by, it is treated as a string, so the order comes out as&lt;br&gt;&lt;br&gt;VersionNo&lt;br&gt;&lt;br&gt;---------&lt;br&gt;&lt;br&gt;1.10.3.1&lt;br&gt;&lt;br&gt;1.2.3.1&lt;br&gt;&lt;br&gt;1.4.7.2&lt;br&gt;&lt;br&gt;Intead of the following, which is what I am after:&lt;br&gt;&lt;br&gt;VersionNo&lt;br&gt;&lt;br&gt;---------&lt;br&gt;&lt;br&gt;1.2.3.1&lt;br&gt;&lt;br&gt;1.4.7.2&lt;br&gt;&lt;br&gt;1.10.3.1&lt;br&gt;&lt;br&gt;So, what I need to do is to sort by the numbers in reverse order (e.g. in a.b.c.d, I need to sort by d,c,b,a to get the correct sort ourder).&lt;br&gt;&lt;br&gt;But I am stuck as to how to achieve this in a GENERIC way. Sure, I can split the string up using the various sql functions (e.g. left, right, substring, len, charindex), but I can&amp;#39;t guarantee that there will always be 4 parts to the version number. I may have a list like this:&lt;br&gt;&lt;br&gt;VersionNo&lt;br&gt;&lt;br&gt;---------&lt;br&gt;&lt;br&gt;1.2.3.1&lt;br&gt;&lt;br&gt;1.3&lt;br&gt;&lt;br&gt;1.4.7.2&lt;br&gt;&lt;br&gt;1.7.1&lt;br&gt;&lt;br&gt;1.10.3.1&lt;br&gt;&lt;br&gt;1.16.8.0.1&lt;br&gt;&lt;br&gt;Can, does anyone have any suggestions? Your help would be much appreciated.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Answer:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;If You are using SQL Server 2008&lt;br&gt;&lt;br&gt;select VersionNo from Versions order by cast(&amp;#39;/&amp;#39; + replace(VersionNo , &amp;#39;.&amp;#39;, &amp;#39;/&amp;#39;) + &amp;#39;/&amp;#39; as hierarchyid);&lt;br&gt;&lt;br&gt;What is hierarchyid&amp;lt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb677290.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/bb677290.aspx&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Edit:&lt;br&gt;&lt;br&gt;Solutions for 2000, 2005, 2008: Solutions to T-SQL Sorting Challenge here&amp;lt;&lt;a href=&quot;http://www.sqlmag.com/article/sql-server/solutions-to-t-sql-sorting-challenge.aspx&quot;&gt;http://www.sqlmag.com/article/sql-server/solutions-to-t-sql-sorting-challenge.aspx&lt;/a&gt;&amp;gt;.&lt;br&gt;&lt;br&gt;The challenge&amp;lt;&lt;a href=&quot;http://www.sqlmag.com/article/sql-server/t-sql-sorting-challenge.aspx&quot;&gt;http://www.sqlmag.com/article/sql-server/t-sql-sorting-challenge.aspx&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Note:&lt;br&gt;&lt;br&gt;In SQL Server 2008 things are drastically simpler. With slight adjustment of the dot separated list of values, you get the canonical string representation a HIERARCHYID value. Either replace all dots in the string with slashes and add a slash at the beginning and end of the string, or simply add a slash at the beginning and end of the string. Either way, convert the adjusted string to HIERARCHYID, and the values would naturally sort correctly based on the integer values in the string segments. Several people came with such a solution: Razvan Socol, Pawel Potasinski, Peter DeBetta and myself. Here are two examples based on this approach:&lt;br&gt;select val&lt;br&gt;from dbo.t1&lt;br&gt;order by cast(&amp;#39;/&amp;#39; + replace(val, &amp;#39;.&amp;#39;, &amp;#39;/&amp;#39;) + &amp;#39;/&amp;#39; as hierarchyid);&lt;br&gt;&lt;br&gt;&lt;br&gt;select val&lt;br&gt;from dbo.t1&lt;br&gt;order by cast(&amp;#39;/&amp;#39; + val + &amp;#39;/&amp;#39; as hierarchyid);</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/4853915730079574052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/4853915730079574052' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4853915730079574052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/4853915730079574052'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/05/sql-how-can-i-sort-version-number.html' title='SQL: How Can I Sort A &#39;Version Number&#39; Column Generically Using a SQL Server Query  : Good One'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-8888723976978345482</id><published>2012-03-02T12:10:00.001+05:30</published><updated>2012-03-02T12:10:45.115+05:30</updated><title type='text'>SQL SERVER - How To Handle Deadlock: Nice Example</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7M5UDY1GuaXU62JSjc6yD1e4iFIB6YTTpZ4FBwrzw1P7QvyDRapI2OAlHeSEHIX0oUn3hLKIVnlG-Drw9CjQpkMneZ9okRz9QyDM1AKg7bCUK0KIkgNMpVHJFKR9el9xBCjliSMJGfSY3/s1600/image001-745116.gif&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7M5UDY1GuaXU62JSjc6yD1e4iFIB6YTTpZ4FBwrzw1P7QvyDRapI2OAlHeSEHIX0oUn3hLKIVnlG-Drw9CjQpkMneZ9okRz9QyDM1AKg7bCUK0KIkgNMpVHJFKR9el9xBCjliSMJGfSY3/s320/image001-745116.gif&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5715186045230582050&quot; /&gt;&lt;/a&gt;&lt;/p&gt;SQL SERVER - How To Handle Deadlock&lt;br&gt;By Nitin Chilka&amp;lt;&lt;a href=&quot;http://www.codeproject.com/script/Membership/View.aspx?mid=3897642&quot;&gt;http://www.codeproject.com/script/Membership/View.aspx?mid=3897642&lt;/a&gt;&amp;gt; | 22 Sep 2009&lt;br&gt;SQL2005&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=30&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=30&lt;/a&gt;&amp;gt;SQL&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=93&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=93&lt;/a&gt;&amp;gt;Windows&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=94&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=94&lt;/a&gt;&amp;gt;SQL-Server&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=101&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=101&lt;/a&gt;&amp;gt;DBA&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=117&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=117&lt;/a&gt;&amp;gt;Dev&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=118&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=118&lt;/a&gt;&amp;gt;Intermediate&amp;lt;&lt;a href=&quot;http://www.codeproject.com/search.aspx?aidlst=153&quot;&gt;http://www.codeproject.com/search.aspx?aidlst=153&lt;/a&gt;&amp;gt;&lt;br&gt;An article on how to handle deadlock&lt;p&gt;Introduction&lt;p&gt;A deadlock is a situation wherein two transactions wait for each other to give up their respective locks.&lt;p&gt;When this happens, the SQL Server ends the deadlock by automatically choosing one and aborting the process, allowing the other process to continue. The aborted transaction is rolled back and an error message is sent to the user of the aborted process. Generally, the transaction that requires the least amount of overhead to rollback is the transaction that is aborted.&lt;p&gt;This article will explain how to handle deadlocks in a user-friendly way.&lt;p&gt;The Deadlock&lt;p&gt;Transaction A attempts to update table 1 and subsequently read/update data from table 2, whereas transaction B attempts to update table 2 and subsequently read/update data from table 1. In such situations, transaction A holds locks that transaction B needs to complete its task and vice versa; neither transaction can complete until the other transaction releases locks.&lt;p&gt;The Deadlock Situation&lt;p&gt;The below example shows the deadlock situation between the two transactions.&lt;p&gt;Transaction A&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt; BEGIN TRANSACTION&lt;p&gt;&lt;p&gt; UPDATE Customer SET LastName = &amp;#39;John&amp;#39; WHERE CustomerId=111&lt;p&gt; WAITFOR DELAY &amp;#39;00:00:05&amp;#39; -- Wait for 5 ms&lt;p&gt; UPDATE Orders SET CustomerId = 1 WHERE OrderId = 221&lt;p&gt;&lt;p&gt; COMMIT TRANSACTION&lt;p&gt;Transaction B&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt; BEGIN TRANSACTION&lt;p&gt;&lt;p&gt; UPDATE Orders SET ShippingId = 12 WHERE OrderId = 221&lt;p&gt; WAITFOR DELAY &amp;#39;00:00:05&amp;#39; -- Wait for 5 ms&lt;p&gt; UPDATE Customer SET FirstName = &amp;#39;Mike&amp;#39; WHERE CustomerId=111&lt;p&gt;&lt;p&gt; COMMIT TRANSACTION&lt;p&gt;If both the transactions are executed at the same time, then Transaction A locks and updates Customer table whereas transaction B locks and updates Orders table. After a delay of 5 ms, transaction A looks for the lock on Orders table which is already held by transaction B and transaction B looks for lock on Customer table which is held by transaction A. So both the transactions cannot proceed further, the deadlock occurs and the SQL server returns the error message 1205 for the aborted transaction.&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;(1 row(s) affected)&lt;p&gt;Msg 1205, Level 13, State 45, Line 5&lt;p&gt;Transaction (Process ID 52) was deadlocked on lock resources with&lt;p&gt;another process and has been chosen as the deadlock victim.&lt;p&gt;Rerun the transaction.&lt;p&gt;But what if you don&amp;#39;t like the default behavior (aborting the transaction)? Can you change it? Yes, you can, by rewriting Transactions A and B as shown below.&lt;p&gt;Transaction A&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;RETRY: -- Label RETRY&lt;p&gt;BEGIN TRANSACTION&lt;p&gt;BEGIN TRY&lt;p&gt;&lt;p&gt;         UPDATE Customer SET LastName = &amp;#39;John&amp;#39; WHERE CustomerId=111&lt;p&gt;         WAITFOR DELAY &amp;#39;00:00:05&amp;#39;  -- Wait for 5 ms&lt;p&gt;         UPDATE Orders SET CustomerId = 1 WHERE OrderId = 221&lt;p&gt;&lt;p&gt;         COMMIT TRANSACTION&lt;p&gt;END TRY&lt;p&gt;BEGIN CATCH&lt;p&gt;         PRINT &amp;#39;Rollback Transaction&amp;#39;&lt;p&gt;         ROLLBACK TRANSACTION&lt;p&gt;         IF ERROR_NUMBER() = 1205 -- Deadlock Error Number&lt;p&gt;         BEGIN&lt;p&gt;                 WAITFOR DELAY &amp;#39;00:00:00.05&amp;#39; -- Wait for 5 ms&lt;p&gt;                 GOTO RETRY -- Go to Label RETRY&lt;p&gt;         END&lt;p&gt;END CATCH&lt;p&gt;Transaction B&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;RETRY: -- Label RETRY&lt;p&gt;BEGIN TRANSACTION&lt;p&gt;BEGIN TRY&lt;p&gt;         UPDATE Orders SET ShippingId = 12 Where OrderId = 221&lt;p&gt;         WAITFOR DELAY &amp;#39;00:00:05&amp;#39; -- Wait for 5 ms&lt;p&gt;         UPDATE Customer SET FirstName = &amp;#39;Mike&amp;#39; WHERE CustomerId=111&lt;p&gt;&lt;p&gt;         COMMIT TRANSACTION&lt;p&gt;END TRY&lt;p&gt;BEGIN CATCH&lt;p&gt;         PRINT &amp;#39;Rollback Transaction&amp;#39;&lt;p&gt;         ROLLBACK TRANSACTION&lt;p&gt;         IF ERROR_NUMBER() = 1205 -- Deadlock Error Number&lt;p&gt;         BEGIN&lt;p&gt;                 WAITFOR DELAY &amp;#39;00:00:00.05&amp;#39; -- Wait for 5 ms&lt;p&gt;                 GOTO RETRY -- Go to Label RETRY&lt;p&gt;         END&lt;p&gt;END CATCH&lt;p&gt;Here I have used Label RETRY at the beginning of both the transactions. The TRY/CATCH method is used to handle the exceptions in the transactions. If the code within the TRY block fails, the control automatically jumps to the CATCH block, letting the transaction roll back, and if the exception is occurred due to deadlock (Error_Number 1205), the transaction waits for 5 milliseconds. The delay is used here because the other transaction (which is not aborted) can complete its operation within delay duration and release the lock on the table which was required by the aborted transaction. You can increase the delay according to the size of your transactions. After the delay, the transaction starts executing from the beginning (RETRY: Label RETRY at the beginning of the transaction) using the below statement:&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;GOTO RETRY -- Go to Label RETRY&lt;p&gt;This statement is used to transfer the control to the label named RETRY (which is at the beginning).&lt;p&gt;Now Execute the Transaction A and Transaction B at the same time. Both the transactions will execute successfully. Have a look into the outputs of the transaction where the exception occurred.&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;(1 row(s) affected)&lt;p&gt;Rollback Transaction&lt;p&gt;&lt;p&gt;(1 row(s) affected)&lt;p&gt;&lt;p&gt;(1 row(s) affected)&lt;p&gt;Using RetryCounter&lt;p&gt;Now, I guess you understood how to handle deadlock without aborting the transaction. Let&amp;#39;s move to the next interesting topic about deadlock. Imagine if there are more than two processes that read/update the Customer or Orders table at the same time. Below, I have modified both the transactions where I have shown how we can use RetryCounter to solve the problem.&lt;p&gt;Transaction A&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;DECLARE @RetryCounter INT&lt;p&gt;SET @RetryCounter = 1&lt;p&gt;RETRY: -- Label RETRY&lt;p&gt;BEGIN TRANSACTION&lt;p&gt;BEGIN TRY&lt;p&gt;&lt;p&gt;         UPDATE Customer SET LastName = &amp;#39;John&amp;#39; WHERE CustomerId=111&lt;p&gt;         WAITFOR DELAY &amp;#39;00:00:05&amp;#39;  -- Wait for 5 ms&lt;p&gt;         UPDATE Orders SET CustomerId = 1 WHERE OrderId = 221&lt;p&gt;&lt;p&gt;         COMMIT TRANSACTION&lt;p&gt;END TRY&lt;p&gt;BEGIN CATCH&lt;p&gt;         PRINT &amp;#39;Rollback Transaction&amp;#39;&lt;p&gt;         ROLLBACK TRANSACTION&lt;p&gt;         DECLARE @DoRetry bit; -- Whether to Retry transaction or not&lt;p&gt;         DECLARE @ErrorMessage varchar(500)&lt;p&gt;         SET @doRetry = 0;&lt;p&gt;         SET @ErrorMessage = ERROR_MESSAGE()&lt;p&gt;         IF ERROR_NUMBER() = 1205 -- Deadlock Error Number&lt;p&gt;         BEGIN&lt;p&gt;                 SET @doRetry = 1; -- Set @doRetry to 1 only for Deadlock&lt;p&gt;         END&lt;p&gt;         IF @DoRetry = 1&lt;p&gt;         BEGIN&lt;p&gt;                 SET @RetryCounter = @RetryCounter + 1 -- Increment Retry Counter By one&lt;p&gt;                 IF (@RetryCounter &amp;gt; 3) -- Check whether Retry Counter reached to 3&lt;p&gt;                 BEGIN&lt;p&gt;                          RAISERROR(@ErrorMessage, 18, 1) -- Raise Error Message if&lt;p&gt;                                   -- still deadlock occurred after three retries&lt;p&gt;                 END&lt;p&gt;                 ELSE&lt;p&gt;                 BEGIN&lt;p&gt;                          WAITFOR DELAY &amp;#39;00:00:00.05&amp;#39; -- Wait for 5 ms&lt;p&gt;                          GOTO RETRY       -- Go to Label RETRY&lt;p&gt;                 END&lt;p&gt;         END&lt;p&gt;         ELSE&lt;p&gt;         BEGIN&lt;p&gt;                 RAISERROR(@ErrorMessage, 18, 1)&lt;p&gt;         END&lt;p&gt;END CATCH&lt;p&gt;Transaction B&lt;br&gt;[cid:image001.gif@01CCF86D.7391A3F0]Collapse | Copy Code&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;&amp;gt;&lt;p&gt;DECLARE @RetryCounter INT&lt;p&gt;SET @RetryCounter = 1&lt;p&gt;RETRY: -- Label RETRY&lt;p&gt;BEGIN TRANSACTION&lt;p&gt;BEGIN TRY&lt;p&gt;         UPDATE Orders SET ShippingId = 12 Where OrderId = 221&lt;p&gt;         WAITFOR DELAY &amp;#39;00:00:05&amp;#39; -- Wait for 5 ms&lt;p&gt;         UPDATE Customer SET FirstName = &amp;#39;Mike&amp;#39; WHERE CustomerId=111&lt;p&gt;         COMMIT TRANSACTION&lt;p&gt;END TRY&lt;p&gt;BEGIN CATCH&lt;p&gt;         PRINT &amp;#39;Rollback Transaction&amp;#39;&lt;p&gt;         ROLLBACK TRANSACTION&lt;p&gt;         DECLARE @DoRetry bit; -- Whether to Retry transaction or not&lt;p&gt;         DECLARE @ErrorMessage varchar(500)&lt;p&gt;         SET @doRetry = 0;&lt;p&gt;         SET @ErrorMessage = ERROR_MESSAGE()&lt;p&gt;         IF ERROR_NUMBER() = 1205 -- Deadlock Error Number&lt;p&gt;         BEGIN&lt;p&gt;                 SET @doRetry = 1; -- Set @doRetry to 1 only for Deadlock&lt;p&gt;         END&lt;p&gt;         IF @DoRetry = 1&lt;p&gt;         BEGIN&lt;p&gt;                 SET @RetryCounter = @RetryCounter + 1 -- Increment Retry Counter By one&lt;p&gt;                 IF (@RetryCounter &amp;gt; 3) -- Check whether Retry Counter reached to 3&lt;p&gt;                 BEGIN&lt;p&gt;                          RAISERROR(@ErrorMessage, 18, 1) -- Raise Error Message&lt;p&gt;                                   -- if still deadlock occurred after three retries&lt;p&gt;                 END&lt;p&gt;                 ELSE&lt;p&gt;                 BEGIN&lt;p&gt;                          WAITFOR DELAY &amp;#39;00:00:00.05&amp;#39; -- Wait for 5 ms&lt;p&gt;                          GOTO RETRY       -- Go to Label RETRY&lt;p&gt;                 END&lt;p&gt;         END&lt;p&gt;         ELSE&lt;p&gt;         BEGIN&lt;p&gt;                 RAISERROR(@ErrorMessage, 18, 1)&lt;p&gt;         END&lt;p&gt;END CATCH&lt;p&gt;The RetryCounter variable used here gives a chance for the transaction to execute again if it fails due to deadlock (Error_Number 1205). In this example, the transaction can try to execute up to three times if it fails due to a deadlock. This scenario would be very useful if the transaction looking for the lock which was not released by the other transactions for a long time. So the transaction can try three times to check whether the required lock is available.&lt;p&gt;History&lt;p&gt; *   20th September, 2009: Initial version&lt;p&gt;License&lt;p&gt;This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)&amp;lt;&lt;a href=&quot;http://www.codeproject.com/info/cpol10.aspx&quot;&gt;http://www.codeproject.com/info/cpol10.aspx&lt;/a&gt;&amp;gt;&lt;p&gt;About the Author&lt;br&gt;Nitin Chilka&amp;lt;&lt;a href=&quot;http://www.codeproject.com/Members/Nitin-Chilka&quot;&gt;http://www.codeproject.com/Members/Nitin-Chilka&lt;/a&gt;&amp;gt;&lt;p&gt;&lt;p&gt;References:&lt;p&gt;&lt;a href=&quot;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&quot;&gt;http://www.codeproject.com/Articles/42547/SQL-SERVER-How-To-Handle-Deadlock&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/8888723976978345482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/8888723976978345482' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/8888723976978345482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/8888723976978345482'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/03/sql-server-how-to-handle-deadlock-nice.html' title='SQL SERVER - How To Handle Deadlock: Nice Example'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7M5UDY1GuaXU62JSjc6yD1e4iFIB6YTTpZ4FBwrzw1P7QvyDRapI2OAlHeSEHIX0oUn3hLKIVnlG-Drw9CjQpkMneZ9okRz9QyDM1AKg7bCUK0KIkgNMpVHJFKR9el9xBCjliSMJGfSY3/s72-c/image001-745116.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-6123329328085813359</id><published>2012-02-20T12:27:00.001+05:30</published><updated>2012-02-20T12:27:51.153+05:30</updated><title type='text'>JOB: &quot;Star F.A.D. Technology Pvt. Ltd.&quot; Interviews.</title><content type='html'>&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;&lt;div class=&quot;HOEnZb&quot;&gt;&lt;div class=&quot;h5&quot;&gt;&lt;div class=&quot;gmail_quote&quot;&gt;---------- Forwarded message ----------&lt;br&gt;From: &lt;b class=&quot;gmail_sendername&quot;&gt;Varadhi Software&lt;/b&gt; &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;mailto:varadhi.soft@gmail.com&quot; target=&quot;_blank&quot;&gt;varadhi.soft@gmail.com&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  Date: Mon, Feb 20, 2012 at 11:58 AM&lt;br&gt;Subject: Fwd: Fw: &amp;quot;Star F.A.D. Technology Pvt. Ltd.&amp;quot; Interviews.&lt;br&gt;To: &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt; &lt;div&gt; &lt;div style=&quot;font-family:times new roman,new york,times,serif;font-size:12pt&quot;&gt; &lt;div style=&quot;font-family:times new roman,new york,times,serif;font-size:12pt&quot;&gt; &lt;div style=&quot;font-family:times new roman,new york,times,serif;font-size:12pt&quot;&gt; &lt;div dir=&quot;ltr&quot;&gt;Dear Sir/Madam,&lt;br&gt;&lt;br&gt;     In our organization (&amp;quot;Star FAD Technology Pvt. Ltd.&amp;quot;) we have 6 vacancies. Anybody who ever is interested (male or female) qualified with Intermediate and any degree pass or fail with any computer course is eligible(Any Multimedia course is more preferable).&lt;br&gt;   &lt;br&gt;     This is regarding computer editing and mixing job. Age limit is 18years to 25years. If the candidate is selected, the we give training for 15days (In this training period 50% salary would be paid to the selected candidates). Monthly salary would be 25000/-. Monday to Friday are working days and timing is 10am to 6pm.&lt;br&gt;   &lt;br&gt;&lt;br&gt;      Firstly we give agreement for 1year when a person joins. If his or her performance is good we extend the period upto five years and also every year salary will be hike up to 20%.&lt;br&gt;&lt;br&gt;      So, Interested candidates can come on Sunday to Wednesday 10am to 7pm i.e. on Feb 19th, 20th, 21th, 22nd &amp;amp; 23rd which is the last date of the interview . You should bring your last completed educational qualified certificate and also certificates of any completed computer courses &amp;amp; 2 passport size photos with an appropriate resume (Your certificates should be only xerox copies).&lt;br&gt;   &lt;br&gt;[Note:&amp;#39; This is not placement service this is our company openings only&amp;#39; and also give this message to friends, collegues and to all ur students. In these selected candidates will be sent to US after one year if their performance is good in their work]&lt;br&gt;   &lt;br&gt; Thanking you Sir/Madam,&lt;br&gt;&lt;br&gt;M.Rajkumar Chowdary,.(Chairman &amp;amp; Director)&lt;br&gt;&lt;br&gt;&amp;quot;Star FAD Technology Pvt. Ltd.&amp;quot;&lt;br&gt;&lt;br&gt;Interview Place:&lt;br&gt;Star F.A.D. Technology Pvt. Ltd.&lt;br&gt;V.V. Complex, Above Syndicate Bank,&lt;br&gt;   4th Floor, Near Kalanikethan,&lt;br&gt;Chaitanyapuri,&lt;br&gt;Dilsukhnagar,&lt;br&gt;Hyderabad.&lt;br&gt;&lt;br&gt;Contact No. 9705266097 &lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt;&lt;br&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/6123329328085813359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/6123329328085813359' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/6123329328085813359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/6123329328085813359'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/02/job-star-fad-technology-pvt-ltd.html' title='JOB: &quot;Star F.A.D. Technology Pvt. Ltd.&quot; Interviews.'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-1008237670510708472</id><published>2012-01-20T20:32:00.001+05:30</published><updated>2012-01-20T20:32:24.194+05:30</updated><title type='text'>SQL : Row-By-Row Processing Without Cursor</title><content type='html'>Row-By-Row Processing Without Cursor&lt;p&gt;&lt;p&gt;Here is the Logic.....&lt;br&gt;--Create a Table Variable and Variable Counter&lt;p&gt;DECLARE @InitialTable TABLE(RowNo INT IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED, Field1 int, Field2 Int)&lt;br&gt;DECLARE @IncrementalCounter INT &amp;#39;This variable is declare for Loop&lt;p&gt;--All values are inserted into Your Table Variable ........&lt;br&gt;Insert into @InitialTable (field1, Feld2)&lt;br&gt;Select A1, A2 from Your_Table Where Your_Condition&lt;br&gt;----------------------------------------------------------&lt;br&gt;--Initialize the Counter&lt;br&gt;SET @IncrementalCounter = 1&lt;br&gt;--Condition of Checking the No of records to be traverse&lt;br&gt;while @IncrementalCounter &amp;lt;= ISNULL((SELECT COUNT(RowNo) FROM @InitialTable),0)&lt;br&gt;BEGIN&lt;br&gt;--Here we set the variable value to the @variable&lt;br&gt;SELECT @Variable = Field1 FROM @InitalTable where RowNo = @IncrementalCounter&lt;p&gt;SET @IncrementalCounter = @incrementalCounter +1&lt;br&gt;END&lt;p&gt;&lt;br&gt;Reference:&lt;p&gt;&lt;a href=&quot;http://www.sqlservercentral.com/Forums/Topic327280-319-1.aspx&quot;&gt;http://www.sqlservercentral.com/Forums/Topic327280-319-1.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/1008237670510708472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/1008237670510708472' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/1008237670510708472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/1008237670510708472'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2012/01/sql-row-by-row-processing-without.html' title='SQL : Row-By-Row Processing Without Cursor'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-3915528457237504220</id><published>2011-11-30T17:08:00.001+05:30</published><updated>2011-11-30T17:08:37.849+05:30</updated><title type='text'>JOB in Aricent : Walk-in interviews for Senior Engineer /Technical Leader (Testing) on December 3, 2011 -  Gurgaon</title><content type='html'>&lt;p class=&quot;mobile-photo&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnqB4bMbIl7s8jUogi-9PV8LcSqXAV3-S4Wg5rpqgTq7YE72bKkzZHxBawR1OiMxecLfn2aN2d7aF-WVgpBREkilZ6JlV0YWyLBwecW62U4pk12YMFqQlN1WwWfJDVHSlXe_LVbx3FKCkp/s1600/ATT00002-717850.jpg&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnqB4bMbIl7s8jUogi-9PV8LcSqXAV3-S4Wg5rpqgTq7YE72bKkzZHxBawR1OiMxecLfn2aN2d7aF-WVgpBREkilZ6JlV0YWyLBwecW62U4pk12YMFqQlN1WwWfJDVHSlXe_LVbx3FKCkp/s320/ATT00002-717850.jpg&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5680751889970545554&quot; /&gt;&lt;/a&gt;&lt;/p&gt;From: Suchi Gupta&lt;br&gt;&lt;br&gt;&lt;br&gt;From: Aricent IT On Behalf Of HR_TA_iRefer&lt;br&gt;Sent: Wednesday, November 30, 2011 4:03 PM&lt;br&gt;Subject: Walk-in interviews for Senior Engineer /Technical Leader (Testing) on December 3, 2011 - Gurgaon&lt;br&gt;&lt;br&gt;&lt;br&gt;[cid:_2_071B09B8071B0450003D856B65257958]&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Dear Friends,&lt;br&gt;&lt;br&gt;We are in the process of hiring testing professionals for Senior Engineer –Testing/Technical Leader-Testing role.  Please refer your friends and relatives whose profiles match with the following requirements to participate in the selection process.&lt;br&gt;&lt;br&gt;Job Title: Senior Engineer-Testing/Technical Leader-Testing&lt;br&gt;&lt;br&gt;Job Location: Gurgaon&lt;br&gt;&lt;br&gt;Qualification: B.E / B.Tech / M.Tech / MCA&lt;br&gt;&lt;br&gt;Experience:  3 - 7 years&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Job Code&lt;br&gt;&lt;br&gt;Designation&lt;br&gt;&lt;br&gt;Job Location&lt;br&gt;&lt;br&gt;Intranet Links&lt;br&gt;&lt;br&gt;Internet Links&lt;br&gt;&lt;br&gt;JOB931&lt;br&gt;&lt;br&gt;Senior Engineer - Testing (Test Administrator)&lt;br&gt;&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=932&quot;&gt;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=932&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=932&quot;&gt;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=932&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;JOB932&lt;br&gt;&lt;br&gt;Technical Leader - Testing (Configuration Lead)&lt;br&gt;&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=933&quot;&gt;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=933&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=933&quot;&gt;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=933&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;JOB933&lt;br&gt;&lt;br&gt;Senior Engineer - Testing (System Tester)&lt;br&gt;&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=934&quot;&gt;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=934&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=934&quot;&gt;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=934&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;JOB934&lt;br&gt;&lt;br&gt;Technical Leader - Testing (Routing/Switching)&lt;br&gt;&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=935&quot;&gt;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=935&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=935&quot;&gt;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=935&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;JOB935&lt;br&gt;&lt;br&gt;Technical Leader - Testing (Integration Engineer)&lt;br&gt;&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=936&quot;&gt;http://home.intra.aricent.com/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=936&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;Read More&amp;lt;&lt;a href=&quot;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=936&quot;&gt;https://vpn.aricent.com/+CSCO+1h756767633A2F2F75627A722E766167656E2E6E6576707261672E70627A++/functions/hr/Lists/iRefer%20Jobs/DispForm.aspx?ID=936&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Candidates meeting the eligibility criteria can appear for the selection process as per the below mentioned schedule:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Location&lt;br&gt;&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Date&lt;br&gt;&lt;br&gt;December 3, 2011 (Saturday)&lt;br&gt;&lt;br&gt;Time&lt;br&gt;&lt;br&gt;9:30 AM – 2:00 PM&lt;br&gt;&lt;br&gt;Venue&lt;br&gt;&lt;br&gt;Aricent Group&lt;br&gt;Plot 17,&lt;br&gt;Sector 18, Electronic City,&lt;br&gt;Gurgaon&lt;br&gt;&lt;br&gt;Contact Person&lt;br&gt;&lt;br&gt;Kamini Kinra&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Terms and Conditions:&lt;br&gt;•                   Freshers and 2011 graduates are not applicable&lt;br&gt;•                   Candidates will be expected to make their own arrangements for travel and accommodation&lt;br&gt;•                   To avail the referral bonus, candidates must mention the referrer&amp;#39;s employee ID at the time of interview&lt;br&gt;•                   All terms and conditions of the Aricent iRefer program will apply&lt;br&gt;&lt;br&gt;So hurry up &amp;amp; ask your referrals to avail this great opportunity!</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/3915528457237504220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/3915528457237504220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3915528457237504220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/3915528457237504220'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2011/11/job-in-aricent-walk-in-interviews-for.html' title='JOB in Aricent : Walk-in interviews for Senior Engineer /Technical Leader (Testing) on December 3, 2011 -  Gurgaon'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnqB4bMbIl7s8jUogi-9PV8LcSqXAV3-S4Wg5rpqgTq7YE72bKkzZHxBawR1OiMxecLfn2aN2d7aF-WVgpBREkilZ6JlV0YWyLBwecW62U4pk12YMFqQlN1WwWfJDVHSlXe_LVbx3FKCkp/s72-c/ATT00002-717850.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-2479109481907663182</id><published>2011-06-24T14:01:00.001+05:30</published><updated>2011-06-24T14:01:39.706+05:30</updated><title type='text'>THIS IS THE ONLY TIME WE WILL SEE AND LIVE THIS EVENT.......]</title><content type='html'>&lt;div class=&quot;gmail_quote&quot;&gt;From: &lt;b class=&quot;gmail_sendername&quot;&gt;Naveen kumar&lt;/b&gt; &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt; &lt;div class=&quot;gmail_quote&quot;&gt; &lt;div class=&quot;gmail_quote&quot;&gt; &lt;div class=&quot;gmail_quote&quot;&gt;&lt;u&gt;&lt;/u&gt; &lt;div&gt;&lt;font size=&quot;1&quot; face=&quot;Tahoma&quot;&gt;Hi  &lt;/font&gt;  &lt;p&gt;&lt;font size=&quot;1&quot; face=&quot;Tahoma&quot;&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color=&quot;#800080&quot; size=&quot;2&quot;&gt;&lt;b&gt;It is interesting to note the dates of Fri &amp;amp; Sat for this JULY..&lt;/b&gt;&lt;/font&gt; &lt;/p&gt; &lt;p&gt;&lt;font size=&quot;1&quot; face=&quot;Tahoma&quot;&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size=&quot;1&quot; face=&quot;Tahoma&quot;&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr valign=&quot;top&quot;&gt; &lt;td&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr valign=&quot;top&quot;&gt; &lt;td&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr valign=&quot;top&quot;&gt; &lt;td&gt;&lt;font size=&quot;2&quot;&gt;&lt;b&gt;THIS IS THE ONLY TIME WE WILL SEE AND LIVE THIS EVENT&lt;/b&gt; &lt;/font&gt;&lt;font color=&quot;#000080&quot; size=&quot;6&quot;&gt;&lt;b&gt;&lt;br&gt;Calendar for July 2011 &lt;/b&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt; &lt;/font&gt;  &lt;p&gt;&lt;br&gt;&lt;/p&gt; &lt;table align=&quot;center&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div align=&quot;center&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;July&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt; &lt;p&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;br&gt; &lt;table align=&quot;center&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Sun&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Mon&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Tue&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Wed&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Thu&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Fri&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;Sat&lt;/font&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;1&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;2&lt;/b&gt;&lt;/font&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;3&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;4&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;5&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;6&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;7&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;8&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;9&lt;/b&gt;&lt;/font&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;10&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;11&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;12&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;13&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;14&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;15&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;16&lt;/b&gt;&lt;/font&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;17&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;18&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;19&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;20&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;21&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;22&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;23&lt;/b&gt;&lt;/font&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;24&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;25&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;26&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;27&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt;28&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;29&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;30&lt;/b&gt;&lt;/font&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font size=&quot;4&quot;&gt;&lt;b&gt;31&lt;/b&gt;&lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt; &lt;/td&gt; &lt;td&gt;&lt;font size=&quot;3&quot;&gt; &lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;font size=&quot;2&quot;&gt;&lt;br&gt;&lt;/font&gt;&lt;font size=&quot;4&quot;&gt;&lt;br&gt;Money bags &lt;br&gt;&lt;br&gt;This year, July has 5 Fridays, 5 Saturdays and 5 Sundays. This happens once every 823 years. This is called money bags. So, forward this to your friends and money will arrive within 4 days. Based on Chinese Feng Shui. The one who does not forward.....will be without money!!!&lt;/font&gt; &lt;/p&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;font color=&quot;blue&quot; size=&quot;4&quot; face=&quot;Tahoma&quot;&gt;&lt;/font&gt; &lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt; &lt;/div&gt;&lt;br&gt; </content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/2479109481907663182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/2479109481907663182' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2479109481907663182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2479109481907663182'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2011/06/this-is-only-time-we-will-see-and-live.html' title='THIS IS THE ONLY TIME WE WILL SEE AND LIVE THIS EVENT.......]'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5498269097239166924.post-2712224111325691753</id><published>2011-06-23T17:46:00.001+05:30</published><updated>2011-06-23T17:46:25.383+05:30</updated><title type='text'>About Warren Buffet</title><content type='html'>&lt;div class=WordSection1&gt;&lt;p class=MsoNormal&gt;&lt;span style=&#39;font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D&#39;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;div style=&#39;border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm&#39;&gt;&lt;p class=MsoNormal&gt;&lt;b&gt;&lt;span lang=EN-US style=&#39;font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;&#39;&gt;From:&lt;/span&gt;&lt;/b&gt;&lt;span lang=EN-US style=&#39;font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;&#39;&gt; ram.patro&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;blockquote style=&#39;margin-top:5.0pt;margin-bottom:5.0pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=&quot;100%&quot; style=&#39;width:100.0%&#39;&gt;&lt;tr&gt;&lt;td width=&quot;100%&quot; style=&#39;width:100.0%;padding:1.5pt 1.5pt 1.5pt 1.5pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=701 style=&#39;width:525.75pt&#39;&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:0cm 0cm 0cm 0cm&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:0cm 0cm 0cm 0cm&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=680 style=&#39;width:510.0pt;margin-left:10.5pt&#39;&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:0cm 0cm 0cm 0cm&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0&gt;&lt;tr&gt;&lt;td width=680 valign=top style=&#39;width:510.0pt;padding:0cm 0cm 0cm 0cm&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:0cm 0cm 0cm 0cm&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&#39;font-size:16.0pt&#39;&gt;This man lives by his philosophy and has been paid handsomely by doing so.&amp;nbsp; I love the two rules he gives to the CEO&#39;s of his 63 companies (see #7)!&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0 width=&quot;100%&quot; style=&#39;width:100.0%&#39;&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;span style=&#39;font-size:10.0pt&#39;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;b&gt;&lt;span style=&#39;font-size:36.0pt&#39;&gt;Some valuable advice...&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;table class=MsoNormalTable border=0 cellspacing=3 cellpadding=0&gt;&lt;tr&gt;&lt;td valign=top style=&#39;padding:.75pt .75pt .75pt .75pt&#39;&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;b&gt;&lt;span style=&#39;font-size:18.0pt;color:#A16252&#39;&gt;&amp;quot;I always knew I was going to be rich.&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;b&gt;&lt;span style=&#39;font-size:18.0pt;color:#A16252&#39;&gt;I don&#39;t think I ever doubted it for a minute&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;span style=&#39;color:black&#39;&gt;&amp;nbsp;&lt;br&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&#39;font-size:18.0pt;color:#A16252&#39;&gt;- Warren Buffett&lt;/span&gt;&lt;/b&gt;&lt;span style=&#39;color:black&#39;&gt;&amp;nbsp;&lt;br&gt;&lt;img width=632 height=480 id=&quot;_x0000_i1025&quot; src=&quot;cid:part1.09000301.01060207@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image012.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=632 height=474 id=&quot;_x0000_i1026&quot; src=&quot;cid:part2.00080908.04000104@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;&amp;#13;&amp;#10;                                                          image013.jpg&quot;&gt;&lt;br&gt;&lt;img width=632 height=474 id=&quot;_x0000_i1027&quot; src=&quot;cid:part3.06090608.04060700@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image014.jpg&quot;&gt;&lt;br&gt;&lt;img width=627 height=470 id=&quot;_x0000_i1028&quot; src=&quot;cid:part4.00070907.09010509@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image015.jpg&quot;&gt;&lt;br&gt;&lt;img width=627 height=471 id=&quot;_x0000_i1029&quot; src=&quot;cid:part5.09050407.01030802@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image016.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=627 height=470 id=&quot;_x0000_i1030&quot; src=&quot;cid:part6.06000209.00060001@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image017.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=627 height=470 id=&quot;_x0000_i1031&quot; src=&quot;cid:part7.06040704.04070802@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image018.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=627 height=470 id=&quot;_x0000_i1032&quot; src=&quot;cid:part8.04080505.01050706@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image019.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=625 height=469 id=&quot;_x0000_i1033&quot; src=&quot;cid:part9.09050804.09020802@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image020.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=625 height=469 id=&quot;_x0000_i1034&quot; src=&quot;cid:part10.07080704.08030906@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image021.jpg&quot;&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;color:black&#39;&gt;&lt;img width=626 height=476 id=&quot;_x0000_i1035&quot; src=&quot;cid:part11.08030900.05040105@yahoo.com&quot; alt=&quot;Description:&amp;#13;&amp;#10;                                                          image022.jpg&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span style=&#39;font-size:10.0pt;color:black&#39;&gt;&lt;br&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&#39;font-size:36.0pt;color:black&#39;&gt;PLEASE PASS THIS ON AS IT IS CLASSIC&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;span style=&#39;font-family:&quot;Times \, serif \;color\:black&quot;&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;span style=&#39;font-size:10.0pt&#39;&gt;&lt;br&gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/table&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;span style=&#39;font-family:&quot;Times \, serif \;color\:black&quot;&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal style=&#39;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto&#39;&gt;&lt;span style=&#39;font-family:&quot;Times \, serif \;color\:black&quot;&#39;&gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/div&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/div&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;p class=MsoNormal&gt;&lt;span lang=EN-US&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://connecttoall.blogspot.com/feeds/2712224111325691753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5498269097239166924/2712224111325691753' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2712224111325691753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5498269097239166924/posts/default/2712224111325691753'/><link rel='alternate' type='text/html' href='http://connecttoall.blogspot.com/2011/06/about-warren-buffet.html' title='About Warren Buffet'/><author><name>Bishnu Patro</name><uri>http://www.blogger.com/profile/09294503143351091440</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpHnzfobw4diVHb3GAc7_GvNJJNptdF5OnrvJb-zUWi6PxwDB1me-jLNnoW4cKCJ1atHWdT2bL5w6q57qEXBsjU4HGiocz_09OyHIFISsDiwkB487MGGd8PcP4q2XpRw/s220/BishnuPatro.JPG'/></author><thr:total>0</thr:total></entry></feed>