Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7488833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:05:44+00:00 2026-05-29T15:05:44+00:00

I’m trying to make a customized view that gets me the row count for

  • 0

I’m trying to make a customized view that gets me the row count for all the views and tables of a database.

Getting the count of table is damn in SQL Server

SELECT TABLE_SCHEMA,
       TABLE_NAME = TABLES.TABLE_NAME,
       RECORD_COUNT = MAX(SYSINDEXES.ROWS)
FROM   SYS.SYSINDEXES "SYSINDEXES",
       INFORMATION_SCHEMA.TABLES "TABLES"
WHERE  TABLES.TABLE_NAME = OBJECT_NAME(SYSINDEXES.ID)
       AND TABLES.TABLE_TYPE = 'BASE TABLE'
GROUP  BY TABLES.TABLE_SCHEMA,
          TABLES.TABLE_NAME  

Now, I need to get the rowcount for VIEWS

I feel the only way is to count the number of rows from the views
i.e. count(*) from view_name

But, I could not find a way to have the rowcount for view along with view_name, table_schema and so on.

Any advance on this would be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:05:44+00:00Added an answer on May 29, 2026 at 3:05 pm

    Here , is the final solution:

    SET NOCOUNT ON
    DECLARE   @ViewName AS nVarChar(128)
        , @TmpQuery AS nVarChar(500)
        , @Out3 as int
    DECLARE Cur_Views CURSOR FOR
    SELECT schema_name(schema_id)+'.'+name as "Table_Name" FROM [sys].[all_views] 
    OPEN Cur_Views
    FETCH NEXT FROM Cur_Views INTO @ViewName
    WHILE   @@Fetch_Status = 0 BEGIN
    --SELECT  @Query = 'SELECT COUNT(*) AS [Count] FROM ' + @ViewName
    --EXECUTE(@Query)
    CREATE TABLE #Data (var int)
    SELECT  @TmpQuery = 'SELECT COUNT(*) AS [Count] FROM ' + @ViewName
    INSERT #Data exec (@TmpQuery)
    SELECT @Out3 = var from #Data
    --PRINT @ViewName
    --PRINT @Out3
    insert into Person.ViewCountTracker values(@ViewName,@Out3)
    DROP TABLE #Data
    FETCH NEXT FROM Cur_Views INTO @ViewName
    END
    CLOSE Cur_Views
    DEALLOCATE Cur_Views
    GO
    --create table Person.ViewCountTracker
    --(
    --  ViewName varchar(255),
    --  RowValue int
    --)
    --select * from Person.ViewCountTracker
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.