How to list last backup date of all databases in MSSQL

To list last backup date of all databases in MSSQL you can use the following snippet.

Sample MSSQL

SELECT db.name AS [Databasename], 
case when	MAX(bck.backup_finish_date) is NULL then 
				'No Backup' 
			else 
				convert(varchar(100), MAX(bck.backup_finish_date)) 
end AS [DateOfLastBackup]
FROM sys.databases db
LEFT OUTER JOIN msdb.dbo.backupset bck 
	ON db.name = bck.database_name AND bck.type = 'D' WHERE db.database_id NOT IN (2) 
GROUP BY db.name
ORDER BY 2 ASC

How to check if a process is running in C# and VB.NET

To check if a process is running in C# and VB.NET you can use the following snippet.

Sample C#

public static bool IsRunning(string processName)
{
	try
	{
		var retVal = Process.GetProcesses().Any(p => p.ProcessName.Contains(processName));
		return retVal;
	}
	catch (Exception ex)
	{
		//handle the exception your way 
		return false;
	}
}

public static bool IsRunning(this Process process)
{
	try
	{
		var retVal = Process.GetProcesses().Any(p => p.ProcessName.Contains(process.ProcessName));
		return retVal;
	}
	catch (Exception ex)
	{
		//handle the exception your way 
		return false;
	}
}

Sample VB.NET

Public Overloads Shared Function IsRunning(ByVal processName As String) As Boolean
        Try 
            Dim retVal As var = Process.GetProcesses.Any(() => {  }, p.ProcessName.Contains(processName))
            Return retVal
        Catch ex As Exception
            'handle the exception your way 
            Return false
        End Try
    End Function
    
    Public Overloads Shared Function IsRunning(this ByVal process As Process) As Boolean
        Try 
            Dim retVal As var = Process.GetProcesses.Any(() => {  }, p.ProcessName.Contains(process.ProcessName))
            Return retVal
        Catch ex As Exception
            'handle the exception your way 
            Return false
        End Try
    End Function