Created
August 24, 2018 18:18
-
-
Save mvillegascuellar/122687215d6f1392c435c1b7bdda5f9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- creamos las variables tipo tabla | |
DECLARE @tmp1 TABLE (object_id int, name sysname) | |
DECLARE @tmp2 TABLE (object_id int, column_id int, name sysname) | |
-- insertamos la informacion en las variables tipo tabla | |
insert into @tmp1 | |
select object_id, name | |
from sys.all_objects | |
insert into @tmp2 | |
select object_id, column_id, name | |
from sys.all_columns | |
-- obtenemos los datos | |
SET STATISTICS IO ON | |
select t1.name, count(t2.column_id) | |
from @tmp1 t1 | |
left join @tmp2 t2 | |
on t1.object_id = t2.object_id | |
group by t1.name | |
SET STATISTICS IO OFF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment