If you've got SQL Server 2000, you need to dig around the docs for Transac-SQL. Otherwise I think you can get the docs for Transac-SQL on MSDN.
Most of it can be done through system stored procedures. Some of it will require SQL-DMO, especially activating SQL Server authentication, which would use the username/password.