Code to check whether word,excel has been indtalled in system

This is code to check whether microsoft word or microsoft excel has been installed in your system..

import namespace microsoft.win32 'namespace to acess the Registry classes.

Dim RegAppli As RegistryKey
RegAppli = Registry.ClassesRoot.OpenSubKey("excel.application")
'in case of checking word installed,the above code should be RegAppli = 'Registry.ClassesRoot.OpenSubKey("word.application")
If RegAppli Is Nothing Then
MsgBox("Microsoft Excel has not been installed")
Else
MsgBox("Microsoft Excel has been installed")
RegAppli.Close()
End If

Query to show the connection as per user and database

the query to find the users having how how many connections are present in which database.

Code:

SELECT LOGINAME AS 'LOGIN NAME',COUNT(DBID) AS 'NO OF CONNECTIONS EXIST',
DB_NAME(DBID) AS 'DATABASE NAME'
FROM SYS.SYSPROCESSES
WHERE DBID > 0
GROUP BY DBID, LOGINAME

Very Simple Query to Print All the Months

just run the below query to print all the months from January to December(without using loop)
code:

;WITH santosh
AS
(
SELECT 1 AS [Month]
UNION ALL
SELECT [Month] +1 FROM santosh WHERE [Month]<12
)
SELECT [Month] [Month], datename(month,dateadd(month, [Month] - 1, 0)) [Month Name] FROM santosh
GO