<?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>Thoughts.GetRandom().ToBlog()</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/vascov/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/vascov/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:10:54 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Spent a lot of time trying to talk to a "Muted" WCF ServiceHost</title>
      <link>https://docs.microsoft.com/archive/blogs/vascov/spent-a-lot-of-time-trying-to-talk-to-a-muted-wcf-servicehost</link>
      <pubDate>Fri, 10 Apr 2009 23:32:00 GMT</pubDate>
      <dc:creator><![CDATA[vascov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vascov/2009/04/10/spent-a-lot-of-time-trying-to-talk-to-a-muted-wcf-servicehost/</guid>
      <description><![CDATA[Today i spent 1h trying to figure why i couldn't talk to a WCF Endpoint hosted on a Windows Service....]]></description>
      <content:encoded><![CDATA[<P>Today i spent 1h trying to figure why i couldn't talk to a WCF Endpoint hosted on a Windows Service. </P>
<P>I did some&nbsp;work on my Vista laptop yesterday where everything was working fine and then copied the Service library (that contains the service i wanted to host) to my main dev box (Win7), added it to my Windows Service host and hacked some quick code/config to have it created by the service and running.</P>
<P>The service started fine and the logs were saying that the service host for the WCF service i just added was all good, but&nbsp;from my clients I kept getting:</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas"><FONT size=3>System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://localhost:8733/...Service. The connection attempt lasted for a time span of 00:00:02.0323046. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8733<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></SPAN></P>
<P>Hmm, must be some Win7 security goo. So i spent the next <STRONG>*hour*</STRONG> trying a gazzilion of things - security? turned it off and no go, firewall? some weird policy? configured it and created a console app that opened the port and it was working fine. Need to do netsh http iplisten? that's for http, but who knows.... nothing still. Ok, let's try&nbsp;another binding&nbsp;instead, still same issue... . Ok, let's trace the client and server setting up WCF diagnostic traces...&nbsp;nothing&nbsp;relevant on the server and&nbsp;i already know what the client is going through. Ok, run under the debugger and see if there's anything weird... still nothing. Just looks like the&nbsp;wcf service is "muted" but it does not complain when i start it, and I know i'm creating the host and starting one by one.... I cannot be the only one having this problem so let's see what live.com finds... many different issues but i've already covered most of the tips or they don't apply. <BR>At this point I'm starting to lower the level of investigation&nbsp;to figure what's going on with the ports, so i just try to use telnet</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas"><FONT size=3>&gt;telnet localhost 8733<BR>Connecting To localhost...Could not open connection to the host, on port 8733: Connect failed<o:p></o:p></FONT></SPAN></P>
<P>ok, let me use netstat to confirm that i've used the right port and protocol (which is probably what i should&nbsp;have done to begin with):</P>
<P><FONT size=3 face=Consolas>&gt; netstat -a -o | findstr 8733<BR>&gt;</FONT></P>
<P>nothing! i'm absolutelly sure that i'm only using netTcpBinding and i review my code and config and yes, that's the port! <BR>I use netstat again to verify what other ports might be opened for my process (pid&nbsp;5868 - not to confuse with port nb)</P>
<P><FONT size=3 face=Consolas>&gt; netstat -a -o | findstr 5868<BR>&gt;</FONT></P>
<P>nothing again!<BR>At this point i'm really confused, but the only logical explanation is that my hosting code is busted, so i review it again and compare it to the last version... and finally understand what happened.</P>
<P>I added some tracing to know in detail when each&nbsp;ServiceHost was created and in doing so, i removed a "kind of important" line by accident </P><FONT color=#dcdccc size=2><FONT color=#dcdccc size=2></FONT></FONT><FONT color=#dfdfbf size=2><FONT color=#dfdfbf size=2>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; BACKGROUND: black; COLOR: #dcdccc; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: black"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: Consolas; BACKGROUND: black; COLOR: #dfdfbf; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: black">host</SPAN><SPAN style="FONT-FAMILY: Consolas; BACKGROUND: black; COLOR: #dcdccc; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: black">.</SPAN><SPAN style="FONT-FAMILY: Consolas; BACKGROUND: black; COLOR: #dfdfbf; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: black">Open</SPAN><SPAN style="FONT-FAMILY: Consolas; BACKGROUND: black; COLOR: #dcdccc; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: black">();</SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; BACKGROUND: black; COLOR: #dcdccc; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: black"><o:p></o:p></SPAN>&nbsp;</P></FONT></FONT><FONT color=#dcdccc size=2><FONT color=#dcdccc size=2>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><FONT color=#000000>I "uncomment" it, and now everything's good again.</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas"><FONT size=3>&gt;netstat -a -o | findstr 2864<BR><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>TCP<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>0.0.0.0:8733<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>MACHINE1:0 <SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>LISTENING<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>2864<BR><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>TCP<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>[::]:8733<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>MACHINE1:0 <SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>LISTENING<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>2864<BR><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>UDP<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>127.0.0.1:63316<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>*:*<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>2864<o:p></o:p></FONT></SPAN></P></FONT></SPAN>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><FONT color=#000000>So, moral of the story: <STRONG>cover you basics first</STRONG>. </FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><FONT color=#000000>Make sure the server is actually "listening" in order to reply and not "muted" and double check your code changes before&nbsp;trying heavy weight techniques and tools :)</FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><FONT color=#000000>This time i'm also documenting it so that if i run into this again (to be honest i'ts not the first time :)) so that i don't forget again!</FONT></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><FONT color=#000000></FONT></SPAN>&nbsp;</P></FONT></FONT>]]></content:encoded>
    </item>
    <item>
      <title>Using Performance Dashboard with SQL Server 2008</title>
      <link>https://docs.microsoft.com/archive/blogs/vascov/using-performance-dashboard-with-sql-server-2008</link>
      <pubDate>Tue, 30 Sep 2008 16:57:00 GMT</pubDate>
      <dc:creator><![CDATA[vascov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vascov/2008/09/30/using-performance-dashboard-with-sql-server-2008/</guid>
      <description><![CDATA[Today,&nbsp;by the force of habit i was trying to spawn SQL Server Performance Dashboard to diagnose...]]></description>
      <content:encoded><![CDATA[<P>Today,&nbsp;by the force of habit i was trying to spawn <A href="https://www.microsoft.com/downloads/details.aspx?familyid=1d3a4a0d-7e0c-4730-8204-e419218c1efc&amp;displaylang=en" mce_href="https://www.microsoft.com/downloads/details.aspx?familyid=1d3a4a0d-7e0c-4730-8204-e419218c1efc&amp;displaylang=en">SQL Server Performance Dashboard</A> to diagnose a SQL perf issue and didn't even realize the DB was SQL 2k8.<BR>I just went ahead to execute setup.sql to setup the sprocs that Perf Dashboard requires for that server and then to my great surprise ran into an error</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">Msg 207<SPAN style="COLOR: gray">,</SPAN> <SPAN style="COLOR: blue">Level</SPAN> 16<SPAN style="COLOR: gray">,</SPAN> <SPAN style="COLOR: blue">State</SPAN> 1<SPAN style="COLOR: gray">,</SPAN> <SPAN style="COLOR: blue">Procedure</SPAN> usp_Main_GetCPUHistory<SPAN style="COLOR: gray">,</SPAN> Line 6<BR></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Invalid <SPAN style="COLOR: blue">column</SPAN> name <SPAN style="COLOR: red">'cpu_ticks_in_ms'</SPAN><SPAN style="COLOR: gray">.</SPAN></SPAN></P>
<P>Here's a peek at the code (from setup.sql that ships with the Performance Dashboard):<BR><BR></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">create</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">procedure</SPAN> MS_PerfDashboard<SPAN style="COLOR: gray">.</SPAN>usp_Main_GetCPUHistory<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">as<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">begin<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">declare</SPAN> @ts_now <SPAN style="COLOR: blue">bigint<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">select</SPAN> @ts_now <SPAN style="COLOR: gray">=</SPAN> cpu_ticks <SPAN style="COLOR: gray">/</SPAN> <SPAN style="COLOR: fuchsia">convert</SPAN><SPAN style="COLOR: gray">(</SPAN><SPAN style="COLOR: blue">float</SPAN><SPAN style="COLOR: gray">,</SPAN> <STRONG><U>cpu_ticks_in_ms</U></STRONG><SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: blue">from</SPAN> <SPAN style="COLOR: green">sys</SPAN><SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: green">dm_os_sys_info<BR></SPAN></SPAN>...</P>
<P>Hmm, what is going on !? Ah, this is Sql 2k8!</P>
<P>At this point i was about to switch to using the new super cool Activity Monitor in SQL2k8, but i was still intrigued, why wasn't this working? <BR>I'm so used to Performance Dashboard that I wanted to know whether this was not going to work against Sql 2k8.<BR><BR>After some&nbsp;<A href="https://search.live.com/results.aspx?setflight=0&amp;mkt=en-us&amp;q=sys.dm_os_sys_info cpu_ticks_in_ms changes +site:microsoft.com" mce_href="https://search.live.com/results.aspx?setflight=0&amp;mkt=en-us&amp;q=sys.dm_os_sys_info cpu_ticks_in_ms changes +site:microsoft.com">live searching</A> i found that the column had been <A href="https://msdn.microsoft.com/en-us/library/ms143179.aspx" mce_href="https://msdn.microsoft.com/en-us/library/ms143179.aspx">removed</A> (well, i already knew&nbsp;that :)) and that it was <A href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=292638" mce_href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=292638">due to some imprecision</A>&nbsp;with its value.<BR>The next question was how to fix the query in Sql 2k8, and it turned out to&nbsp;be a&nbsp;very trivial fix.&nbsp;<BR>Looking at sys.dm_os_sys_info <A href="https://msdn.microsoft.com/en-us/library/ms175048.aspx" mce_href="https://msdn.microsoft.com/en-us/library/ms175048.aspx">2k8</A> schema and at the original query using cpu_ticks_in_ms i&nbsp;saw a very interesting column (ms_ticks):<BR><BR>
<TABLE style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; MARGIN: auto auto auto 2.35pt; WIDTH: 97%; BORDER-COLLAPSE: collapse; BACKGROUND: #cccccc; BORDER-TOP: medium none; BORDER-RIGHT: medium none; mso-border-alt: solid #DDDDDD .5pt; mso-yfti-tbllook: 1184" class=MsoNormalTable border=1 cellSpacing=0 cellPadding=0 width="97%" class="MsoNormalTable">
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes">
<TD style="BORDER-BOTTOM: #c8cdde 1pt solid; BORDER-LEFT: #cccccc 1pt solid; PADDING-BOTTOM: 2.35pt; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BORDER-TOP: #cccccc 1pt solid; BORDER-RIGHT: #cccccc 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #CCCCCC .25pt; mso-border-bottom-alt: solid #C8CDDE .5pt" vAlign=bottom>
<P style="LINE-HEIGHT: normal; MARGIN: 2.35pt 0in" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #000066; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">Column name <o:p></o:p></SPAN></B></P></TD>
<TD style="BORDER-BOTTOM: #c8cdde 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 2.35pt; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BORDER-TOP: #cccccc 1pt solid; BORDER-RIGHT: #cccccc 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #CCCCCC .25pt; mso-border-bottom-alt: solid #C8CDDE .5pt; mso-border-left-alt: solid #CCCCCC .25pt" vAlign=bottom>
<P style="LINE-HEIGHT: normal; MARGIN: 2.35pt 0in" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #000066; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">Data type <o:p></o:p></SPAN></B></P></TD>
<TD style="BORDER-BOTTOM: #c8cdde 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 2.35pt; BACKGROUND-COLOR: transparent; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BORDER-TOP: #cccccc 1pt solid; BORDER-RIGHT: #cccccc 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #CCCCCC .25pt; mso-border-bottom-alt: solid #C8CDDE .5pt; mso-border-left-alt: solid #CCCCCC .25pt" vAlign=bottom>
<P style="LINE-HEIGHT: normal; MARGIN: 2.35pt 0in" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #000066; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">Description <o:p></o:p></SPAN></B></P></TD></TR>
<TR style="mso-yfti-irow: 1">
<TD style="BORDER-BOTTOM: #d5d5d3 1pt solid; BORDER-LEFT: #d5d5d3 1pt solid; PADDING-BOTTOM: 2.35pt; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BACKGROUND: white; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #d5d5d3 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #D5D5D3 .5pt; mso-border-top-alt: solid #D5D5D3 .5pt" vAlign=top>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0.45pt 4.7pt" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">cpu_ticks</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'"> <o:p></o:p></SPAN></P></TD>
<TD style="BORDER-BOTTOM: #d5d5d3 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 2.35pt; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BACKGROUND: white; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #d5d5d3 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #D5D5D3 .5pt; mso-border-left-alt: solid #D5D5D3 .5pt; mso-border-top-alt: solid #D5D5D3 .5pt" vAlign=top>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0.45pt 4.7pt" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">bigint</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'"> <o:p></o:p></SPAN></P></TD>
<TD style="BORDER-BOTTOM: #d5d5d3 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 2.35pt; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BACKGROUND: white; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #d5d5d3 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #D5D5D3 .5pt; mso-border-left-alt: solid #D5D5D3 .5pt; mso-border-top-alt: solid #D5D5D3 .5pt" vAlign=top>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0.45pt 4.7pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">Current CPU tick count. CPU ticks are obtained from the processor's RDTSC counter. It is a monotonically increasing number. <o:p></o:p></SPAN></P></TD></TR>
<TR style="mso-yfti-irow: 2; mso-yfti-lastrow: yes">
<TD style="BORDER-BOTTOM: #d5d5d3 1pt solid; BORDER-LEFT: #d5d5d3 1pt solid; PADDING-BOTTOM: 2.35pt; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BACKGROUND: white; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #d5d5d3 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #D5D5D3 .5pt; mso-border-top-alt: solid #D5D5D3 .5pt" vAlign=top>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0.45pt 4.7pt" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">ms_ticks</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'"> <o:p></o:p></SPAN></P></TD>
<TD style="BORDER-BOTTOM: #d5d5d3 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 2.35pt; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BACKGROUND: white; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #d5d5d3 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #D5D5D3 .5pt; mso-border-left-alt: solid #D5D5D3 .5pt; mso-border-top-alt: solid #D5D5D3 .5pt" vAlign=top>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0.45pt 4.7pt" class=MsoNormal><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">bigint</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'"> <o:p></o:p></SPAN></P></TD>
<TD style="BORDER-BOTTOM: #d5d5d3 1pt solid; BORDER-LEFT: #f0f0f0; PADDING-BOTTOM: 2.35pt; PADDING-LEFT: 2.35pt; PADDING-RIGHT: 2.35pt; BACKGROUND: white; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #d5d5d3 1pt solid; PADDING-TOP: 2.35pt; mso-border-alt: solid #D5D5D3 .5pt; mso-border-left-alt: solid #D5D5D3 .5pt; mso-border-top-alt: solid #D5D5D3 .5pt" vAlign=top>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0.45pt 4.7pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: black; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'">Number of milliseconds since the computer was started. <o:p></o:p></SPAN></P></TD></TR></TBODY></TABLE></P>
<P>The reason that column was interesting is because <FONT face="Courier New">cpu_ticks <SPAN style="COLOR: gray">/</SPAN> <SPAN style="COLOR: fuchsia">convert</SPAN><SPAN style="COLOR: gray">(</SPAN><SPAN style="COLOR: blue">float</SPAN><SPAN style="COLOR: gray">,</SPAN> cpu_ticks_in_ms<SPAN style="COLOR: gray">)</SPAN></FONT> looks awefuly similar (ticks/(ticks/ms) == ms) to what ms_ticks already provides!<BR>I ran some tests to make sure this column was good in both sql 2k5 and 2k8:</P>
<P><FONT color=#0000ff size=2><FONT color=#0000ff size=2><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">select</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><FONT color=#000000> cpu_ticks </FONT><SPAN style="COLOR: gray">/</SPAN><FONT color=#000000> ms_ticks </FONT><SPAN style="COLOR: blue">as</SPAN><FONT color=#000000> ratio_ticks_in_ms</FONT><SPAN style="COLOR: gray">,</SPAN><FONT color=#000000> cpu_ticks</FONT><SPAN style="COLOR: gray">,</SPAN><FONT color=#000000> ms_ticks </FONT><SPAN style="COLOR: blue">from</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: green">sys</SPAN><SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: green">dm_os_sys_info</SPAN></SPAN></FONT></FONT></P>
<P mce_keep="true">The first column (ratio_ticks_in_ms) remained (mostly - within 0.000001% variance which i believe is due to rounding errors in ms_ticks) constant (and surprise, it was roughly my CPU frequency in ms - number of CPU ticks per millisecond). Note this happened in both SQL 2k5 and 2k8 (and i verified this across 3 different boxes). In SQL 2k5 i also added cpu_ticks_in_ms to the output and again it was within 0.000001%.</P>
<P mce_keep="true">So, it seemed weird that in SQL 2k5 the query was written to divide cpu_ticks / cpu_ticks_in_ms given that ms_ticks is also present in sys.dm_os_sys_info 2k5. I can't think of any good reason (other than minimizing the rounding error of ms_ticks) and since ms_ticks was not dropped in 2k8 it was probably as reliable in 2k5 so i'll assume that was just some copy/paste, historical reasons...</P>
<P mce_keep="true">On any case, i then changed the original stmt to </P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">create</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">procedure</SPAN> MS_PerfDashboard<SPAN style="COLOR: gray">.</SPAN>usp_Main_GetCPUHistory<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">as<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">begin<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">declare</SPAN> @ts_now <SPAN style="COLOR: blue">bigint<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">select</SPAN> @ts_now <SPAN style="COLOR: gray">=</SPAN> ms_ticks <SPAN style="COLOR: blue">from</SPAN> <SPAN style="COLOR: green">sys</SPAN><SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: green">dm_os_sys_info</SPAN></SPAN></P>
<P>and ran setup.sql again. </P>
<P mce_keep="true">I haven't tested all the reports, but all i've tested (main, costliest queries and some others) all seem to be working fine!</P>
<P mce_keep="true">So, there you go. If you are running into errors trying to deploy SQL Server Performance Dashboard into 2k8 just change setup.sql as shown above and you should be good.</P>
<P mce_keep="true">That said i should say that Activity Monitor + Performance Data Collector and reports in Sql 2k8 are&nbsp;SIMPLY AWESOME and you should definetely look at them too.<BR></P>
<P>PS: It has been a long time since i've published anything and very commonly I wish I had posted something that I (or somebody else) end up needing again. So, i'm trying to keep up to date again.</P>]]></content:encoded>
    </item>
    <item>
      <title>Must Read - Performance</title>
      <link>https://docs.microsoft.com/archive/blogs/vascov/must-read-performance</link>
      <pubDate>Wed, 30 Nov 2005 18:00:00 GMT</pubDate>
      <dc:creator><![CDATA[vascov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vascov/2005/11/30/must-read-performance/</guid>
      <description><![CDATA[The Ten Rules of Performancehttps://www.panopticoncentral.net/articles/946.aspx
and
Improving .NET...]]></description>
      <content:encoded><![CDATA[<P><FONT face=Tahoma>The Ten Rules of Performance<BR></FONT><A href="https://www.panopticoncentral.net/articles/946.aspx"><FONT face=Tahoma>https://www.panopticoncentral.net/articles/946.aspx</FONT></A></P>
<P><FONT face=Tahoma>and</FONT></P>
<P><FONT face=Tahoma>Improving .NET Application Performance and Scalability<BR></FONT><A href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenet.asp"><FONT face=Tahoma>https://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenet.asp</FONT></A></P>
<P><FONT face=Tahoma>My favorite quote:<BR>"If your software does not meet its performance objectives, your application is unlikely to be a success.<BR>If you do not know your performance objectives, it is unlikely that you will meet them"<BR></FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>Getting a string array from SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/vascov/getting-a-string-array-from-sql-server</link>
      <pubDate>Mon, 21 Nov 2005 17:06:00 GMT</pubDate>
      <dc:creator><![CDATA[vascov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vascov/2005/11/21/getting-a-string-array-from-sql-server/</guid>
      <description><![CDATA[After the last post showing how to pass an array into SQL, i will show how to go the other way...]]></description>
      <content:encoded><![CDATA[<P><FONT face=Tahoma>After the last </FONT><a href="https://blogs.msdn.com/vascov/archive/2005/11/20/495154.aspx"><FONT face=Tahoma>post</FONT></A><FONT face=Tahoma> showing how to pass an array into SQL, i will show how to go the other way around. How to get a string array from a table.</FONT></P>
<P><FONT face=Tahoma>I should note that i ONLY pass and get arrays as strings on very specific cases (usually perf, test&nbsp;or dbg&nbsp;related). <BR></FONT><FONT face=Tahoma>Whenever possible i use relational operations only, especially for returning collections. Sometimes it is useful though to be able to return&nbsp;a single column with more than one elm, especially when the actual destination of the data is a function that expects a delimiter separated list.</FONT></P>
<P><FONT face=Tahoma>That said, getting a bunch of params as a string array can be done like this:</FONT></P>
<P><FONT face="Courier New">DECLARE @outStringArray VARCHAR(MAX)<BR>SET @outStringArray = NULL</FONT></P>
<P><FONT face="Courier New">SELECT&nbsp;&nbsp;&nbsp; @outStringArray = ( COALESCE( NULLIF( @outStringArray + ',', '' ), '' ) + Name )<BR>FROM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sys.objects</FONT></P>
<P><FONT face="Courier New">SELECT&nbsp;&nbsp;&nbsp; @outStringArray<BR></FONT><FONT face="Courier New"></FONT></P>
<P><FONT face="Courier New"><FONT face=Tahoma>The interesting part is </FONT>COALESCE( NULLIF( @outStringArray&nbsp;+ ',', '' ), '' ) + Name</FONT><FONT face=Tahoma> which should read:<BR>if @outStringArray is not NULL, then return the current string +&nbsp;',' + Name. If it is null, return '' + Name.</FONT></P>
<P><FONT face=Tahoma>We return '' + Name, because if we return NULL&nbsp;+ Name, then NULL + something is NULL and our string would never grow.<BR>You could also use SELECT CASE WHEN syntax, but i prefer this more compact form of saying the same. (after some time using this on queries you learn the meaning quite fast)<BR>You could also use SQLCLR, xml (though not exactly a comma separated thing) and&nbsp;recursive functions.</FONT></P>
<P><FONT face=Tahoma>Again, you can have specialized versions to deal with NULLs in the string (doing <FONT face="Courier New">+ COALESCE( Name, 'N/A')</FONT> instead of <FONT face="Courier New">+ Name</FONT> for example), to deal&nbsp;with different types, as well as different sort orders, more than one string field (e.g: <FONT face="Courier New">+ Name + ':' + Value</FONT>).</FONT></P>
<P><FONT face=Tahoma>Another use for this is sometimes when you want to compare hierarquical data the queries can become complex, and this way you can kind of serialize the hierarquies and then do a simple string comparison... (more on this on future posts)</FONT></P>
<P><FONT face=Tahoma></FONT>&nbsp;</P>
<P><FONT face="Courier New">&nbsp;</P></FONT>]]></content:encoded>
    </item>
    <item>
      <title>Passing an array to SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/vascov/passing-an-array-to-sql-server</link>
      <pubDate>Mon, 21 Nov 2005 00:39:00 GMT</pubDate>
      <dc:creator><![CDATA[vascov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vascov/2005/11/21/passing-an-array-to-sql-server/</guid>
      <description><![CDATA[Often times i need to pass a variable&nbsp;number of arguments to SQL, and since there's no array...]]></description>
      <content:encoded><![CDATA[<P><FONT face=Tahoma>Often times i need to pass a variable&nbsp;number of arguments to SQL, and since there's no array support i usually end up doing:</FONT></P>
<OL>
<LI><FONT face=Tahoma>Adding parameters to T-SQL with default values&nbsp;</FONT> 
<LI><FONT face=Tahoma>Passing a string with some delimiter and building a table from that</FONT></LI></OL>
<P><FONT face=Tahoma size=4>1. Adding parameters to T-SQL with default values is something like:</FONT></P>
<P><FONT face="Courier New">CREATE PROC GetCustomersById<BR>(<BR>&nbsp;&nbsp;&nbsp;@CustomerId1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INT = NULL<BR>&nbsp;&nbsp;&nbsp;, @CustomerId2&nbsp;&nbsp;&nbsp;INT = NULL<BR>&nbsp;&nbsp;&nbsp;...<BR>) AS<BR>BEGIN<BR>&nbsp;&nbsp;&nbsp;SELECT Customer.CustomerId<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, Customer.Name<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , ...<BR>&nbsp;&nbsp;&nbsp;FROM&nbsp;&nbsp;&nbsp;Customer<BR>&nbsp;&nbsp;&nbsp;WHERE&nbsp;&nbsp;Customer.CustomerId IN ( @CustomerId1, @CustomerId2 )<BR></FONT><FONT face="Courier New">END</FONT></P>
<P><FONT face=Tahoma>There are some variations to the way one can consume the values, like storing them on a temp table or table variable,&nbsp;using COALESCE,... .</FONT></P>
<P><FONT face=Tahoma>For simple stuff this works well but it does not scale as you add more parameters, or you need to pass in collections of related parameters (like structures). It starts to get messier.</FONT></P>
<P><FONT face=Tahoma size=4>2. Passing a string with some delimiter and building a table from that</FONT></P>
<P><FONT face=Tahoma>For this method, we need&nbsp;a way to&nbsp;convert a string into a table. For that&nbsp;i use a function that returns a table&nbsp;variable. That's&nbsp;very convenient because one can use&nbsp;it directly&nbsp;on&nbsp;the queries as well as store it on local table variables.</FONT></P>
<P><FONT face="Courier New">/*<BR>&nbsp;&nbsp;&nbsp; Used to convert a delimited string into a table<BR>&nbsp;&nbsp;&nbsp; Ex: SELECT * FROM StringArray2Table( 'one,two,three,four,five', ',' )<BR><BR>&nbsp;&nbsp;&nbsp; Notes: not dealing with overflow of elements, and when empty elms are found they<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; are converted to NULL.</FONT><FONT face="Courier New"><BR>*/<BR>CREATE FUNCTION StringArray2Table <BR>( <BR>&nbsp;&nbsp;&nbsp; @stringArray VARCHAR(MAX)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- delimited string array (max elm size = 255)<BR>&nbsp;&nbsp;&nbsp; , @delimiter CHAR(1) = ','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- , by default<BR>) <BR>RETURNS @Table&nbsp; TABLE <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ix int identity(1,1)&nbsp;&nbsp;-- useful to correlate two arrays and<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- preserve order of elements</FONT><FONT face="Courier New"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , elm VARCHAR(255)&nbsp;&nbsp;&nbsp;&nbsp;-- elmts&nbsp;may overflow, not being checked<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) <BR>AS <BR>BEGIN </FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp; DECLARE @elm VARCHAR(255)<BR>&nbsp;&nbsp;&nbsp; DECLARE @from INT<BR>&nbsp;&nbsp;&nbsp; DECLARE @ix INT</FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp; SET @from = 1&nbsp;-- start from the beginning<BR></FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp; SET @ix = CHARINDEX( @delimiter, @stringArray, @ix ) </FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp; WHILE (@ix &gt; 0) -- while there's a match<BR>&nbsp;&nbsp;&nbsp; BEGIN <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @elm = SUBSTRING( @stringArray, @from, @ix - @from ) </FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IF ( @ix = @from )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO @Table( elm )&nbsp;VALUES ( NULL )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ELSE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO @Table( elm ) VALUES ( @elm ) </FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @from = @ix + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @ix = CHARINDEX( @delimiter, @stringArray, @from ) &nbsp;-- find next<BR>&nbsp;&nbsp;&nbsp; END </FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp; IF ( @from - 1 &lt;= len( @stringArray ) )&nbsp;&nbsp;&nbsp;&nbsp;-- last elm<BR>&nbsp;&nbsp;&nbsp; BEGIN<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @elm = SUBSTRING( @stringArray, @from,&nbsp;255 )</FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IF LEN(@elm) &gt; 0 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO @Table( elm ) VALUES ( @elm ) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ELSE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INSERT INTO @Table( elm ) VALUES ( NULL )<BR>&nbsp;&nbsp;&nbsp; END</FONT></P>
<P><FONT face="Courier New">&nbsp;&nbsp;&nbsp; RETURN<BR>END </FONT></P>
<P><FONT face="Courier New"></FONT><FONT face=Tahoma>and then one can use it like</FONT></P>
<P><FONT face="Courier New">CREATE PROC GetCustomersById<BR>(<BR>&nbsp;&nbsp;&nbsp;@CustomerList&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR(MAX)<BR>) AS<BR>BEGIN<BR>&nbsp;&nbsp;&nbsp;SELECT Customer.CustomerId<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, Customer.Name<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , ...<BR>&nbsp;&nbsp;&nbsp;FROM&nbsp;&nbsp;&nbsp;Customer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INNER JOIN dbo.StringArray2Table( @CustomerList, ',' ) CustArray<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ON Customer.CustomerId = CustArray.elm<BR></FONT><FONT face="Courier New">END</FONT></P>
<P><FONT face=Tahoma>I use some variations of this function, specialized by return type (return int for example),&nbsp;not&nbsp;returning the index, returning empty&nbsp;strings instead of NULL,&nbsp;returning more than one&nbsp;column (useful especially for "dictionary" like structures, e.g. 'Caption:asdasd,Height:2312,Width:123').</FONT></P>
<P><FONT face=Tahoma>When i use this function i always have control over the input data and make sure it does not conflict with the delimiter. Of course, it's easy to come up with a convention to avoid delimiter usage inside the elements (like SQL does for 's for example).</FONT></P>
<P><FONT face=Tahoma>There are other ways to pass in arrays, though i don't use them as often mainly because they are a bit more involved and imply more dependencies/configuration.&nbsp;The other options are xml type/OPENXML, varbinary, using SQLCLR (SQL2K5), etc...</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>Hello Blog</title>
      <link>https://docs.microsoft.com/archive/blogs/vascov/hello-blog</link>
      <pubDate>Mon, 21 Nov 2005 00:28:00 GMT</pubDate>
      <dc:creator><![CDATA[vascov]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vascov/2005/11/21/hello-blog/</guid>
      <description><![CDATA[I decided to start sharing some thoughts on this blog, hoping they will help people the same way i...]]></description>
      <content:encoded><![CDATA[<P><FONT face=Tahoma>I decided to start sharing some thoughts on this blog, hoping they will help people the same way i have benefited from other blogs and web sources. </FONT></P>
<P><FONT face=Tahoma>I'll blog randomnly mainly on System.Data, Xml and SQL Server, as they are closely related to my current job (perf for System.Xml, System.Data (DataSet especially) and MSXML)</FONT></P>
<P><FONT face=Tahoma>All feedback (questions, flames, comments...) is welcome.</FONT></P>
<P><FONT face=Tahoma></FONT>&nbsp;</P>
<P>&nbsp;</P>]]></content:encoded>
    </item>
  </channel>
</rss>