Skip to main content
Solved

Show all tables with contents in a db

  • April 30, 2024
  • 3 replies
  • 202 views

smartman63
Contributor
Forum|alt.badge.img+1

Hi all,

I am trying to show all tables with contents in a database. I have a database with over 800 tables. Some tables are empty, some are not. 

 

Im using this query in a sql client:

SELECT SCHEMA_NAME(t.[schema_id]) AS [table_schema]
          ,OBJECT_NAME(p.[object_id]) AS [table_name]
          ,SUM(p.[rows]) AS [row_count]
    FROM [sys].[partitions] p
    INNER JOIN [sys].[tables] t ON p.[object_id] = t.[object_id]
    WHERE p.[index_id] < 2
    GROUP BY p.[object_id]
        ,t.[schema_id]
    ORDER BY row_count desc

 

 

If i am using a Sql Executor with this sql statement i have a return value of more than 300 tables wich is correct. In the preview of the feature window i see more than 300 lines. But i dont see any attributes like a table name or the number of records.

 

Do you know how i can expose these attributes?

Best answer by redgeographics

The SQLCreator requires you to specifically expose the attributes coming out of it (the Attributes to Expose parameter), so in this case you would need to add table_name and row_count there.

View original
Did this help you find an answer to your question?

3 replies

redgeographics
Celebrity
Forum|alt.badge.img+49
  • Celebrity
  • Best Answer
  • April 30, 2024

The SQLCreator requires you to specifically expose the attributes coming out of it (the Attributes to Expose parameter), so in this case you would need to add table_name and row_count there.


nielsgerrits
VIP
Forum|alt.badge.img+54

Using aliases should do the trick. You probably have to expose table_schema, table_name and row_count in the SQLExecutor, or using an AttributeExposer. If that does not work, I would try to use quotes, not straigh hooks, but I’m not sure.


smartman63
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • April 30, 2024
We're done. The "populate from sql" button doesn't give us any results. The window remains empty. Weird?But manually entering our desired attributes does work.Thank you redgeographics for this insight!

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings