Ashfield wrote:
the OP did specify sql server
Oh, yes, absolutely, and he wanted it to be an SQL statement too, but after finding one way for SQL Server, another way for Oracle, another way for Ingres, and then facing MySQL, Caché, FireBird, Access, etc. I realized I already had a way that works with all of them. I aim for database agnosticism. (I do, however, prefer SQL Server.)