Centralized Logon Accounting (whoson)
WhosOn SQL - Index
This project contains a bundle of SQL script for different SQL RDBMS, currently MSSQL 2008 R2 and MySQL 5.1.x
The script for MSSQL creates both the table and stored procedures. Theres also scripts for database maintenance.
Theres usually a README file in each sub directory explaining how to apply the script to the database engine in question.