Alexander The Great

March 13, 2008

SQL Danger

Filed under: Evolution,Programming,Software — alexanderthegreatest @ 3:53 pm
Tags: , , , , , ,

SQL Server supports a cooperative, non-preemptive threading model in which the threads voluntarily yield execution periodically, or when they are waiting on locks or I/O. The CLR supports a preemptive threading model. If user code running inside SQL Server can directly call the operating system threading primitives, then it does not integrate well into the SQL Server task scheduler and can degrade the scalability of the system. The CLR does not distinguish between virtual and physical memory, but SQL Server directly manages physical memory and is required to use physical memory within a configurable limit.


If you’re scratching your head, thank your lucky stars you don’t need to understand this gibberish. I’ve been having to focus on SQL Server and .NET Integration, also known as SQL CLR integration. A lot of people have made fairly bad choices in the very, very recent past. Just because you can write your stored procedures now in Visual Basic doesn’t mean you should. Obviously it cuts both ways, and that doesn’t mean you shouldn’t – the trouble seems to come when people can’t decide whether they should or not.

Having to help guide that decision, I found the 1st paragraph above, which has some frightening guidance on the matter. It seems to suggest never to use .NET at first glance, but that isn’t really the case. What it really says is long running code that might interfere with SQL’s thread scheduling can be bad. Code that spawns new threads really shouldn’t be hosted in SQL. PInvoke calls can hurt.

But XML processing is an example of something that does none of those things. And while SQL has good XML support, for some operations, .NET is better. Also the set based nature of SQL compared to the procedural and object oriented nature of C# mean you have better control over caching in .NET, so by porting this type of sproc, you can parse an XML document in memory once, instead of once for every time you need to access it.

After all, it’s not SyBase in 1997!


February 2, 2008

Even ASP Ancient Can Do XML With Access

Filed under: Software — alexanderthegreatest @ 9:42 pm
Tags: , , , , , , ,

Access is a baby RDBMS or Relational Database Management System. It runs SQL, stores its data in tables, provides queries (select with projection, DML, even DDL) and has code integration in the sense that VBA (Visual Basic for Applications – embedded, crappy VB Scripting) functions you write can be used in a SQL query.

In all honesty, SQL Server has allowed this forever with UDFs but only recently with the CLR. This is a unique way that Access has lead SQL Server if you simply must write your functions in Visual Basic.

But I digress. The point is that even in absolutely ancient ASP, and with Access the baby brother to SQL Server, you can generate XML. Here’s how.

This is a legacy tip – SQL Server has better support for XML by far, though, without even needing an external language like ASP. And SQL Server is free – Access is not. This defies the conventional wisdom that SQL Server is more expensive than Access (true in web hosting, and true if you buy enterprise versions of SQL Server).

Blog at