Skip to content

Instantly share code, notes, and snippets.

@mvillegascuellar
Created August 24, 2018 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvillegascuellar/122687215d6f1392c435c1b7bdda5f9f to your computer and use it in GitHub Desktop.
Save mvillegascuellar/122687215d6f1392c435c1b7bdda5f9f to your computer and use it in GitHub Desktop.
-- 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