Orphaned Datafiles ?

Occasionally, in my hunt for space I find a datafile with a name unrelated to any current installed database. This query lists datafiles and the database’s they belong to …

SELECT DB_NAME(database_id) DBName,
	   [name] Logical_Name,
       Physical_Name, 
       CONVERT(FLOAT, size) * 8 / 1000000 SizeGB
FROM master.sys.master_files
-- WHERE DB_NAME(database_id) like 'Man%'
WHERE physical_name LIKE 'c%' -- on the c-drive!
-- ORDER BY database_id
ORDER BY size DESC;

What port is SQL 2005 using?

Well, to connect using SSMS you specify the server name / the instance then a comma and port (if its not standard)
EG: “lon101dds ,5001”

If you dont know the port …
– remote onto server
– start / programs / sql 2005 / configuration tools / configuration manager /
– find the instance under network config
– look in tcp/ip settings
– within the ip addresses tab
– scroll to the bottom “IP All”
– read tcp port

Scripted Notification

Here’s an interesting (ActiveX) SQL Job-Step. It can be used to send an email should the usual methods not be available.

Function Main()
	Main = DTSTaskExecResult_Success

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "sendingemail@address.com"
objEmail.To = "receivingemail@address.com"
objEmail.Subject = "FAILED JOB: name SERVER: name"
objEmail.Textbody = "FAILED JOB: name SERVER: name"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "123.123.123.123"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
set objEmail = nothing
End Function

Where the ip-address (123.123.123.123) is the local email server.