Thursday, January 01, 2009

Well, I finally have deposited my source code from the Nova CodeCamp presentation on SQL CLR here on my blog.

 

I apologize for taking so long. I needed to update some of the code and strip out any source code control references.

 

SQLCLRUDA.Zip (29.89 KB)

 

My presentation slides can be found in a blog entry below.

1/1/2009 9:53:22 PM (Eastern Standard Time, UTC-05:00) |  | .Net Framework 3.5 | Code Camp | NovaCodeCamp | SQL Server 2005 | SQL Server 2008 | SQLCLR | Visual Studio 2008#

Here is a little commentary that I dispensed at my recent Nova CodeCamp presentation with regards to user defined aggregates written using SQL CLR for the Microsoft SQL Server. SQL 2008 has improved the user defined aggregate feature, but it currently comes at a price. First I discuss the attribute setting to implement the feature, then I provide necessary information on how to deploy it!

 

For those developers building user defined aggregates (UDA) in SQL Server 2008, you now can build an aggregate that exceeds the 8000 byte limitation in SQL Server 2005.

 

To implement this feature, you set the MaxByteSize to -1. This will allow the UDA to grow to a size above 8000 bytes up to 2 GB. An example of the attribute setting is shown below.

 

[Serializable]

[Microsoft.SqlServer.Server.SqlUserDefinedAggregate(

   Format.UserDefined,

   IsInvariantToNulls = true,

   IsInvariantToDuplicates = false,

   IsInvariantToOrder = false,

   MaxByteSize = -1)

        ]

 

Great so far. Now here is where the problem starts. You cannot deploy an assembly with a UDA having this setting from within Visual Studio 2008. You have to deploy the assembly manually.

/*

 * Manually add assembly to database

 */

CREATE ASSEMBLY UDA from 'D:\Development\UDA\bin\UDA.dll'

WITH PERMISSION_SET = SAFE

GO

If you attempt to deploy the UDA with the above attribute, you will get the following message:

 

Error: 'MaxByteSize' property specified was not found.

 

You can find information on MSDN about the MaxByteSize setting here.

 

1/1/2009 9:32:00 PM (Eastern Standard Time, UTC-05:00) |  | SQL Server 2008 | SQLCLR | UDA | Visual Studio 2008#
Tuesday, December 23, 2008

http://www.novacodecamp.org/Nova Code Camp

Here is my presentation from the Nova CodeCamp held on December 6th in Reson, Virginia.

Dec 2008 Nova CodeCamp.pptx (198.08 KB)
12/23/2008 6:56:53 AM (Eastern Standard Time, UTC-05:00) |  | Code Camp | SQL Server 2005 | SQL Server 2008 | SQLCLR#
Saturday, March 15, 2008

Working with Microsoft MVP, Jeff Schoolcraft, we have organized a wonderful developer learning event on Saturday, March 29th at Strayer University in Woodbridge, Va.

CodeCamp SOUTH

Speakers include:

  • Brian Noyes, Microsoft MVP
  • Jonathan Cogley, Microsoft MVP
  • Sahil Malik, Microsoft MVP
  • Frank LaVigne, Microsoft MVP
  • Antonio Chagoury, DotNetNuke Team Lead

and many more.

Topics to be covered include a host of new technologies along with some introductory courses. Here is a sample (you can see the rest at the NovaCodeCamp site).

  • Visual Studio 2008
  • SQL Server 2008
  • SharePoint 2007
  • DotNetNuke Module Development
  • Office 2007 Development
  • Service Oriented Architecture (SOA) Development
  • Ajax
  • Silverlight

For you developers, this is a golden opportunity to see presentations that would typically be presented at high priced conferences like Microsoft TechEd and VSLive. And it is FREE. However, registration is limited to the first 100 that sing up - so make your reservation today!

 

 

 

3/15/2008 12:47:14 PM (Eastern Daylight Time, UTC-04:00) |  | .NET Framework | .NET Framework 2.0 | .Net Framework 3.5 | Ajax | ASP.NET | Code Camp | DotNetNuke | Microsoft MVP | SharePoint 2007 | SQL Server 2005 | SQL Server 2008 | SQLCLR | Visual Studio 2005 | Visual Studio 2008 | WCF#
Thursday, October 18, 2007

OK, I'm a little slow. But, here are the two presentations I made at the Richmond Code Camp two weeks ago. These are in Microsoft Powerpoint.

XQuery for DBAs and Developers (Powerpoint)

Richmond Code Camp XQuery for DBAs and Developers.pptx (980.39 KB)

XQuery SQL Demonstration File (.SQL)

XQuery Presentation.sql (42.59 KB)

Dr. Jekyll and Mr. Hyde; SQLCLR for DBAs and Developers (Powerpoint)

SQLCLR Richmond Code Camp Oct 6.pptx (620.63 KB)

10/18/2007 9:54:40 AM (Eastern Daylight Time, UTC-04:00) |  | .NET Framework 2.0 | Code Camp | SQL Server 2005 | SQLCLR | UDA | XML | XQuery#
Friday, October 05, 2007

Well, I have really done it now. I'm giving two presentations tomorrow at the Richmond CodeCamp. Andy Leonard is putting on another show, and if this one is as good as the last, everyone coming should be in for a real treat.

 

See you all Saturday!

10/5/2007 9:37:21 PM (Eastern Daylight Time, UTC-04:00) |  | Code Camp | SQLCLR | Visual Studio 2005 | XML | XQuery#
Wednesday, April 25, 2007

When working on code developing a SQLCLR stored procedure for my upcoming presentation at the Richmond Code Camp, I ran into this problem with the SqlPipe output.

Here is my code:

<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub procExtractSubjectDetail ()
'Return a string of Subject IDs/XML seperated by a ";"
Try
'Connect to database, notice the context connection
Dim Command As SqlCommand = New SqlCommand
Command.Connection = New SqlConnection("Context connection=true")
Command.Connection.Open()

'Generate the SQL query
Dim strSQL As String = "SELECT ID, Study FROM StudyDetail"

'Attach query to command object
Command.CommandText = strSQL

'Execute command object and get results back in a SQL reader object
Dim reader As SqlDataReader = Command.ExecuteReader()

'Create an efficient stringbuilder to hold the results
Dim Subjects As StringBuilder = New StringBuilder

'Add an emtpy string
Subjects.Append("")

'Collect the results
While reader.Read
'String output size limit is 4kb
'so let us restrict our output for this demo
Subjects.Append(reader.Item(0).ToString() + "/")
Dim sXml As SqlXml = reader.GetSqlXml(1)

Subjects.Append(sXml.Value.ToString)
End While

'Close and release the reader
reader.Close()
reader = Nothing

Dim strResult As String = Subjects.ToString()

'Is it too big?
Dim iSize As Integer = strResult.Length

'Send the results
SqlContext.Pipe.Send(strResult)

Command.Connection.Close()

Catch ex As Exception
'Catch the error and resend it. You could add more error code handling here.
Throw New ApplicationException("An error occurred. " + ex.ToString())
End Try

End Sub

--

This was failing when I ran the code. The issue? SqlContext.Pipe.Send(STRING) only allows a string size of 4k bytes. My output was over 7k.

4/25/2007 1:05:28 PM (Eastern Daylight Time, UTC-04:00) |  | Code Camp | Programming | SQL Server 2005 | XML | XQuery | SQLCLR#
Search
Archive
Links
Categories
Admin Login
Sign In
Blogroll
 CTO 2.0
Antonio Chagoury
Dot NET Ramblings
Brian Noyes
 New Entry
 SharePoint Resources
Lamont Harrington
 Winsmarts
Sahil Malik
Themes
Pick a theme: