Sample script that lists the roles within a SQL Server database.

Visual Basic
Edit|Remove
strDBServerName = "."
strDBName = "Northwind"

Set objSQLServer = CreateObject("SQLDMO.SQLServer")
objSQLServer.LoginSecure = True
objSQLServer.Connect strDBServerName

Set objDB = objSQLServer.Databases(strDBName)
Set colRoles = objDB.DatabaseRoles
For Each objRole In colRoles
   WScript.Echo "Role Name: "    & objRole.Name
Next