Title / Description
Code DECLARE @i INT DECLARE @q VARCHAR(MAX) SET @i = 1 SET @q = 'With ZoomCounts AS( Select count(*) as ElementCount, ''MGeoZoom' + Cast(@i as VARCHAR) + ''' as ZoomTable, Layer, ' + Cast(@i as VARCHAR) + ' as ZoomNum from MGeoZoom' + Cast(@i as VARCHAR) + ' Group By Layer' SET @i+=1 WHILE @i <=21 BEGIN SET @q += ' Union ALL ' SET @q += 'Select Count(*) as ElementCount, ''MGeoZoom' + Cast(@i as VARCHAR) + ''' as ZoomTable, layer, ' + Cast(@i as VARCHAR) + ' as ZoomNum from MGeoZoom' + Cast(@i as VARCHAR) + ' Group By Layer' SET @i+=1 END SET @q += ') Select Layer, ZoomTable, ElementCount as Record_Count from ZoomCounts Order By Layer, ZoomNum' EXEC(@q)
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code