DataBases:
SELECT NAME FROM SYSDATABASES ORDER BY 1
Tables:
DECLARE @sqlCommand nvarchar(1000)='use ' + @databases+' SELECT name FROM sys.tables order by 1'
EXECUTE sp_executesql @sqlCommand
Columns:
DECLARE @sqlCommand nvarchar(1000)='use ' + @databases+' Select sys.columns.Name from sys.columns Inner Join sys.objects
On sys.objects.object_id = sys.columns.object_id
AND sys.objects.name = '''+@Tables +''''
EXECUTE sp_executesql @sqlCommand