<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Amit's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/amitjet/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/amitjet/feed.xml</link>
    <description>A SQL Server Professional&amp;#039;s blog</description>
    <lastBuildDate>Mon, 20 Jul 2015 15:11:08 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SQL Server Snapshot backup and restores - Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sql-server-snapshot-backup-and-restores-part-2</link>
      <pubDate>Tue, 01 Mar 2011 22:41:26 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2011/03/01/sql-server-snapshot-backup-and-restores-part-2/</guid>
      <description><![CDATA[&nbsp; In my last blog entry,I gave you some insights on my project objective. Let’s call this...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p>In my <a href="https://blogs.msdn.com/b/amitjet/archive/2011/01/17/sql-server-snapshot-backup-and-restores-part-1.aspx">last</a> blog entry,I gave you some insights on my project objective. Let’s call this project as SQLSNAP (SQL Snapshot). In&nbsp; VDI application development, the actual work of writing the backup metadata and taking backups is done by the VDI application. SQL Server would be doing the work as instructed by VDI app. So we have to be careful in our code and logic. </p> <p>Consider following sequence of logic for SQLSNAP. we will rectify as and when necessary in subsequent posts.</p> <p>1. On startup, SQLSNAP does certain initializations (for VDI backups)</p> <p>2. SQLSNAP connect to local SQL Server instance. </p> <p>3. Just like any other backup, a header file is created (you could do a RESTORE HEADERONLY on it) by SQL Server, the responsibility to write the metadata (and taking actual disk snapshot) lies with SQLSNAP.</p> <p>4. SQL puts database IO in freeze mode (via VDI calls made by SQLSNAP).</p> <p>6. SQLSNAP makes the disk level snapshots. This is a storage level work and will not be touched here. We will simply call a batch file that does storage level work.&nbsp; In my case, I am working on a Windows 7 laptop. so I will make use of the VSS to create “Previous versions” of my C:&nbsp; </p> <p>for large production database systems running on SANs, you should use tools specific to your SAN for making snapshots. </p> <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/09/79/metablogapi/2046.image_5F40E54D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-09-79-metablogapi/2046.image_5F00_5F40E54D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/09/79/metablogapi/3782.image_thumb_26861573.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-09-79-metablogapi/3782.image_5F00_thumb_5F00_26861573.png" width="183" height="244" /></a></p> <p>7. on completion of the snapshot, SQLSNAP informs SQL Server about backup completion. SQL Server resumes the IO on server. </p> <p>And Our backup gets completed.</p> <p>Sounds simple.&nbsp; Lets get it coded !!</p> <p><br />First, <a href="https://www.microsoft.com/downloads/en/details.aspx?FamilyID=416f8a51-65a3-4e8e-a4c8-adfe15e850fc&amp;DisplayLang=en">Download</a> the SQL Server 2005 Virtual Backup Device Interface (VDI) Specification from Microsoft. Run the downloaded EXE to extract few files onto your development machines.&nbsp; you will see few folders and a help file extracted. The vbackup.chm provides descriptions of each of the functions. The descriptions include the following information: </p> <ul> <li>Function purpose  </li><li>Function syntax  </li><li>Parameter list  </li><li>Return values  </li><li>Remarks </li></ul> <p>The other folders are sample code for you to study and develop your custom applications. </p> <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/09/79/metablogapi/8078.image_712CDD40.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-09-79-metablogapi/8078.image_5F00_712CDD40.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/09/79/metablogapi/3660.image_thumb_55A7DB3D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-09-79-metablogapi/3660.image_5F00_thumb_5F00_55A7DB3D.png" width="576" height="230" /></a></p> <p>so lets open the snapshot sample in more details.</p> <p>open the snapshot.cpp file in notepad or in your favorite C++ editor (such as Visual Studio). I am using VS2010 for this.&nbsp; Firstly note the initial comments in the source code. The same are applicable on to the modifications done/shown on this blog.&nbsp; </p> <div class="csharpcode"><pre class="code"><span style="color: green">// This source code is an intended supplement to the Microsoft SQL
// Server online references and related electronic documentation.
//
// This sample is for instructional purposes only.
// Code contained herein is not intended to be used "as is" in real applications.
// 
// snapshot.cpp
//
// This sample extends the "osimple.cpp" sample to demonstrate BACKUP WITH SNAPSHOT.
// It is not fully functional.  <u>The ability to take/mount snapshots must be provided.</u>
//
// This is a sample program used to demonstrate the Virtual Device Interface
// feature of Microsoft SQL Server together with an ODBC connection.
//
// The program will request backup or restore of a single database
// on some instance of sql server.
</span></pre><pre class="code"><span style="color: green">
</span>Let’s go over the rest comments inside the main function of the code.</pre><pre class="code">&nbsp;</pre><pre class="code"><pre class="code">    <span style="color: green">// Check the input parm

</span></pre>    <span style="color: green">// Initialize COM Library
    // Note: _WIN32_DCOM must be defined during the compile.</span></pre></div><pre class="code">    <span style="color: green">// Get an interface to the device set.
    // Notice how we use a single IID for both the class and interface
    // identifiers.

</span></pre><pre class="code">    <span style="color: green">// Setup the VDI configuration we want to use.
    // This program doesn't use any fancy features, so the
    // only field to setup is the deviceCount.
    //
    // The server will treat the virtual device just like a pipe:
    // I/O will be strictly sequential with only the basic commands.
</span></pre><pre class="code">    <span style="color: green">// Create a GUID to use for a unique virtual device name
</span></pre><pre class="code">    <span style="color: green">// Create the virtual device set
    // Notice that we only support unicode interfaces</span></pre><pre class="code">    <span style="color: green">// Send the SQL command, by starting a thread to handle the ODBC

</span></pre><pre class="code">    <span style="color: green">// Wait for the server to connect, completing the configuration.
</span></pre><pre class="code">    <span style="color: green">// Open the single device in the set.
</span><span style="color: green"></span></pre><pre class="code"><span style="color: green">now Logic moves to performTransfer function. following comments from performTransfer function.</span></pre><pre class="code"><span style="color: green">// VDI data transfer handler.
//
// This routine reads commands from the server until a 'Close' status is received.
// It simply reads or writes a file 'superbak.dmp' in the current directory.
</span></pre>
<p>and few more inside a while loop. I am not pasting them here. </p>
<p>A typical database backup command has following syntax </p>
<blockquote><pre class="csharpcode"><span class="kwrd">BACKUP</span> <span class="kwrd">DATABASE</span> DBNAME <span class="kwrd">TO</span> <span class="kwrd">DISK</span>=’FILENAME’</pre>

</blockquote>
<p>Just doing a simple search on the file about word “DATABASE “, I found following line inside a function named&nbsp; “<em>SQLRoutine”</em></p>
<p><em><br /></em><span style="color: green">// Generate the command to execute<br />//<br /></span>sprintf (sqlCommand, <span style="color: #a31515">"%s DATABASE [%s] %s VIRTUAL_DEVICE='%s' WITH SNAPSHOT"</span>,<br />&nbsp;&nbsp;&nbsp; parms-&gt;doBackup ? <span style="color: #a31515">"BACKUP"</span>: <span style="color: #a31515">"RESTORE"</span>,<br />&nbsp;&nbsp;&nbsp; parms-&gt;pDbName,<br />&nbsp;&nbsp;&nbsp; parms-&gt;doBackup ? <span style="color: #a31515">"TO"</span>: <span style="color: #a31515">"FROM"</span>,<br />&nbsp;&nbsp;&nbsp; aVdsName);<br /><br /></p>
<p>So as we see, the majority of work that we intend to do is done in this 3 functions. main, performTransfer and SQLRoutine.&nbsp; There are few other functions as well. </p>
<p>In my next blog post, I will go deeper into the sample code and modifications. </p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Snapshot backup and restores - Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sql-server-snapshot-backup-and-restores-part-1</link>
      <pubDate>Mon, 17 Jan 2011 05:24:19 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2011/01/17/sql-server-snapshot-backup-and-restores-part-1/</guid>
      <description><![CDATA[&#160;  Recently, I was working with one of my customers to help them design their backup scheme....]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>Recently, I was working with one of my customers to help them design their backup scheme. This customer has their IT team very comfortable with their SAN infrastructure. Their current infrastructure and backup solution for non-Microsoft product stack is all based on SAN. </p>  <p>The way they work is they mirror their disks (or volumes) to other disks. Once mirror is in Sync, they break the mirror, mount the mirrored disk on to another server and take file system level backups. They call it as BCV copy.</p>  <p>This customer was interested to know if he could do the same with Windows/SQL. </p>  <p>As it sounds independent of the OS/DB, customer gave it a shot. It worked. They were able to make their BCVs to tape without a problem. (Disk Mirror -&gt; Sync -&gt; Break Mirror -&gt; mount it on new server -&gt; take tape backup). </p>  <p>Now, no backup test is complete without a restore. So they tried to restore. It worked as expected as well. However, there was a issue which needed to be addressed. </p>  <p>Customer couldn’t restore BCV data files and then apply additional transaction log files to bring database up to date. Why? As soon as you attach these BCV’ed files, SQL will recover them and database will be operational. </p>  <p>In comes SQL Server VDI (Virtual Device Interface).</p>  <p>Next : What I did to SQL Server VDI Samples to facilitate subsequent transaction log restores. Stay tuned for more.</p>  <p>Meanwhile see these articles for more knowledge. </p>  <p><b><a href="https://msdn.microsoft.com/en-us/library/cc966520.aspx">A Guide for SQL Server Backup Application Vendors</a></b></p>  <p><b><a href="https://blogs.msdn.com/b/psssql/archive/2009/03/03/how-it-works-sql-server-vdi-vss-backup-resources.aspx">How It Works: SQL Server - VDI (VSS) Backup Resources</a></b></p>]]></content:encoded>
    </item>
    <item>
      <title>sp_what</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sp_what</link>
      <pubDate>Mon, 28 Jun 2010 22:04:08 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2010/06/28/sp_what/</guid>
      <description><![CDATA[I have been recently involved with a customer who were running a lot of parallel processes and the...]]></description>
      <content:encoded><![CDATA[<p><font face="Calibri">I have been recently involved with a customer who were running a lot of parallel processes and the DBA team used to run sp_who, sp_who2 &amp; selects from dm_exec_request to know status of those commands. Every time users fire those&#160; parallel processes, DBA Team would keep scrolling into the SSMS UI to see desired rows from their monitoring queries. </font></p>  <p><font face="Calibri">I made following procedure to make their life a little easier. hope this helps others as well. </font></p>  <p><font face="Calibri">No explanations on that this procedure does. Run it on SQL 2005 or SQL 2008 and see it for yourself.</font></p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <pre class="csharpcode"><span class="kwrd"></span></pre>

<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">proc</span> sp_what ( @<span class="kwrd">session</span> <span class="kwrd">int</span> = <span class="kwrd">null</span>, @<span class="kwrd">plan</span> <span class="kwrd">bit</span> = 0 ) 
<span class="kwrd">as</span> 
<span class="kwrd">begin</span>
    <span class="kwrd">select</span> session_id ,command ,
    blocking_session_id <span class="kwrd">as</span> blocked, wait_time, wait_resource,
    open_transaction_count <span class="kwrd">as</span> trans , percent_complete <span class="kwrd">as</span> [%], 
    cpu_time , 
    <span class="kwrd">convert</span>(<span class="kwrd">varchar</span>, total_elapsed_time /60000 ) + <span class="str">':'</span> + <span class="kwrd">right</span>(<span class="str">'0'</span> + <span class="kwrd">convert</span>(<span class="kwrd">varchar</span>(2), (total_elapsed_time /1000) % 60 ),2 ) <span class="kwrd">as</span> StartedSince,
    <span class="kwrd">reads</span> , 
    writes ,logical_reads, row_count, nest_level, granted_query_memory <span class="kwrd">as</span> mem ,
    object_name( s.objectid) <span class="kwrd">as</span> obj,
    <span class="kwrd">SUBSTRING</span>(s.text, statement_start_offset / 2, ( (<span class="kwrd">CASE</span> <span class="kwrd">WHEN</span> statement_end_offset = -1 <span class="kwrd">THEN</span> (LEN(<span class="kwrd">CONVERT</span>(nvarchar(<span class="kwrd">max</span>),s.text)) * 2) <span class="kwrd">ELSE</span> statement_end_offset <span class="kwrd">END</span>) - statement_start_offset) / 2) 
    <span class="kwrd">from</span> sys.dm_Exec_requests r <span class="kwrd">cross</span> apply sys.dm_exec_sql_text (sql_handle) s
    <span class="kwrd">where</span> command <span class="kwrd">is</span> <span class="kwrd">not</span> <span class="kwrd">null</span> <span class="kwrd">and</span> session_id &lt;&gt; <span class="preproc">@@spid</span>

    <span class="kwrd">and</span> ( session_id = @<span class="kwrd">session</span> <span class="kwrd">or</span> @<span class="kwrd">session</span> <span class="kwrd">is</span> <span class="kwrd">null</span> )

    <span class="kwrd">if</span> ( @<span class="kwrd">plan</span> = 1 )
    <span class="kwrd">begin</span>
        <span class="kwrd">select</span> session_id , query_plan <span class="kwrd">from</span> sys.dm_Exec_requests r
        <span class="kwrd">cross</span> apply sys.dm_exec_query_plan (plan_handle) s
        <span class="kwrd">where</span> command <span class="kwrd">is</span> <span class="kwrd">not</span> <span class="kwrd">null</span> <span class="kwrd">and</span> session_id &lt;&gt; <span class="preproc">@@spid</span>
        <span class="kwrd">and</span> ( session_id = @<span class="kwrd">session</span> <span class="kwrd">or</span> @<span class="kwrd">session</span> <span class="kwrd">is</span> <span class="kwrd">null</span> )
 
    <span class="kwrd">end</span>
<span class="kwrd">end</span> </pre>
]]></content:encoded>
    </item>
    <item>
      <title>Convert Comma Separated String to Table : 4 different approaches</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/convert-comma-separated-string-to-table-4-different-approaches</link>
      <pubDate>Fri, 11 Dec 2009 10:10:56 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2009/12/11/convert-comma-separated-string-to-table-4-different-approaches/</guid>
      <description><![CDATA[Recently, I came across a piece of TSQL code that would take a comma separated string as an input...]]></description>
      <content:encoded><![CDATA[<p>Recently, I came across a piece of TSQL code that would take a comma separated string as an input and parse it to return a single column table from it.&#160; </p>  <p>Lets’ call this function as Split1. The code is as follows:</p>  <p>&#160;</p>  <blockquote>   <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">CREATE</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">FUNCTION</span> [dbo]<span style="color: gray">.</span>Split1<span style="color: gray">(</span>@input <span style="color: blue">AS</span> <span style="color: blue">Varchar</span><span style="color: gray">(</span>4000<span style="color: gray">)</span> <span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">RETURNS</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span>@Result <span style="color: blue">TABLE</span><span style="color: gray">(</span>Value <span style="color: blue">BIGINT</span><span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">AS </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">BEGIN </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">DECLARE</span> @str <span style="color: blue">VARCHAR</span><span style="color: gray">(</span>20<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">DECLARE</span> @ind <span style="color: blue">Int </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">IF</span><span style="color: gray">(</span>@input <span style="color: gray">is</span> <span style="color: gray">not</span> <span style="color: gray">null) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">BEGIN </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SET</span> @ind <span style="color: gray">=</span> <span style="color: fuchsia">CharIndex</span><span style="color: gray">(</span><span style="color: red">','</span><span style="color: gray">,</span>@input<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">WHILE</span> @ind <span style="color: gray">&gt;</span> 0 </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">BEGIN </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SET</span> @str <span style="color: gray">=</span> <span style="color: fuchsia">SUBSTRING</span><span style="color: gray">(</span>@input<span style="color: gray">,</span>1<span style="color: gray">,</span>@ind<span style="color: gray">-</span>1<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SET</span> @input <span style="color: gray">=</span> <span style="color: fuchsia">SUBSTRING</span><span style="color: gray">(</span>@input<span style="color: gray">,</span>@ind<span style="color: gray">+</span>1<span style="color: gray">,</span><span style="color: fuchsia">LEN</span><span style="color: gray">(</span>@input<span style="color: gray">)-</span>@ind<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">INSERT</span> <span style="color: blue">INTO</span> @Result <span style="color: blue">values </span><span style="color: gray">(</span>@str<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SET</span> @ind <span style="color: gray">=</span> <span style="color: fuchsia">CharIndex</span><span style="color: gray">(</span><span style="color: red">','</span><span style="color: gray">,</span>@input<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">END </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SET</span> @str <span style="color: gray">=</span> @input </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">INSERT</span> <span style="color: blue">INTO</span> @Result <span style="color: blue">values </span><span style="color: gray">(</span>@str<span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">END </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">RETURN </span>        <p></p>     </span></p>    <p></p>    <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">END</span> </p>    <p></p>    <p></p> </blockquote>  <p>This is a very old fashioned (but still effective enough) script which does a loop over a string to cut out all possible string values that are separated by a comma.</p>  <p>Let’s see now, how the same could be achieved in modern day TSQL languages (such as SQL 2005 or SQL 2008).</p>  <p><strong>Approach 1:&#160; Common Table Expression (CTE)</strong></p>  <p>&#160;</p>  <p>Lets call this function as Split2.&#160; here we are using </p>  <blockquote>   <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">CREATE</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">FUNCTION</span> dbo<span style="color: gray">.</span>Split2<span style="color: blue"> </span><span style="color: gray">(</span> @strString <span style="color: blue">varchar</span><span style="color: gray">(</span>4000<span style="color: gray">))</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">RETURNS</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160; </span>@Result <span style="color: blue">TABLE</span><span style="color: gray">(</span>Value <span style="color: blue">BIGINT</span><span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">AS </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">begin</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">WITH</span> StrCTE<span style="color: gray">(</span>start<span style="color: gray">,</span> <span style="color: blue">stop</span><span style="color: gray">)</span> <span style="color: blue">AS</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes">( </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SELECT</span><span style="mso-spacerun: yes">&#160; </span>1<span style="color: gray">,</span> <span style="color: fuchsia">CHARINDEX</span><span style="color: gray">(</span><span style="color: red">','</span> <span style="color: gray">,</span> @strString <span style="color: gray">)</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">UNION</span> <span style="color: gray">ALL </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SELECT</span><span style="mso-spacerun: yes">&#160; </span><span style="color: blue">stop</span> <span style="color: gray">+</span> 1<span style="color: gray">,</span> <span style="color: fuchsia">CHARINDEX</span><span style="color: gray">(</span><span style="color: red">','</span> <span style="color: gray">,</span>@strString<span style="mso-spacerun: yes">&#160; </span><span style="color: gray">,</span> <span style="color: blue">stop</span> <span style="color: gray">+</span> 1<span style="color: gray">)</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">FROM</span> StrCTE </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">WHERE</span> <span style="color: blue">stop</span> <span style="color: gray">&gt;</span> 0 </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">insert</span> <span style="color: blue">into</span> @Result </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">SELECT</span><span style="mso-spacerun: yes">&#160;&#160; </span><span style="color: fuchsia">SUBSTRING</span><span style="color: gray">(</span>@strString <span style="color: gray">,</span> start<span style="color: gray">,</span> <span style="color: blue">CASE</span> <span style="color: blue">WHEN</span> <span style="color: blue">stop</span> <span style="color: gray">&gt;</span> 0 <span style="color: blue">THEN</span> <span style="color: blue">stop</span><span style="color: gray">-</span>start <span style="color: blue">ELSE</span> 4000 <span style="color: blue">END</span><span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;</span><span style="color: blue">AS</span> stringValue </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">FROM</span> StrCTE </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">return </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">end</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"></span>      <p>&#160;</p>   </p>    <p></p>    <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">GO</span> </p>    <p></p>    <p></p> </blockquote>  <p>&#160;</p>  <p><strong>Approach 2:&#160; XML (surprise) </strong></p>  <p><strong></strong></p>  <p>XML could be applied to do some type of string parsing (see this) Let’s call this function as Split3.</p>  <p>&#160;</p>  <p><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">CREATE</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">FUNCTION</span> dbo<span style="color: gray">.</span>Split3<span style="color: blue"> </span><span style="color: gray">(</span> @strString <span style="color: blue">varchar</span><span style="color: gray">(</span>4000<span style="color: gray">))</span> </span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">RETURNS</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160; </span>@Result <span style="color: blue">TABLE</span><span style="color: gray">(</span>Value <span style="color: blue">BIGINT</span><span style="color: gray">) </span>      <p></p>   </span></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">AS </span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">BEGIN</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> </span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">DECLARE</span> @x <span style="color: blue">XML</span><span style="mso-spacerun: yes">&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SELECT</span> @x <span style="color: gray">=</span> <span style="color: fuchsia">CAST</span><span style="color: gray">(</span><span style="color: red">'&lt;A&gt;'</span><span style="color: gray">+</span> <span style="color: fuchsia">REPLACE</span><span style="color: gray">(</span>@strString<span style="color: gray">,</span><span style="color: red">','</span><span style="color: gray">,</span><span style="color: red">'&lt;/A&gt;&lt;A&gt;'</span><span style="color: gray">)+</span> <span style="color: red">'&lt;/A&gt;'</span> <span style="color: blue">AS</span> <span style="color: blue">XML</span><span style="color: gray">) </span>      <p></p>   </span></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">INSERT</span> <span style="color: blue">INTO</span> @Result<span style="mso-tab-count: 1">&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SELECT</span> t<span style="color: gray">.</span>value<span style="color: gray">(</span><span style="color: red">'.'</span><span style="color: gray">,</span> <span style="color: red">'int'</span><span style="color: gray">)</span> <span style="color: blue">AS</span> inVal </span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">FROM</span> @x<span style="color: gray">.</span>nodes<span style="color: gray">(</span><span style="color: red">'/A'</span><span style="color: gray">)</span> <span style="color: blue">AS</span> x<span style="color: gray">(</span>t<span style="color: gray">) </span>      <p></p>   </span></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes"></span>    <p>&#160;</p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue">RETURN </span>      <p></p>   </span></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">END</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">GO </span>    <p></p> </p>  <p></p>  <p class="MsoNormal"></p>  <p>&#160;</p>  <p></p>  <p><strong>Approach 4: Classic TSQL Way</strong></p>  <p><strong></strong></p>  <p>I got this approach from <a href="https://www.sqlservercentral.com/articles/T-SQL/62867" target="_blank">SQL Server Central site</a>. This approach is slightly unusual but very effective. this needs you to create a table of sequential numbers called a Tally Table. </p>  <p>&#160;</p>  <blockquote>   <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">SELECT</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">TOP</span> 11000 <span style="color: green">--equates to more than 30 years of dates<span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">IDENTITY</span><span style="font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes">(</span><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">INT</span><span style="font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes">,</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes">1<span style="color: gray">,</span>1<span style="color: gray">)</span> <span style="color: blue">AS</span> N<span style="mso-spacerun: yes">&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">INTO</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> dbo<span style="color: gray">.</span>Tally<span style="mso-spacerun: yes">&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">FROM</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">Master</span><span style="color: gray">.</span>dbo<span style="color: gray">.</span><span style="color: green">SysColumns</span> sc1<span style="color: gray">,</span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">Master</span><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes">.</span><span style="line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes">dbo<span style="color: gray">.</span><span style="color: green">SysColumns</span> sc2</span> </p>    <p></p>    <p></p> </blockquote>  <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes"></span></p>  <p></p>  <p></p>  <p>&#160;</p>  <p>Lets index the table for better performance.</p>  <p>&#160;</p>  <blockquote>   <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">ALTER</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">TABLE</span> dbo<span style="color: gray">.</span>Tally<span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: blue"></span></span></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="color: blue">ADD</span> <span style="color: blue">CONSTRAINT</span> PK_Tally_N<span style="mso-spacerun: yes">&#160;</span><span style="color: blue">PRIMARY</span> <span style="color: blue">KEY</span> <span style="color: blue">CLUSTERED </span><span style="color: gray">(</span>N<span style="color: gray">)</span> </span></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="color: blue">WITH</span> <span style="color: blue">FILLFACTOR</span> <span style="color: gray">=</span> 100 </span>      <p></p>   </p>    <p></p> </blockquote>  <p class="MsoNormal"></p>  <p>&#160;</p>  <p></p>  <p>Finally out Split4 function.</p>  <p>&#160;</p>  <p>&#160;</p>  <blockquote>   <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">CREATE</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: blue">FUNCTION</span> dbo<span style="color: gray">.</span>Split4<span style="color: blue"> </span><span style="color: gray">(</span> @strString <span style="color: blue">varchar</span><span style="color: gray">(</span>4000<span style="color: gray">))</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">RETURNS</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160; </span>@Result <span style="color: blue">TABLE</span><span style="color: gray">(</span>Value <span style="color: blue">BIGINT</span><span style="color: gray">) </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">AS </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">BEGIN</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;</span><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160; </span><span style="color: blue">SET</span> @strString <span style="color: gray">=</span> <span style="color: red">','</span><span style="color: gray">+</span>@strString <span style="color: gray">+</span><span style="color: red">',' </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">INSERT</span> <span style="color: blue">INTO</span> @t<span style="color: blue"><span style="mso-spacerun: yes">&#160; </span></span><span style="color: gray">(</span>Value<span style="color: gray">)</span> </span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">SELECT</span> <span style="color: fuchsia">SUBSTRING</span><span style="color: gray">(</span>@strString<span style="color: gray">,</span>N<span style="color: gray">+</span>1<span style="color: gray">,</span><span style="color: fuchsia">CHARINDEX</span><span style="color: gray">(</span><span style="color: red">','</span><span style="color: gray">,</span>@strString<span style="color: gray">,</span>N<span style="color: gray">+</span>1<span style="color: gray">)-</span>N<span style="color: gray">-</span>1<span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">FROM</span> dbo<span style="color: gray">.</span>Tally<span style="mso-spacerun: yes">&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">WHERE</span> N <span style="color: gray">&lt;</span> <span style="color: fuchsia">LEN</span><span style="color: gray">(</span>@strString<span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: gray">AND</span> <span style="color: fuchsia">SUBSTRING</span><span style="color: gray">(</span>@strString<span style="color: gray">,</span>N<span style="color: gray">,</span>1<span style="color: gray">)</span> <span style="color: gray">=</span> <span style="color: red">','</span> <span style="color: green">--Notice how we find the comma </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: green; font-size: 10pt; mso-no-proof: yes"></span>      <p>&#160;</p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">RETURN </span>        <p></p>     </span></p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">END</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span>      <p></p>   </p>    <p></p>    <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">GO </span>      <p></p>   </p>    <p></p>    <p class="MsoNormal"></p>    <p>&#160;</p>    <p></p> </blockquote>  <p>Now, what about the most crucial question: Performance.&#160; so lets put all 4 functions to test.</p>  <p>please note that I am running this on SQL Server 2008. you may need to modify it for SQL 2005.</p>  <p>&#160;</p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">DECLARE</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> @str <span style="color: blue">VARCHAR</span><span style="color: gray">(</span>4000<span style="color: gray">)</span> </span><span style="font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes">=</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: red">'6,7,7,8,10,12,13,14,16,44,46,47,394,396,417,488,714,717,718,719,722,725,811,818,832,833,836,837,846,913,914,919,922,923,924,925,926,927,927,928,929,929,930,931,932,934,935,1029,1072,1187,1188,1192,1196,1197,1199,1199,1199,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1366,1367,1387,1388,1666,1759,1870,2042,2045,2163,2261,2374,2445,2550,2676,2879,2880,2881,2892,2893,2894' </span>      <p></p>   </span></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">SELECT</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> dbo<span style="color: gray">.</span>split1<span style="color: blue"> </span><span style="color: gray">(</span> @str <span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">SELECT</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> dbo<span style="color: gray">.</span>split2<span style="color: blue"> </span><span style="color: gray">(</span> @str <span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">SELECT</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> dbo<span style="color: gray">.</span>split3<span style="color: blue"> </span><span style="color: gray">(</span> @str <span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">SELECT</span><span style="line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> dbo<span style="color: gray">.</span>split3<span style="color: blue"> </span><span style="color: gray">(</span> @str <span style="color: gray">)</span><span style="mso-spacerun: yes">&#160;&#160; </span></span></p>  <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes"></span></span></p>  <p class="MsoNormal">On my laptop, I saw following numbers. I expected the XML to be the fastest. </p>  <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_2.png" original-url="https://blogs.msdn.com/blogfiles/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_thumb.png" width="541" height="127" /></a> </p>  <p>&#160;</p>  <p>so I changed the code slightly to test out XML function directly.</p>  <p>&#160;</p>  <p>&#160;</p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">DECLARE</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> @str <span style="color: blue">VARCHAR</span><span style="color: gray">(</span>4000<span style="color: gray">)</span> </span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: gray; font-size: 10pt; mso-no-proof: yes">=</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> <span style="color: red">'6,7,7,8,10,12,13,14,16,44,46,47,394,396,417,488,714,717,718,719,722,725,811,818,832,833,836,837,846,913,914,919,922,923,924,925,926,927,927,928,929,929,930,931,932,934,935,1029,1072,1187,1188,1192,1196,1197,1199,1199,1199,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1366,1367,1387,1388,1666,1759,1870,2042,2045,2163,2261,2374,2445,2550,2676,2879,2880,2881,2892,2893,2894'</span> </span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">Declare</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> @x <span style="color: blue">XML</span><span style="mso-spacerun: yes">&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">select</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> @x <span style="color: gray">=</span> <span style="color: fuchsia">cast</span><span style="color: gray">(</span><span style="color: red">'&lt;A&gt;'</span><span style="color: gray">+</span> <span style="color: fuchsia">replace</span><span style="color: gray">(</span>@str<span style="color: gray">,</span><span style="color: red">','</span><span style="color: gray">,</span><span style="color: red">'&lt;/A&gt;&lt;A&gt;'</span><span style="color: gray">)+</span> <span style="color: red">'&lt;/A&gt;'</span> <span style="color: blue">as</span> <span style="color: blue">xml</span><span style="color: gray">) </span>      <p></p>   </span></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span></span>    <p></p> </p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">select</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> t<span style="color: gray">.</span>value<span style="color: gray">(</span><span style="color: red">'.'</span><span style="color: gray">,</span> <span style="color: red">'int'</span><span style="color: gray">)</span> <span style="color: blue">as</span> inVal </span>    <p></p> </p>  <p></p>  <p class="MsoNormal"><span style="line-height: 115%; font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt; mso-no-proof: yes">from</span><span style="line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt; mso-no-proof: yes"> @x<span style="color: gray">.</span>nodes<span style="color: gray">(</span><span style="color: red">'/A'</span><span style="color: gray">)</span> <span style="color: blue">as</span> x<span style="color: gray">(</span>t<span style="color: gray">)</span></span> </p>  <p></p>  <p></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_4.png" original-url="https://blogs.msdn.com/blogfiles/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/amitjet/WindowsLiveWriter/SQLServerCommaSeparatedStringtoTable_147C4/image_thumb_1.png" width="544" height="72" /></a> </p>  <p>&#160;</p>  <p>&#160;</p>  <p>Hmm. so just as I thought, XML is faster on its’ own.</p>  <p>there are some more options that I did not consider such as CLR functions. but we will get to those some other time. </p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server and SAP !!!</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sql-server-and-sap</link>
      <pubDate>Sat, 30 May 2009 15:18:46 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2009/05/30/sql-server-and-sap/</guid>
      <description><![CDATA[Recently, I started working with some of my customers in India who are running their mission...]]></description>
      <content:encoded><![CDATA[<p>Recently, I started working with some of my customers in India who are running their mission critical systems on Microsoft platform. </p>  <p>During my interactions with them, I came across following case studies. </p>  <h4><a href="https://www.microsoft.com/casestudies/Case_Study_Detail.aspx?CaseStudyID=4000003962" target="_blank">Quanta Computer Gains 80 Percent Data Compression for SAP with SQL Server 2008</a></h4>  <blockquote>   <p>With its SAP database supporting its global operations growing by more than half a terabyte a month, Quanta needed to either replace its SAN infrastructure or find a compression solution. The company upgraded to Microsoft® SQL Server® 2008 Enterprise (64-bit) to take advantage of new SQL Server compression technology. SQL Server 2008 Database Compression has reduced some tables by as much as <strong><u>90 </u></strong>percent, while SQL Server 2008 Backup Compression has provided compression of 85 percent</p> </blockquote>  <p>&#160;</p>  <h4><a href="https://www.microsoft.com/casestudies/Case_Study_Detail.aspx?casestudyid=4000003421" target="_blank">Moving SAP Off Mainframe to SQL Server Nets Australia’s QR Limited U.S.$100,000 a Month</a></h4>  <blockquote>   <p>Having been in the business since the 1860s, Australia’s QR Limited knows how to run a railroad. As the company prepared to upgrade its SAP R/3 enterprise resource planning (ERP) software it decided to move its SAP applications and databases from a mainframe and DB2 environment to the Microsoft® Application Platform, including Microsoft SQL Server® 2005 database software running on a geocluster supported by the Windows Server® 2003 Enterprise Edition operating system. The company estimates it is saving about U.S.$100,000 per month in mainframe costs, since moving its SAP infrastructure to a cluster of commodity servers running the Microsoft Application Platform. QR Limited reports 20 to 40 percent faster SAP transactional response times and up to 8 times faster batch processing since moving SAP to SQL Server 2005.</p> </blockquote>  <h4><a href="https://www.microsoft.com/casestudies/Case_Study_Detail.aspx?CaseStudyID=4000004133" target="_blank">Australia’s CSR Lowers Costs by Migrating SAP from Oracle to SQL Server 2005</a></h4>  <blockquote>   <p>CSR Limited (CSR), which traces its roots to 1855, is one of the largest manufacturers in Australia. It is the sixth largest sugar producer in the world and a major manufacturer of building products including plasterboard, roofing material, insulation, and glass. CSR is also a joint venture participant in the Tomago aluminium smelter. The company uses SAP software to manage its multinational enterprise. CSR originally deployed SAP on a UNIX/Oracle stack, but later migrated to the Microsoft® Application Platform including Microsoft SQL Server® 2005 database software. Running SAP on SQL Server has proven so effective that after the company recently purchased Australia and New Zealand’s Pilkington Glass, it again migrated SAP from the UNIX/Oracle stack to the Microsoft Application Platform. CSR is enjoying a lower total cost of ownership, enhanced performance, and high availability.</p> </blockquote>  <p>&#160;</p>  <p>Isn’t that great? Running SQL Server gives you lower total cost of ownership, enhanced performance, high availability &amp; with SQL 2008, you also get a great storage size reduction!!!&#160; A truly valuable solution in these recession days ….</p>  <p>&#160;</p>  <p>Also, you would find following blogs as very useful resources for SAP on SQL Server. </p>  <p>&#160;</p>  <p><a href="https://blogs.msdn.com/saponsqlserver/default.aspx">Running SAP Applications on SQL Server</a></p>  <p>This Blog will provide information about running SAP applications on SQL Server and Windows. The Blog is written by folks of Microsoft who are working with SAP and SQL Server for more than a decade or who are running Microsoft's SAP landscape.</p>  <p>&#160;</p>  <p><a href="https://blogs.msdn.com/saptech" target="_blank">SAP Global Alliance Technology Team Blog:</a> find various information that relates to Microsoft Windows platform and SAP. It contains information on Whitepapers, books, various software releases related to SAP &amp; Windows.!!!</p>  <p>&#160;</p>  <p>-- Amit </p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Standard Edition and Lock Pages in Memory</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sql-server-standard-edition-and-lock-pages-in-memory</link>
      <pubDate>Mon, 27 Apr 2009 00:54:44 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2009/04/27/sql-server-standard-edition-and-lock-pages-in-memory/</guid>
      <description><![CDATA[Have you faced any SQL Server working set trimming problems (Don’t know this? Read Here and...]]></description>
      <content:encoded><![CDATA[<p>Have you faced any SQL Server working set trimming problems (Don’t know this? Read <a href="https://blogs.msdn.com/psssql/archive/2008/03/03/sql-server-working-set-trim-problems-consider.aspx" target="_blank">Here</a> and <a href="https://support.microsoft.com/kb/918483" target="_blank">Here</a>&#160; ) </p>  <p>One of the solutions of this kind of issue was “Lock Pages in Memory” which was an Enterprise Edition only feature. </p>  <p>On Popular Demand (&amp; Noise), This might be available for Standard Editions as well !!!</p>  <p>Read following blog entry from Bob ward </p>  <p><a title="https://blogs.msdn.com/psssql/archive/2009/04/24/sql-server-locked-pages-and-standard-sku.aspx" href="https://blogs.msdn.com/psssql/archive/2009/04/24/sql-server-locked-pages-and-standard-sku.aspx">https://blogs.msdn.com/psssql/archive/2009/04/24/sql-server-locked-pages-and-standard-sku.aspx</a></p>  <p>and for now ….&#160; just wait for those CU to be released !!!</p>]]></content:encoded>
    </item>
    <item>
      <title>SQL 2008 Whitepapers</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sql-2008-whitepapers</link>
      <pubDate>Sat, 18 Apr 2009 01:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2009/04/18/sql-2008-whitepapers/</guid>
      <description><![CDATA[All the whitepapers for Microsoft SQL Server 2008 are available at...]]></description>
      <content:encoded><![CDATA[<p>All the whitepapers for Microsoft SQL Server 2008 are available at <a title="https://www.microsoft.com/sqlserver/2008/en/us/white-papers.aspx" href="https://www.microsoft.com/sqlserver/2008/en/us/white-papers.aspx">https://www.microsoft.com/sqlserver/2008/en/us/white-papers.aspx</a></p>  <p>My favorite of them all is </p>  <p><a href="https://msdn.microsoft.com/en-us/library/dd672789.aspx">Troubleshooting Performance Problems in SQL Server 2008 Whitepaper</a></p>  <p>This white paper provides step-by-step guidelines for diagnosing and troubleshooting common performance problems by using publicly available tools such as:   <br />▪ SQL Server Profiler    <br />▪ System Monitor (in the Windows Server 2003 operating system) or     <br />▪ Performance Monitor (in the Windows Vista operating system and Windows Server 2008), also known as Perfmon    <br />▪ Dynamic management views (sometimes referred to as DMVs)    <br />▪ SQL Server Extended Events (Extended Events) and the data collector, which are new in SQL Server 2008</p>  <p>&#160;</p>  <p>Happy reading and troubleshooting!</p>]]></content:encoded>
    </item>
    <item>
      <title>Disk Partitioning Offset</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/disk-partitioning-offset</link>
      <pubDate>Fri, 17 Apr 2009 05:51:35 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2009/04/17/disk-partitioning-offset/</guid>
      <description><![CDATA[What is this?  Following is an excerpt from SQL Server Best Practices Article published on Technet....]]></description>
      <content:encoded><![CDATA[<p>What is this?</p>  <p>Following is an excerpt from SQL Server Best Practices Article published on Technet.</p>  <p><a title="https://technet.microsoft.com/en-us/library/cc966412.aspx" href="https://technet.microsoft.com/en-us/library/cc966412.aspx">https://technet.microsoft.com/en-us/library/cc966412.aspx</a>&#160; </p>  <p>{</p>  <blockquote>   <p>Volume alignment, commonly referred to as <em>sector alignment</em>, should be performed on the file system (NTFS) whenever a volume is created on a RAID device. <u><strong>Failure to do so can lead to significant performance degradation</strong></u>; these are most commonly the result of partition misalignment with stripe unit boundaries. This can also lead to hardware cache misalignment, resulting in inefficient utilization of the array cache. For more information on this, see <a href="https://support.microsoft.com/default.aspx?scid=kb;EN-US;929491">Disk performance may be slower than expected when you use multiple disks in Windows Server 2003, in Windows XP, and in Windows 2000</a>.</p>    <p>Volume alignment on NTFS volumes can be performed by using diskpar.exe or DiskPart.exe. There is no advantage of using one over the other. However, DiskPart.exe is the preferred method since it is now included as part of Microsoft Windows® and the functionality will continue to be enhanced. Diskpar.exe is a Windows 2000 Resource Kit tool and is most commonly used in versions of Windows prior to Windows 2003 SP1. DiskPart.exe is a disk configuration utility that is built into Windows; in Windows 2003 version SP1 or greater DiskPart.exe contains an ALIGN option that can be used to align volumes. </p>    <p>When aligning the file system keep in mind the following:&#160; </p>    <ul>     <li>       <p>Ideally, the offset used to align the volume should be supplied by the OEM of your particular storage array. </p>     </li>      <li>       <p>If the OEM does not provide an offset, the only way to determine the optimal offset is through testing. </p>     </li>      <li>       <p>A 64-KB offset (128 sectors) is a common value that works on many storage arrays and has been used with success in the SQL Server test labs (at the time of writing this paper). Vista™ and Windows Longhorn Server remove the need to manually establish correct alignment and use 1024 KB (2048 sectors) as a starting offset, which will probably work well for almost any array. </p>     </li>      <li>       <p>Diskpar.exe works only on MBR partitions. DiskPart.exe supports both MBR and GPT partitions. Alignment of dynamic volumes is not currently supported as of Windows 2003 SP1. </p>     </li>      <li>       <p>The value of the offset for diskpar.exe is expressed in sectors (512 bytes) and differs from the ALIGN option of DiskPart.exe, which uses a value defined in KB. For example “create partition primary align=64” creates a partition using a 64-KB offset.</p>     </li>   </ul>    <p>To determine the current starting offset of a volume (or partition), you can either use Diskpar.exe with the <strong>–i</strong> option or WMI (as demonstrated in the following script) if Diskpar.exe is not available.</p>    <pre>strComputer = &quot;.&quot; 
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) 
Set colItems = objWMIService.ExecQuery( _&#160;&#160;&#160;&#160; &quot;SELECT * FROM Win32_DiskPartition&quot;,,48) 
For Each objItem in colItems&#160;&#160;&#160;&#160; Wscript.Echo &quot;Disk: &quot; &amp; objItem.DiskIndex &amp; &quot;&#160; Partition: &quot; &amp; objItem.Index &amp; &quot;&#160; StartingOffset: &quot; &amp; objItem.StartingOffset/1024 &amp; &quot;KB&quot;&#160;&#160;&#160;&#160; Wscript.Echo 
Next</pre>

  <p>For more information on DiskPart.exe, see <a href="https://technet2.microsoft.com/WindowsServer/en/library/ca099518-dde5-4eac-a1f1-38eff6e3e5091033.mspx?mfr=true">DiskPart</a> on Microsoft TechNet, specifically the &quot;create partition primary&quot; section.</p>
</blockquote>

<p>}</p>

<p>&#160;</p>

<p>I have been setting up this disk partition offset at all of my customer’s wherever a new SQL box or a new SAN deployment was planned out. As this is a task that could only be done while formatting hard drives. </p>

<p>I was following this at a customer place where some new clustered disk(s) were to introduced. the only challenge out there was that this customer was still running their systems on Windows 2000 Advanced Server.&#160; (I know it’s a bit outdated, but still running their mission critical database system) and I never used DiskPart.EXE on windows 2000.</p>

<p>So, I downloaded the DiskPart.EXE from Windows 2000 Resource Kit and ran the usual command.</p>

<p>CREATE PRIMARY PARTITION ALIGN=64</p>

<p>and I could not believe on the result. The tool diskPart.exe did not liked my syntax for this command. and I could not do this task on windows 2000.</p>

<p>I went through a lo of reading and then came to know that&#160; I should use DiskPar.EXE (no typo – It’s DiskPar.exe - Without the ‘t’ ). </p>

<p>then I began my quest to download the tool. After a long search, I managed to get the tool. </p>

<p>you could get it from My SkyDrive folder <a href="https://cid-3c71087f6b65b1a7.skydrive.live.com/browse.aspx/SQLTools" target="_blank">here</a></p>

<p>The usage is simple. </p>

<p>&#160;</p>

<p>DiskPar.Exe [-?] [ -i | -s ] DriveNumber </p>

<p>Where: </p>

<p>-? displays command-line help.</p>

<p>-i DriveNumber&#160;&#160; :queries drive layout and partition information. </p>

<p>-s DriveNumber&#160; :sets new partition information. </p>

<p>you would get the Drive number in the Disk Management GUI.</p>

<p>&#160;</p>

<p>also note that you would need to restart two services for the disks to be used again as needed.</p>

<p>See <a href="https://technet.microsoft.com/en-us/library/Bb643096.aspx" target="_blank">Technet</a>&#160; for more information </p>

<p>&#160;</p>

<p>Hope this helps.
  </p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server internals Viewer</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/sql-server-internals-viewer</link>
      <pubDate>Fri, 17 Apr 2009 02:28:08 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2009/04/17/sql-server-internals-viewer/</guid>
      <description><![CDATA[&#160;  This is a nice tool for someone who needs to see whats inside a 8k SQL Data Page.  check it...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>This is a nice tool for someone who needs to see whats inside a 8k SQL Data Page.</p>  <p>check it out yourself: <a title="https://internalsviewer.codeplex.com" href="https://internalsviewer.codeplex.com">https://internalsviewer.codeplex.com</a></p>  <p>Features:</p>  <p><b>Features</b></p>  <ul>   <li>Integration with SSMS (SQL Server Management Studio) 2005 and 2008      <ul>       <li>The application is installed as a SSMS add-in </li>        <li>Internals information integrated into the Object Explorer </li>        <li>Transaction Log viewer integrated into the Query Results</li>     </ul>   </li> </ul>  <ul>   <li>Allocation Map      <ul>       <li>Displays the physical layout of tables and indexes </li>        <li>Displays PFS status </li>        <li>Overlay pages in the Buffer Pool</li>     </ul>   </li> </ul>  <ul>   <li>Page Viewer      <ul>       <li>Displays Data pages including forwarding records and sparse columns </li>        <li>Displays Index pages </li>        <li>Displays allocation pages (IAM, GAM, SGAM, DCM, and BCM pages) </li>        <li>Displays pages with SQL Server 2008 row and page compression</li>     </ul>   </li> </ul>]]></content:encoded>
    </item>
    <item>
      <title>Planning to upgrade to SQL Server 2008</title>
      <link>https://docs.microsoft.com/archive/blogs/amitjet/planning-to-upgrade-to-sql-server-2008</link>
      <pubDate>Thu, 25 Dec 2008 08:10:31 GMT</pubDate>
      <dc:creator><![CDATA[Amit Jethva [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/amitjet/2008/12/25/planning-to-upgrade-to-sql-server-2008/</guid>
      <description><![CDATA[If you are planning to upgrade your legacy systems running on SQL Server 2000/2005 to the latest...]]></description>
      <content:encoded><![CDATA[<p>If you are planning to upgrade your legacy systems running on SQL Server 2000/2005 to the latest version i.e. SQL Server 2008, start with this guide.&#160; It contains almost everything one needs to know for the upgrade.</p>  <p>&#160;</p>  <p><strong>SQL Server 2008 Upgrade Technical Reference Guide</strong></p>  <p><a title="https://www.microsoft.com/downloads/details.aspx?FamilyID=66D3E6F5-6902-4FDD-AF75-9975AEA5BEA7&amp;displaylang=en" href="https://www.microsoft.com/downloads/details.aspx?FamilyID=66D3E6F5-6902-4FDD-AF75-9975AEA5BEA7&amp;displaylang=en">https://www.microsoft.com/downloads/details.aspx?FamilyID=66D3E6F5-6902-4FDD-AF75-9975AEA5BEA7&amp;displaylang=en</a>&#160; <br /></p>  <p>&#160;</p>  <p>Also One more must download is <strong>SQL Server 2008 Upgrade Advisor.&#160; </strong>It is a separate download. The most recent downloadable version is available as part of the <a href="https://go.microsoft.com/fwlink/?LinkID=133088">Microsoft SQL Server 2008 Feature Pack</a>.</p>  <p>&#160;</p>  <p>If you are (still) running your systems on SQL Server 7.0, then upgrade to SQL Server 2000 or 2005 first and then to SQL Server 2008.</p>]]></content:encoded>
    </item>
  </channel>
</rss>