September 2004 - Posts

2005 Australian Blogging Conference

SplaTT and Cameron Reilly talk about a 2005 Australian Blogging Conference. They're taking expressions of interest at http://www.splatt.com.au/blog/archives/aus_blogging_conference/index.html. Sounds great (although I hope it's in Melbourne).

 

Sample Financial Reports for Reporting Services

Mike Gunderloy points to “SQL Server 2000 Report Pack for Financial Reporting” sample reports from Microsoft.

I found that the installer crashed on my W2K Server box with a cryptic error message, but ran OK on my XP Pro desktop (where are the error logs for these things?)

I do have one gripe, while trying not to look the gift horse straight down the throat, that why is an installer required to deliver the RDL and MDB files? I reckon that maybe a copy of the database with instructions to attach it and the Visual Studio solution file and report files would be enough, because now there's an extra entry in my “Add or Remove Programs“, that is not a program (on the plus side, the installer does not put a link in my “All Programs“ start menu folder, like some of the other samples I've downloaded in the past).

However, I can see the advantage to having an installer for access to powerful scripting and system requirements stuff.

Maybe my next task should be to find a way to examine and extract the contents of MSI packages...or maybe to shut up and be grateful for the sample reports...grumble grumble grumble...

Flexwiki now on SourceForge

I was all ready to link to David Ornstein, one of the writers of FlexWiki, which is a wiki written in C#, as he links to an Associated Press article describing the benefits of wikis. Then that article got superseded by David's news that FlexWiki is on SourceForge!

I use FlexWiki here at work for documentation purposes and for my daily ToDo list (which keeps getting bigger and bigger). FlexWiki is great as it requires little setup (no SQL Server database), the user interface is customisable via stylesheets, and it just works (enough for even my manager to like what he sees). I had the chance to delve into the source code once when I wanted to get rid of the “log off” option (we're on an intranet), and I can say that getting the source was pretty hard from GotDotNet (I think I eventually resorted to downloading an old ZIP file from the FlexWiki site itself). Now I'm afraid to update, because my “enhancement“ will be lost to the ether.

So I'm excited that FlexWiki is now on SourceForge because that sort of upgrades it in my book to a “real” project, and means that it'll keep getting improved even if the talents of David, Tommy Williams, Chris Anderson, or the other numerous guys (who are just names to me, I don't know 'em) don't have time to make improvements. And maybe even my little hack will make it into the source!

Well done to date, FlexWiki guys, and I look forward to a stronger FlexWiki emerging from SourceForge.

September Melbourne SQL Server SIG - "Introduction to CLR integration in SQL Server 2005"

Last week's SQL Server SIG at Microsoft was on CLR and Yukon, and was presented by Greg Low. I've seen Greg a while back presenting on “smart clients“ and he was good then. He hasn't lost his touch - Greg did a great job of mixing concepts and code (just enough code to digest at one time) on some of the new cool things that can be done with Yukon and VB.NET (or any other CLR language).

The session was absolutely packed full of people. I had tried to register online during the day of the presentation only to be informed that the session was booked out. No matter, I went along anyway and told them that I'd eat just one or two pieces of pizza, and stand up near the door so if there was a fire or something that I could get out quickly and not present a hazard.

Greg adapted stuff from an MSDN article which he says had examples in C#, thus his choice of VB.NET for balance (when I find the URL I'll post it). Personally, I could follow along better with the VB.NET code (not that there's a lot of difference between it and C#). Tim Sneath also has a tutorial on the subject at http://blogs.msdn.com/tims/archive/2004/01/26/63057.aspx.

Some of the things that stood out for me were:

  • T-SQL is not dead - CLR has advantages like string concatenation, regex's, access to base classes of the framework, but Greg mentioned that your CLR code gets broken down to T-SQL eventually (this seemingly small point raised a lot of questions from the audience, like “Can we see the T-SQL that gets generated?“).
  • CREATE ASSEMBLY/DROP ASSEMBLY - fine grained permissions can be given, and code access security can be defined even at a function level. Assemblies are added to a database.
  • No intellisense in SQL Server Studio (e.g. Query Analyzer) when programming against assemblies. This means that if you have a library-type assembly loaded, you can't find out what functions/exports it exposes without a tool like Reflector. This is bad.
  • User-defined types - which must be classes or structures, and must implement certain interfaces. These were very cool. Greg demo'ed a Rectangle class, and showed how the content of the class was indexable (wow!) and could be accessed like <TABLE NAME>.<COLUMN NAME>.<CLASS PROPERTY>
  • User-defined aggregate functions - don't like the aggregate functions (SUM, MAX, MIN, etc.)? Create your own! This feature was pretty amazing, to demonstrate it Greg showed us how to create a comma-separated string as an aggregate function.
  • Assembly functions must be shared (in VB) or static(in C#). Special attributes determine whether functions can be called and how they can read data.
  • Assembly exports must be wrapped in a T-SQL function or trigger to use them in SQL queries or table columns. They then attract all the limitations a function has, although you can return tables from functions.

Of course I haven't tested any of this stuff out yet, but as mentioned it does look very cool. Overall a great session, and I'm looking forward to next month.

MS Research User Interface Prototypes

Via ActiveWin, comes Microsoft Research UI Prototypes. Some really interesting stuff, most mocked-up to be semi-functional in a browser, while others are just images. Cool.

SQL Health and History Tool, plus Reporting Services Reports to go with them

Darrell Norton points out a tool to monitor SQL Server 2000, plus Reporting Services reports to view the data collected. I was aware of the Health and History tool before, but having these reports makes it more attractive.

It's good to see reports designed for Reporting Services to cope with “enterprise” needs - I was fossicking around the Superior Software for Windows site the other day and noticed that they'd developed Reporting Services reports for Exchange. Also, the Reporting Services CD comes with reports to monitor usage of Reporting Services itself.

Write up of "What's New In DTS 2005"

AjarnMark does a nice write up of "What's New In DTS 2005". I use DTS (Data Transformation Services, part of SQL Server) fairly frequently and love trying to find ways to encapsulate logic in a package, but wish it wasn't so hard!

Beware of sp_OACreate

I reckon Data Transformation Services in SQL Server 2000 are a good thing, and have used them to import and process text files into my databases. With a bit of mucking around you can do almost anything with DTS, like checking for file existence and setting the target database, among other things. You can even execute a DTS package from a stored procedure, which is perfect for calling from a custom user interface, setting global variables and doing extra processing.

A rough example:

DECLARE @rc INT, --return value from "exec" calls 
        @pkg INT --pointer to package ('object token')

--create an instance of the DTS package
EXEC @rc = sp_OACreate 'DTS.Package', @pkg output
--test return value (this should happen after every sp_OA* call)
IF @rc <> 0 BEGIN
    --error handling
END

--get the DTS package by name
EXEC @rc = sp_OAMethod  @pkg, 'LoadFromSQLServer', NULL, @ServerName = @@SERVERNAME, 
    @Flags = 256, --NT authentication
    @PackageName = "<PACKAGE NAME>"

--set properties of the package
EXEC @rc = sp_OASetProperty @pkg, 'GlobalVariables ("<GLOBAL VARIABLE NAME>").Value', <GLOBAL VARIABLE VALUE>

--also set the "fail on error" property to True
EXEC @rc = sp_OASetProperty @pkg, 'FailOnError', -1

--execute the package
EXEC @rc = sp_OAMethod @pkg, 'Execute', NULL

--kill our local instance of the package
EXEC sp_OADestroy @pkg

The major (and I mean major) drawback to this approach is that the sp_OA* extended stored procedure calls can only be executed by members of the sysadmin fixed role. Not something I want to give to my end users!

I only discovered this after developing a system for a whole year and then deploying on a live server. There does not appear to be a workaround - I've read that granting EXECUTE permission on the extended stored procedures in question might be enough, but this means that a user can create any object and run it...a Very Bad Thing.

Today I started changing my import plumbing to use a VB.NET class to execute the DTS package, ala http://support.microsoft.com/?kbid=321525 and http://www.sqldts.com/default.aspx?265 and it looks like one of the drawbacks is that I'm going to have to work out which DLL's need to be deployed on the user's PC (http://www.winnetmag.com/SQLServer/Article/ArticleID/7444/7444.html gives some help).

I've learned two lessons from this (and I know there's more to come): know your deployment environments (both back-end and front-end), and beware of sp_OACreate.

UPDATE: Two days of work and my two DTS packages are up and running using VB.NET. One key difference is that using VB.NET to call the DTS COM DLL means that the package runs on the local machine, not the server. The initial hurdle of required files to distribute when the end-user does not have Enterprise Manager was solved when I added the required DLL's to my installer, set the COMSelfReg property for particular DLL files and re-installed on the client machine.

I also took the time to make some improvements to my packages - previously I had done some processing using a stored proc, then imported the file using DTS, then done some more processing using a stored proc; now I have rolled that all into the one DTS job, which seems much neater. One further improvement of using VB.NET with a package event handler is that progress events can be displayed to the user (like the Enterprise Manager interface).

I feel like this new approach has some downsides. Using DTS to call a stored procedure and passing both input & output parameters is very unintuitive (see http://www.sqldts.com/?234 for a workaround). And, setting the value of “string” Global Variables from VB.NET is terrible, the workaround is to remove the Global Variable and re-add it (see http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=Z73MR1URCHA.2644%40cpmsftngxa06&rnum=1&prev=/groups%3Fq%3DConclusions%2BIn%2Border%2Bto%2Bchange%2Bthe%2Bvalue%2Bof%2Ba%2BDTS%2BGlobal%2BVariable%2Bof%2Btype%2BString%2Bfrom%2BVB.Net%2Bcode%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3DZ73MR1URCHA.2644%2540cpmsftngxa06%26rnum%3D1 for complete information).

Apart from this I'm happy that it only took two days to keep my import routine working, and remove reliance on sp_OACreate.