In a some later time i am going to publish a CFC with all kind of functions that may help optimizing MSSQL2005 ond your sql scripts.
Ok, ok.. too much talk.
Here is first script:
<cffunction name="getDBInfo" output="No" returntype="any" description="get databases info">
<cfargument name="dbid" default="0" type="any" required="No">
<cfargument name="dbName" default="" type="any" required="No">
<cfset var getDBInfo = "">
<cfquery name="getDBInfo" datasource="yourdsn#" username="youruserName" password="yourpasswd">
Select *, suser_sname(owner_sid)
From sys.databases
<cfif Val(dbid)>
Where database_id = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Val(dbid)#">
<cfelseif Len(Trim(dbName))>
Where name = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#dbName#">
</cfif>
</cfquery>
<cfreturn getDBInfo>
</cffunction>
Example of usage:
<cfdump var="#getDBInfo()#">
<cfdump var="#getDBInfo('someDBName')#">