How to list all user defined functions in MSSQL

To list all user defined functions in MSSQL you can use the following snippet.

Sample MSSQL

SELECT name AS function_name, SCHEMA_NAME(schema_id) AS SCHEMA_NAME ,type_desc FROM sys.objects WHERE type_desc LIKE '%FUNCTION%' ORDER BY name asc;

Please rate this snippet

How to list all installed windows services in C# and VB.NET

To list installed services in C# and VB.NET you can use the following snippet.

Sample C#

public static void ListInstalledServices()
{
	var services = ServiceController.GetServices();
	foreach (var service in services)
	{
		Console.WriteLine(@"Installed: {0}", service.ServiceName);
	}
}

Sample VB.NET

Public Shared Sub ListInstalledServices()
	Dim services = ServiceController.GetServices()
	For Each service As var In services
		Console.WriteLine("Installed: {0}", service.ServiceName)
	Next
End Sub

Please rate this snippet

How to get all culturenames in C# and VB.NET

To get all culturenames in C# and VB.NET you can use the following snippet.

Sample C#

private static void Main(string[] args)
{
	var cultureInformations = GetCultureData();
	foreach (var cultureInformation in cultureInformations)
	{
		Console.WriteLine("Name:{0} ; SpecificName:{1}; FullName:{2}{3}", cultureInformation.Name, cultureInformation.SpecificName, cultureInformation.Fullname, Environment.NewLine);
	}
	Console.Read();
}

public static List<CultureInformation> GetCultureData()
{
	var cultureInformations = (from cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures) let specificName = CultureInfo.CreateSpecificCulture(cultureInfo.Name).Name select new CultureInformation() {Fullname = cultureInfo.EnglishName, Name = cultureInfo.Name, SpecificName = specificName}).ToList();
	return cultureInformations.OrderBy(data => data.Name).ToList();
}

public sealed class CultureInformation
{
	public string Name { get; set; }
	public string SpecificName { get; set; }
	public string Fullname { get; set; }
}

Sample VB.NET

Private Shared Sub Main(args As String())
	Dim cultureInformations = GetCultureData()
	For Each cultureInformation As var In cultureInformations
		Console.WriteLine("Name:{0} ; SpecificName:{1}; FullName:{2}{3}", cultureInformation.Name, cultureInformation.SpecificName, cultureInformation.Fullname, Environment.NewLine)
	Next
	Console.Read()
End Sub

Public Shared Function GetCultureData() As List(Of CultureInformation)
	Dim cultureInformations = (From cultureInfo In CultureInfo.GetCultures(CultureTypes.AllCultures)Let specificName = CultureInfo.CreateSpecificCulture(cultureInfo__1.Name).NameNew CultureInformation() With { _
		Key .Fullname = cultureInfo__1.EnglishName, _
		Key .Name = cultureInfo__1.Name, _
		Key .SpecificName = specificName _
	}).ToList()
	Return cultureInformations.OrderBy(Function(data) data.Name).ToList()
End Function

Public NotInheritable Class CultureInformation
	Public Property Name() As String
		Get
			Return m_Name
		End Get
		Set
			m_Name = Value
		End Set
	End Property
	Private m_Name As String
	Public Property SpecificName() As String
		Get
			Return m_SpecificName
		End Get
		Set
			m_SpecificName = Value
		End Set
	End Property
	Private m_SpecificName As String
	Public Property Fullname() As String
		Get
			Return m_Fullname
		End Get
		Set
			m_Fullname = Value
		End Set
	End Property
	Private m_Fullname As String
End Class

Please rate this snippet

How to get the system drives in C# and VB.NET

To get the system drives in C# and VB.NET you can use the following snippet.

Sample C#

public static DriveInfo[] GetDrives(bool runningDrivesOnly)
{
	return runningDrivesOnly ? Enumerable.Cast<DriveInfo>(DriveInfo.GetDrives()).Where(x => x.IsReady).ToArray() : DriveInfo.GetDrives();
}

Sample VB.NET

Public Shared Function GetDrives(runningDrivesOnly As Boolean) As DriveInfo()
	Return If(runningDrivesOnly, Enumerable.Cast(Of DriveInfo)(DriveInfo.GetDrives()).Where(Function(x) x.IsReady).ToArray(), DriveInfo.GetDrives())
End Function

Please rate this snippet

How to list all columns from a table in MSSQL

To list all columns from a table in MSSQL you can use the following snippet.

Sample MSSQL

SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('TABLENAME') ORDER BY name ASC

If you are using Oracle, take a look at this snippet -> How to get all column names of a Table in Oracle

Please rate this snippet