<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Vijay</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/vijaybk/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/vijaybk/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:34:41 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Build PowerBI Real Time Dashboards through Streaming Set with Python</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/build-powerbi-real-time-dashboards-through-streamset-with-python</link>
      <pubDate>Tue, 15 Aug 2017 05:35:41 GMT</pubDate>
      <dc:creator><![CDATA[VijayKorapadi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/?p=245</guid>
      <description><![CDATA[PowerBI supports streaming dataset through an API that can be used to constantly push data to the...]]></description>
      <content:encoded><![CDATA[<p>
 </p><p>PowerBI supports streaming dataset through an API that can be used to constantly push data to the service for real-time refresh. This post outlines the steps to accomplish it with Python script.
</p><ol><li><div><span style="font-size:14pt"><strong>Create a StreamDataSet in PowerBI
</strong></span></div><p>In your workspace, Click on "<strong><span style="font-size:14pt">+</span> Create</strong>" and choose "<strong>Streaming dataset</strong>"
</p></li></ol><p>
 </p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/2017/08/081817_0638_BuildPowerB1.png" alt="" />
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 36pt">Once you choose "streaming dataset" option, pick "API" streaming option since we will use this API to populate data from Python
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/2017/08/081817_0638_BuildPowerB2.png" alt="" />
	</p><p>
 </p><p style="margin-left: 36pt">Once you click Next, enter the data set name and the values that you need to post on the API. These values will then have to be used as data set on the dashboard.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/2017/08/081817_0638_BuildPowerB3.png" alt="" />
	</p><p style="margin-left: 36pt">Once you click on the create button, the service will create a Push URL that will be the API to push the data to. Copy the PUSH URL to the python script.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/2017/08/081817_0638_BuildPowerB4.png" alt="" />
	</p><p style="margin-left: 36pt">Then create a Dashboard and Add a tile and choose 'Custom streaming data'. You will then see the streaming data sets that was created in the previous step. You can add the elements that was created as part of the steam set. 
</p><p style="margin-left: 40pt"><img src="https://msdnshared.blob.core.windows.net/media/2017/08/081817_0638_BuildPowerB5.png" alt="" />
	</p><p style="margin-left: 40pt">Once the dashboard Is created, copy the PUSH URL in the script below. The below script reads data from a SQL Server table at regular interval and aggregates and generates the sum of the Income value. The generated totalincome is converted to a JSON format required for the Push URL and then post it to the API.
</p><p style="margin-left: 40pt">The script runs in an infinite loop, by reading data and pushing data into the PowerBI streaming set. In a real world scenario, the data read from the DB will have be incremental either based on date, ID or other relevant column.
</p><p><img align="left" src="https://msdnshared.blob.core.windows.net/media/2017/08/081817_0638_BuildPowerB6.png" alt="" />
	</p>]]></content:encoded>
    </item>
    <item>
      <title>Convert Normalized schema and merge JSON to an existing key-Value pair for NoSQL DBs using Python</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/convert-normalized-schema-and-merge-json-to-an-existing-key-value-pair-for-nosql-dbs-using-python</link>
      <pubDate>Fri, 28 Jul 2017 08:27:52 GMT</pubDate>
      <dc:creator><![CDATA[VijayKorapadi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/?p=207</guid>
      <description><![CDATA[In this blog post, we will be discussing how to merge a normalized data structure to a Key-Value...]]></description>
      <content:encoded><![CDATA[<p>
 </p><p>In this blog post, we will be discussing how to merge a normalized data structure to a Key-Value pair with a JSON. 
</p><p>Let's pick a scenario with customer and their Orders
</p><p><img src="https://msdnshared.blob.core.windows.net/media/2017/07/072817_0829_ConvertNorm1.png" alt="" />
	</p><p style="margin-left: 108pt">Table 1 – Customer and Order Relationship
</p><p>
 </p><p>The relationship between customer and order is 1..n. The order list below belongs to two different customers. The dataset in Table 2 is transformed and stored in the DB (either relational or NoSQL dbs) as mentioned in Table 3
</p><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/2017/07/072817_0829_ConvertNorm2.png" alt="" />
	</p><p style="margin-left: 72pt">Table 2 – Orders
</p><p style="text-align: center">
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/2017/07/072817_0829_ConvertNorm3.png" alt="" />
	</p><p style="margin-left: 36pt">Table 3 – Customer and Orders in key-value pair (JSON)
</p><p>
 </p><p>As customers place new orders, the dataset in Table 4 must be merged with the already existing JSON set to produce a table set as mentioned in Table 5.
</p><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/2017/07/072817_0829_ConvertNorm4.png" alt="" />
	</p><p style="margin-left: 36pt">Table 4 – New orders from Customer
</p><p style="text-align: center">
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/2017/07/072817_0829_ConvertNorm5.png" alt="" />
	</p><p style="margin-left: 108pt">Table 5 – Merged orders
</p><p style="margin-left: 108pt">
 </p><div><table style="border-collapse:collapse" border="0"><colgroup><col style="width:726px" /></colgroup><tbody valign="top"><tr><td style="padding-left: 7px;padding-right: 7px;border-top:  solid 0.5pt;border-left:  solid 0.5pt;border-bottom:  solid 0.5pt;border-right:  solid 0.5pt"><p><span style="font-size:8pt"><span style="color:#00b050"><span style="font-family:Courier New"><strong>import</strong></span>
								</span><span style="font-family:Courier New">pandas as pd, zlib, lzma
</span></span></p><p><span style="font-family:Courier New;font-size:8pt">dfneworders = pd.read_csv(<span style="color:#ed7d31">'C:\Temp\Outputfile\Blog\Orders.txt'</span>)
</span></p><p>
 </p><p><span style="font-family:Courier New;font-size:8pt">dfpreviousordercopy = pd.read_csv(<span style="color:#ed7d31">'C:\Temp\Outputfile\Blog\Output_Json.txt'</span>,quotechar=<span style="color:#ed7d31">"'",</span> sep = <span style="color:#ed7d31">"|"</span>)
</span></p><p>
 </p><p><span style="font-family:Courier New;font-size:8pt">rows = []
</span></p><p><span style="font-family:Courier New;font-size:8pt">_ = dfpreviousordercopy.apply(<span style="color:#00b050"><strong>lambda</strong></span> rowval: rows.append(pd.read_json(rowval[<span style="color:#ed7d31">'JSON'</span>], orient=<span style="color:#ed7d31">'records'</span>)), axis=<span style="color:#00b050"><strong>1</strong></span>)
</span></p><p><span style="font-family:Courier New;font-size:8pt">dfintegratedorders = pd.concat([pd.concat(rows[0:]), dfneworders])
</span></p><p><span style="font-family:Courier New;font-size:8pt">dftransposed = pd.DataFrame(dfintegratedorders.groupby([<span style="color:#ed7d31">'CustCode'</span>]).apply(<span style="color:#00b050"><strong>lambda</strong></span> dfsub:     dfsub.to_json(orient=<span style="color:#ed7d31">'records'</span>))).reset_index()
</span></p><p><span style="font-family:Courier New;font-size:8pt">dftransposed.columns = [<span style="color:#ed7d31">'CustCode'</span>,<span style="color:#ed7d31">'JSON'</span>]
</span></p><p><span style="font-family:Courier New;font-size:8pt">dftransposed.to_csv(<span style="color:#ed7d31">'C:\Temp\Outputfile\Blog\Output_MergedFile_withJson.txt'</span>, index=<span style="color:#00b050"><strong>False</strong></span>, quotechar=<span style="color:#ed7d31">"'"</span>, sep = <span style="color:#ed7d31">"|"</span>)</span></p></td></tr></tbody></table></div><p style="text-align: center">
 </p><p>The python script extracts from old JSON dataset and integrates new orders and rebuild the JSON.</p>]]></content:encoded>
    </item>
    <item>
      <title>Generate Unique Identifiers (UID) in U-SQL on Azure Data Lake Analytics with Python extension scripts</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/generate-unique-identifiers-in-u-sql-on-azure-data-lake-analytics</link>
      <pubDate>Mon, 10 Jul 2017 21:09:13 GMT</pubDate>
      <dc:creator><![CDATA[VijayKorapadi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/?p=175</guid>
      <description><![CDATA[U-SQL doesn't support constructs to generate Unique Identifier in Text Files. The script below...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family:Times New Roman;font-size:12pt">U-SQL doesn't support constructs to generate Unique Identifier in Text Files. The script below generates unique identifier for every row in the input file. 
</span></p><p><span style="font-family:Times New Roman;font-size:12pt">The steps are 
</span></p><ol><li>Extract the data file with the EXTRACT statement 
</li><li>REDUCERS are spun based on the customer code. Too little reducers or too many reducers may both cause performance issues. Identify a column that can fairly split, but make sure not to specify a unique column. 
</li><li>For every reduced data set, the python script is invoked with the DATA FRAME. Add another column to the data frame "sguid" and generate a new encoded UID. 
</li><li>The output produced out of the reducer will have a new column sguid 
</li></ol><p>
 </p><div><table style="border-collapse:collapse" border="0"><colgroup><col style="width:1103px" /></colgroup><tbody valign="top"><tr><td vAlign="middle" style="padding-top: 1px;padding-left: 7px;padding-bottom: 1px;padding-right: 7px;border-top:  solid 0.5pt;border-left:  solid 0.5pt;border-bottom:  solid 0.5pt;border-right:  solid 0.5pt"><p><span style="color:blue"><span style="font-family:Consolas;font-size:9pt">REFERENCE<span style="color:black">
										<span style="color:blue">ASSEMBLY<span style="color:black"> [ExtPython]; </span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p>   
 </p><p><span style="color:blue"><span style="font-family:Consolas;font-size:9pt">DECLARE<span style="color:black">
										<span style="color:olive">@ReduceScript<span style="color:black"> = <span style="color:#a31515">@"<span style="color:black">
													</span></span></span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">import uuid<span style="color:black">
									</span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">import base64<span style="color:black">
									</span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p>   
 </p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">def usqlml_main(df):<span style="color:black">
									</span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">        df['sguid'] = ''<span style="color:black">
									</span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">        df['sguid'] = df.sguid.apply(lambda row: str(base64.urlsafe_b64encode(uuid.uuid1().bytes)))<span style="color:black">
									</span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">        return df<span style="color:black">
									</span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:#a31515"><span style="font-family:Consolas;font-size:9pt">"<span style="color:black">; </span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p>   
 </p><p><span style="color:olive"><span style="font-family:Consolas;font-size:9pt">@AllData<span style="color:black"> =    <span style="color:blue">EXTRACT<span style="color:black">     OrderNo     <span style="color:blue">string<span style="color:black">, </span></span></span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        Date             <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        CustomerCode     <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        ProductCode        <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        SalesArea        <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        OrderValue        <span style="color:blue">string<span style="color:black">
										</span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">            <span style="color:blue">FROM<span style="color:black">         <span style="color:#a31515">"/DataLoads/Input/TempFile.csv"<span style="color:black">
												</span></span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">            <span style="color:blue">USING<span style="color:black">         Extractors.Text(delimiter: ',', skipFirstNRows: 1); </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p>   
 </p><p><span style="color:olive"><span style="font-family:Consolas;font-size:9pt">@ReducedData<span style="color:black"> = </span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">            <span style="color:blue">REDUCE<span style="color:black">         <span style="color:olive">@AllData<span style="color:black">
												</span></span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">            <span style="color:blue">ON<span style="color:black">            CustomerCode </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">            <span style="color:blue">PRODUCE<span style="color:black">        sguid <span style="color:blue">string<span style="color:black">, </span></span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        OrderNo     <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        Date             <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        CustomerCode     <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        ProductCode        <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        SalesArea        <span style="color:blue">string<span style="color:black">, </span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">                        OrderValue        <span style="color:blue">string<span style="color:black">
										</span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:black"><span style="font-family:Consolas;font-size:9pt">            <span style="color:blue">USING<span style="color:black">         <span style="color:blue">new<span style="color:black"> Extension.Python.Reducer(pyScript:<span style="color:olive">@ReduceScript<span style="color:black">); </span></span></span></span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p>   
 </p><p>   
 </p><p><span style="color:blue"><span style="font-family:Consolas;font-size:9pt">OUTPUT<span style="color:black">
										<span style="color:olive">@ReducedData<span style="color:black">
											</span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:blue"><span style="font-family:Consolas;font-size:9pt">TO<span style="color:black">
										<span style="color:#a31515">"/DataLoads/CSVOutputwithGUID.txt"<span style="color:black">
											</span></span></span></span><span style="font-family:Times New Roman;font-size:12pt">
								</span></span></p><p><span style="color:blue;font-family:Consolas;font-size:9pt">USING<span style="color:black"> Outputters.Text();</span></span></p></td></tr></tbody></table></div><p>   
 </p><p><span style="font-family:Times New Roman;font-size:12pt">Note : Follow <a href="https://onedrive.live.com/view.aspx?resid=3BDE3286AB2E59F7!451&amp;ithint=file%2cdocx&amp;app=Word&amp;authkey=!AG6W0IqCbfyx6Ow">these</a> instructions to enable U-SQL extensions on your ADL-A account</span></p>]]></content:encoded>
    </item>
    <item>
      <title>U-SQL Script with Python extension to detect Invalid input files</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/u-sql-script-with-python-extension-to-detect-invalid-input-files</link>
      <pubDate>Fri, 07 Jul 2017 17:13:12 GMT</pubDate>
      <dc:creator><![CDATA[VijayKorapadi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/?p=165</guid>
      <description><![CDATA[The script below validates each of input files in the folder and the python script splits and...]]></description>
      <content:encoded><![CDATA[<p>
 </p><p>The script below validates each of input files in the folder and the python script splits and count the number of columns in each row of every. Those files that either have &gt; or &lt; than 9 columns in any of its rows are all logged as Invalid files.
</p><p>
 </p><div><table style="border-collapse:collapse" border="0"><colgroup><col style="width:623px" /></colgroup><tbody valign="top"><tr><td style="padding-left: 7px;padding-right: 7px;border-top:  solid 0.5pt;border-left:  solid 0.5pt;border-bottom:  solid 0.5pt;border-right:  solid 0.5pt"><p><span style="color:#3366ff">REFERENCE ASSEMBLY </span>[ExtPython];
</p><p>
 </p><p><span style="color:#3366ff">DECLARE</span>
							<span style="color:#c00000">@</span>ReduceScript = <span style="color:#c00000">@</span>"<span style="color:#c00000">
							</span></p><p><span style="color:#c00000">def validate_rows(linetext, MaxCols):
</span></p><p><span style="color:#c00000">    return str((len(linetext.split(',')) - MaxCols))
</span></p><p>
 </p><p><span style="color:#c00000">def usqlml_main(df):
</span></p><p><span style="color:#c00000">    MaxCols = 9
</span></p><p><span style="color:#c00000">    df['noofcolumns'] = df.LineText.apply(validate_rows, args={MaxCols})
</span></p><p><span style="color:#c00000">    del df['extension']
</span></p><p><span style="color:#c00000">    del df['LineText']
</span></p><p>    
 </p><p><span style="color:#c00000">    return df
</span></p><p><span style="color:#c00000">"</span>;
</p><p>
 </p><p><span style="color:#c00000">@</span>AllData =    <span style="color:#3366ff">EXTRACT</span>     LineText     <span style="color:#3366ff">string</span>,
</p><p>                filename <span style="color:#3366ff">string</span>,
</p><p>                extension <span style="color:#3366ff">string</span>
						</p><p>        <span style="color:#3366ff">FROM</span>         <span style="color:#c00000">"/DataLoads/Input/{filename}.{extension}"</span>
						</p><p>        <span style="color:#3366ff">USING</span>         Extractors.Text(delimiter: '<span style="color:#c00000">\n</span>', skipFirstNRows: 1);
</p><p>
 </p><p><span style="color:#c00000">@</span>AllData =  <span style="color:#3366ff">SELECT</span> LineText,filename, extension <span style="color:#3366ff">FROM</span>
							<span style="color:#c00000">@</span>AllData;
</p><p>
 </p><p><span style="color:#c00000">@</span>ReducedData  =
</p><p>            <span style="color:#3366ff">REDUCE</span>         <span style="color:#c00000">@</span>AllData 
</p><p>            <span style="color:#3366ff">ON</span>            filename
</p><p>            <span style="color:#3366ff">PRODUCE</span>        noofcolumns string,filename string
</p><p>            <span style="color:#3366ff">USING</span>         new Extension.Python.Reducer(pyScript:<span style="color:#c00000">@</span>ReduceScript);  
</p><p> 
 </p><p><span style="color:#c00000">@</span>InvalidFiles =         <span style="color:#3366ff">SELECT DISTINCT</span> filename 
</p><p>            <span style="color:#3366ff">FROM</span>         <span style="color:#c00000">@</span>ReducedData 
</p><p>            <span style="color:#3366ff">WHERE</span>         noofcolumns != "0";
</p><p><span style="color:#c00000">@</span>ValidFiles = 
</p><p>            <span style="color:#3366ff">SELECT DISTINCT</span> filename 
</p><p>            <span style="color:#3366ff">FROM</span>
							<span style="color:#c00000">@</span>ReducedData AS a 
</p><p>            <span style="color:#3366ff">LEFT</span>
							<span style="color:#3366ff">ANTISEMIJOIN</span>
							<span style="color:#c00000">@</span>InvalidFiles AS b ON a.filename == b.filename;
</p><p>
 </p><p><span style="color:#3366ff">OUTPUT</span>
							<span style="color:#c00000">@</span>InvalidFiles
</p><p><span style="color:#3366ff">TO</span> "/DataLoads/InvalidFiles.txt"
</p><p><span style="color:#3366ff">USING</span> Outputters.Text();
</p><p>
 </p><p><span style="color:#3366ff">OUTPUT</span>
							<span style="color:#c00000">@</span>ValidFiles
</p><p><span style="color:#3366ff">TO</span> "/DataLoads/ValidFiles.txt"
</p><p><span style="color:#3366ff">USING</span> Outputters.Text();</p></td></tr></tbody></table></div><p>
 </p><p>The EXTRACT Statement loads all files from the relative path "/DataLoads/Input" along with the filename attribute. The entire row is picked up as a single column and the column separator is assumed to be a comma (",").
</p><p>The REDUCER groups the reduction by filename and then invokes the python script with the data frame. The python script calls the validate_row for each row with the row as a string. If the number of columns in the row is &lt;9, the result will be a negative value and the result will be a positive value if the #of columns exceed 9. In essence, the result should be 0. The REDUCER produces the name of the file and the number of columns every row. 
</p><p>The files that do have noofcolumns &lt;&gt; 0 is all routed to an InvalidFile list.
</p><p>Follow the instructions <a href="https://onedrive.live.com/view.aspx?resid=3BDE3286AB2E59F7!451&amp;ithint=file%2cdocx&amp;app=Word&amp;authkey=!AG6W0IqCbfyx6Ow">here</a> to enable Python extension on the ADL-A account</p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Workers never yield</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/sql-server-workers-never-yield</link>
      <pubDate>Wed, 06 May 2009 14:05:00 GMT</pubDate>
      <dc:creator><![CDATA[vijaybk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/2009/05/06/sql-server-workers-never-yield/</guid>
      <description><![CDATA[SQL Server scheduler/worker is dsigned such that they are Cooperative and the scheduler expects that...]]></description>
      <content:encoded><![CDATA[<P>SQL Server scheduler/worker is dsigned such that they are Cooperative and the scheduler expects that the workers yield cooperative. However, the API calls such as External modules, Extended procedures etc. may never yield and as a result the worker will be stuck doing an activity.</P>
<P>Error 17883 is reported if the Worker does not yield over 60 seconds (the trace flag –T1262 can ne used to alter this frequency</P>
<P>When all the schedulers encounter 17883 error or all workers are blocked on a critical resource or all workers are executing long running queiries, SQL Server reports scheduler detect Deadlock conditions with the error number 17884, </P>
<P>for further information on this </P>
<P><A href="http://technet.microsoft.com/en-us/library/cc917684.aspx#_17883" mce_href="http://technet.microsoft.com/en-us/library/cc917684.aspx#_17883">http://technet.microsoft.com/en-us/library/cc917684.aspx#_17883</A></P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Deadlock because of Indexed Views</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/deadlock-because-of-indexed-views</link>
      <pubDate>Fri, 01 May 2009 04:45:00 GMT</pubDate>
      <dc:creator><![CDATA[vijaybk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/2009/05/01/deadlock-because-of-indexed-views/</guid>
      <description><![CDATA[Indexed views can cause deadlock when two or more of the participating tables (in the indexed view)...]]></description>
      <content:encoded><![CDATA[<P>Indexed views can cause deadlock when two or more of the participating tables (in the indexed view) is updated/inserted/deleted from two or more sessions in parallel such that they block each other causing a deadlock scenario.</P>
<P>The deadlock scenario in this case cannot be completely eliminated, however, the impact/cause can be minimized. I have explained with a complete sample scenario</P>
<P>Create a new database and execute the script from the attached file "<STRONG>deadlockschemafiles.sql". </STRONG>This file create two tables, one indexed view and populates data into the tables.</P>
<P><STRONG>Step A) </STRONG>Create a new session (<STRONG>Session 1</STRONG>) and execute</P>
<P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>tran</FONT></FONT></P>
<P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update</FONT></FONT><FONT size=2> invoice </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>set</FONT></FONT><FONT size=2> amount </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>=</FONT></FONT><FONT size=2> amount </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>+</FONT></FONT><FONT size=2> 1 </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>where</FONT></FONT><FONT size=2> invid </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>=</FONT></FONT><FONT size=2> 1</FONT></P>
<P mce_keep="true"><STRONG>Step B) </STRONG>Create&nbsp;another session (<STRONG>Session 2</STRONG>)&nbsp;and execute</P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>tran</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update</FONT></FONT><FONT size=2> customer </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>set</FONT></FONT><FONT size=2> custname </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>=</FONT></FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2>'Customer Change1'</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>where</FONT></FONT><FONT size=2> custid </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>=</FONT></FONT><FONT size=2> 2</FONT></P>
<P><FONT size=2>This statement in Step B will will be blocked and if you look at the execution plan&nbsp;of Update Customer statement&nbsp;&nbsp;(from the attached document <STRONG>QueryPlan.doc </STRONG>Section <STRONG>Query Plan A&nbsp;) </STRONG>you will see a&nbsp;clustered index scan on the invoice table. </FONT></P>
<P>This may mean that for any customer to be updated,&nbsp;no other session should hold <STRONG><EM>exclusive lock</EM></STRONG>&nbsp;on any of the invoice rows at that point of time since a clustered index scan is performed on invoice table.</P>
<P>Now we have just seen a blocking scenario, so when does it result in a deadlock.</P>
<P>Execute this statement from <STRONG>Session 1 (created with Step A)</STRONG></P><FONT color=#008000 size=2><FONT color=#008000 size=2>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff size=2><FONT color=#0000ff size=2>update</FONT></FONT><FONT color=#000000 size=2> invoice </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>set</FONT></FONT><FONT color=#000000 size=2> amount </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>=</FONT></FONT><FONT color=#000000 size=2> amount </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>+</FONT></FONT><FONT color=#000000 size=2> 1 </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>where</FONT></FONT><FONT color=#000000 size=2> invid </FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>=</FONT></FONT><FONT size=2><FONT color=#000000> 2</FONT></FONT></P>
<P><FONT size=2><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This statement will require a <STRONG><EM>shared lock </EM></STRONG>on the customer with <STRONG>CustID = 2 </STRONG>in the customer table. As a result both the sessions block out each other resulting in a deadlock situation with a deadlock error in one of sessions.</FONT></FONT></P>
<P><FONT color=#000000>So how do we minimize such that the customer update does not have to block when any of the sessions hold an exclusive lock or anyother lock&nbsp;incompatible with shared lock. </FONT></P>
<P><FONT color=#000000>&nbsp;</FONT><FONT color=#000000>The answer is to create an Index on custid on so that Clustered Index scan becomes an Index Seek.</FONT></P>
<P><FONT color=#000000>Now execute this statement to create an index on the table Invoice(custid)</FONT></P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CREATE</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>NONCLUSTERED</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>INDEX</FONT></FONT><FONT color=#000000 size=2> [IX_Invoice_CustID] </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ON</FONT></FONT><FONT color=#000000 size=2> [dbo]</FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>.</FONT></FONT><FONT size=2><FONT color=#000000>[Invoice] </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>(</P></FONT></FONT><FONT size=2>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [Custid] </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ASC</P></FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )</FONT></FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ON</FONT></FONT><FONT size=2><FONT color=#000000> [PRIMARY]</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GO</P></FONT></FONT>
<P><FONT size=2><FONT color=#000000></FONT></FONT>&nbsp;</P>
<P><FONT color=#000000>If you now look at the query plan for update<FONT size=2> customer statement the query plan will use Index Seek (<STRONG>Refer the attached document&nbsp;"QueryPlan.doc" Section Query Plan B</STRONG>)<STRONG>. </STRONG>Now atleast you will not see a deadlock when different customers are updated from one session and not related invoices are updated in another session</FONT></FONT></P>
<P><FONT color=#000000>Now try all the steps mentioned above. It should work fine as long as you don't update the same customer (from&nbsp;one session)&nbsp;use the invoice (from another session)</FONT></P>
<P><SPAN style="COLOR: #984806; mso-themecolor: accent6; mso-themeshade: 128"><FONT size=3><FONT face=Calibri>The attached zip file has two files in them<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></SPAN></P>
<P></FONT></FONT><FONT size=2><SPAN style="mso-no-proof: yes"></SPAN>&nbsp;</P></FONT>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/58/21/25/Deadlock.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-58-21-25/Deadlock.zip">Deadlock.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Features supported by Editions of SQL Server 2005/2008</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/features-supported-by-editions-of-sql-server-20052008</link>
      <pubDate>Wed, 29 Apr 2009 13:48:00 GMT</pubDate>
      <dc:creator><![CDATA[vijaybk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/2009/04/29/features-supported-by-editions-of-sql-server-20052008/</guid>
      <description><![CDATA[Refer the link for SQL Server 2005 features supported by each of the...]]></description>
      <content:encoded><![CDATA[<P>Refer the link for SQL Server 2005 features supported by each of the edtiion</P>
<P>&nbsp;<A href="http://www.microsoft.com/Sqlserver/2005/en/us/compare-features.aspx">http://www.microsoft.com/Sqlserver/2005/en/us/compare-features.aspx</A></P>
<P mce_keep="true">&nbsp;</P>
<P>For SQL Server 2008 features supported by each of the edtiion</P>
<P><A href="http://msdn.microsoft.com/en-us/library/cc645993.aspx">http://msdn.microsoft.com/en-us/library/cc645993.aspx</A></P>]]></content:encoded>
    </item>
    <item>
      <title>Query fn_dblog() for the list of Operation in active transaction of the current session</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/query-fn_dblog-for-the-list-of-operation-in-active-transaction-of-the-current-session</link>
      <pubDate>Wed, 29 Apr 2009 12:23:00 GMT</pubDate>
      <dc:creator><![CDATA[vijaybk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/2009/04/29/query-fn_dblog-for-the-list-of-operation-in-active-transaction-of-the-current-session/</guid>
      <description><![CDATA[declare @xactid bigint
declare @transactionid nvarchar(28)
select @xactid = transaction_id from...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">declare</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> @xactid <SPAN style="COLOR: blue">bigint<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">declare</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> @transactionid <SPAN style="COLOR: blue">nvarchar</SPAN><SPAN style="COLOR: gray">(</SPAN>28<SPAN style="COLOR: gray">)<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">select</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> @xactid <SPAN style="COLOR: gray">=</SPAN> transaction_id <SPAN style="COLOR: blue">from</SPAN> <SPAN style="COLOR: green">sys</SPAN><SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: green">dm_tran_current_transaction<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">select</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> @transactionid <SPAN style="COLOR: gray">=</SPAN> [transaction id] <SPAN style="COLOR: blue">from</SPAN> <SPAN style="COLOR: green">fn_dblog</SPAN><SPAN style="COLOR: gray">(null,null)</SPAN> <SPAN style="COLOR: blue">where</SPAN> [Xact ID] <SPAN style="COLOR: gray">=</SPAN> @xactid<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">select</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> <SPAN style="COLOR: gray">*</SPAN> <SPAN style="COLOR: blue">from</SPAN> <SPAN style="COLOR: green">fn_dblog</SPAN><SPAN style="COLOR: gray">(null,null)</SPAN> <SPAN style="COLOR: blue">where</SPAN> [Transaction ID] <SPAN style="COLOR: gray">=</SPAN> @transactionid</SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">The [Xact ID] introduced in SQL Server 2008 has the transaction id for the operation LOP_BEGIN_XACT and all the transaction occuring in its context share the common transaction with the [transaction id] column</SPAN></P>]]></content:encoded>
    </item>
    <item>
      <title>DMV to observe wait count and wait time on Indexes</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/dmv-to-observe-wait-count-and-wait-time-on-indexes</link>
      <pubDate>Wed, 11 Feb 2009 22:08:00 GMT</pubDate>
      <dc:creator><![CDATA[vijaybk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/2009/02/11/dmv-to-observe-wait-count-and-wait-time-on-indexes/</guid>
      <description><![CDATA[select&nbsp; database_id
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080 face="Courier New">select<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>database_id</FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,object_id</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,index_id</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,partition_number</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,leaf_insert_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,leaf_delete_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,leaf_update_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,leaf_ghost_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,nonleaf_insert_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,nonleaf_delete_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,nonleaf_update_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,leaf_allocation_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,nonleaf_allocation_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,leaf_page_merge_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,nonleaf_page_merge_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,range_scan_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,singleton_lookup_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,forwarded_fetch_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,lob_fetch_in_pages</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,lob_fetch_in_bytes</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,lob_orphan_create_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,lob_orphan_insert_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,row_overflow_fetch_in_pages</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,row_overflow_fetch_in_bytes</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,column_value_push_off_row_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,column_value_pull_in_row_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,row_lock_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,row_lock_wait_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,row_lock_wait_in_ms</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_lock_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_lock_wait_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_lock_wait_in_ms</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,index_lock_promotion_attempt_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,index_lock_promotion_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_latch_wait_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_latch_wait_in_ms</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_io_latch_wait_count</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,page_io_latch_wait_in_ms</FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>,@now </FONT></FONT></P>
<P style="MARGIN: 0in 0in 3pt" class=Code><FONT color=#000080 face="Courier New">from sys.dm_db_index_operational_stats(@dbid,@objid,@indid,@partitionid)</FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>List all the statements in the Plan Cache along with the counts and CPU usage</title>
      <link>https://docs.microsoft.com/archive/blogs/vijaybk/list-all-the-statements-in-the-plan-cache-along-with-the-counts-and-cpu-usage</link>
      <pubDate>Mon, 12 Jan 2009 09:03:00 GMT</pubDate>
      <dc:creator><![CDATA[vijaybk]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijaybk/2009/01/12/list-all-the-statements-in-the-plan-cache-along-with-the-counts-and-cpu-usage/</guid>
      <description><![CDATA[SELECT t.[text] AS [Adhoc Batch or Object Call],
SUBSTRING(t.[text],...]]></description>
      <content:encoded><![CDATA[<FONT color=#0000ff size=2>
<P>SELECT</FONT><FONT size=2> t</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[text] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Adhoc Batch or Object Call]</FONT><FONT color=#808080 size=2>,</P></FONT><FONT size=2>
<P></FONT><FONT color=#ff00ff size=2>SUBSTRING</FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>t</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[text]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[statement_start_offset]</FONT><FONT color=#808080 size=2>/</FONT><FONT size=2>2</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>+</FONT><FONT size=2> 1</FONT><FONT color=#808080 size=2>,</P></FONT><FONT size=2>
<P></FONT><FONT color=#808080 size=2>((</FONT><FONT color=#0000ff size=2>CASE</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[statement_end_offset]</P>
<P></FONT><FONT color=#0000ff size=2>WHEN</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>-</FONT><FONT size=2>1 </FONT><FONT color=#0000ff size=2>THEN</FONT><FONT size=2> </FONT><FONT color=#ff00ff size=2>DATALENGTH</FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>t</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[text]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>ELSE</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[statement_end_offset] </FONT><FONT color=#0000ff size=2>END</P></FONT><FONT size=2>
<P></FONT><FONT color=#808080 size=2>-</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[statement_start_offset]</FONT><FONT color=#808080 size=2>)/</FONT><FONT size=2>2</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>+</FONT><FONT size=2> 1</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Executed Statement]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Counts]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_worker_time] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Total Worker Time]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_worker_time] </FONT><FONT color=#808080 size=2>/</FONT><FONT size=2> </P>
<P>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Avg Worker Time]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_physical_reads] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Total Physical Reads]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </P></FONT><FONT color=#808080 size=2>
<P>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_physical_reads] </FONT><FONT color=#808080 size=2>/</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Avg Physical Reads]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_logical_writes] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Total Logical Writes]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </P></FONT><FONT color=#808080 size=2>
<P>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_logical_writes] </FONT><FONT color=#808080 size=2>/</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Avg Logical Writes]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_logical_reads] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Total Logical Reads]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </P></FONT><FONT color=#808080 size=2>
<P>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_logical_reads] </FONT><FONT color=#808080 size=2>/</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Avg Logical Reads]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_clr_time] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Total CLR Time]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_clr_time] </FONT><FONT color=#808080 size=2>/</FONT><FONT size=2> </P>
<P>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Avg CLR Time]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_elapsed_time] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Total Elapsed Time]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[total_elapsed_time] </P></FONT><FONT color=#808080 size=2>
<P>/</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[execution_count]</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Avg Elapsed Time]</P>
<P></FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[last_execution_time] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> [Last Exec Time]</FONT><FONT color=#808080 size=2>,</FONT><FONT size=2> qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>[creation_time] </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> </P>
<P>[Creation Time]</P></FONT><FONT color=#0000ff size=2>
<P>FROM</FONT><FONT size=2> </FONT><FONT color=#008000 size=2>sys.dm_exec_query_stats</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> qs</P>
<P></FONT><FONT color=#808080 size=2>CROSS</FONT><FONT size=2> </FONT><FONT color=#808080 size=2>APPLY</FONT><FONT size=2> sys.dm_exec_sql_text</FONT><FONT color=#808080 size=2>(</FONT><FONT size=2>qs</FONT><FONT color=#808080 size=2>.</FONT><FONT size=2>sql_handle</FONT><FONT color=#808080 size=2>)</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>AS</FONT><FONT size=2> t</P></FONT><FONT color=#008000 size=2>
<P>-- ORDER BY [Total Worker Time] DESC</P>
<P>-- ORDER BY [Total Physical Reads] DESC</P>
<P>-- ORDER BY [Total Logical Writes] DESC</P>
<P>-- ORDER BY [Total Logical Reads] DESC</P>
<P>-- ORDER BY [Total CLR Time] DESC</P>
<P>-- ORDER BY [Total Elapsed Time] DESC</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2>ORDER</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>BY</FONT><FONT size=2> [Counts] </FONT><FONT color=#0000ff size=2>DESC</P></FONT>]]></content:encoded>
    </item>
  </channel>
</rss>