Aug 202010

I had an XSLT style sheet that used a C# method to return a multi line string.  I wanted it to include the HTML <BR></BR> tag ad specific places within the string but not as literals.  After some searching around I found that instead of trying to get the <BR></BR> tag to not be literal, story I could simply use the <pre></pre> tag within my HTML and it would force it to recognize the “/r/n” returned from the C# method.

Aug 202010

I needed to find the total purchase order amount given the quantity and line item price on an X12 850 using XSLT and .NET to transform XML into HTML.

In my case:

PO102 = Quantity

PO104 = Price

Add the following to the stylesheet declaration:


for example:

<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:ns0="" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="" exclude-result-prefixes="msxsl var userCSharp" xmlns:userCSharp=">">

In your XSLT use the following code, modifying the referenced node and element within your XML

<xsl:variable name="tmpTotal"> <total_amount> <xsl:for-each select="ns0:PO1Loop1"> <item> <xsl:value-of select="ns0:PO1/PO102 * ns0:PO1/PO104"/> </item> </xsl:for-each> </total_amount> </xsl:variable> <total> <!--<xsl:variable name="myTotal" select="msxsl:node-set($tmpTotal)"/>--> <xsl:variable name="myTotal" select="$tmpTotal"/> <xsl:value-of select="sum(msxsl:node-set($myTotal)/total_amount/item)" /> </total>

Aug 202010

I needed to count all of the rows in an entire database.

I looked around and came up with a pretty easy way to do this.

Create this stored procedure and when you run it, it will display it for you.

create proc AllTableCount AS BEGIN /*Create temp table to populate the row counts for all of the tables*/ CREATE TABLE #TableRowCount( TableName sysname, [RowCount] int) /*Now actually get the counts*/ EXEC sp_MSforeachtable 'INSERT #TableRowCount (TableName,[RowCount]) SELECT ''?'',Count(*) from ?' /*Finally: sum up all of the counts and show it*/ Select SUM([RowCount]) as [Total Number Of Rows From Database] from #TableRowCount END