-- To find all database names;
select name from sys.databases;
-- To find all table names under a database
use DBName;
go
select name from sys.tables;
-- To get column name, data type and length of a table
SELECT
c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length'
FROM
sys.columns c
INNER JOIN
sys.types t ON c.system_type_id = t.system_type_id
WHERE
c.object_id = OBJECT_ID('UserInfo')