>Thank you very much, that SP fits my needs perfectly. Hmm just a followup question I should have asked in my original post. Is there a SP I can execute to find out which version of MSSQL is running, and can I from that information find out if it is the "free" version or not?
The first or second one should answer your question if it's MSDE or not.
SELECT
SERVERPROPERTY ('Edition'),
SERVERPROPERTY ('EngineEdition'),
SERVERPROPERTY ('ProductVersion'),
SERVERPROPERTY ('ProductLevel')
--sb--