If your server supports the INFORMATION_SCHEMA views, those would be my first suggestion. They are database engine agnostic, and implemented by almost all of the major vendors.
If it doesn't, can you tell us which engine you are using (Db2, MS-SQL, MySQL, Oracle, etc) so we can concoct the appropriate engine specific SQL for you?
-PatP