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 8230749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:14:15+00:00 2026-06-07T17:14:15+00:00

So I have a website for internal use which tracks a bunch of stats

  • 0

So I have a website for internal use which tracks a bunch of stats for employees. One of these is whether they are missing any reports. Since the list of items that don’t have reports yet only gets updated every couple days, and there is a 3 day grace period on these reports, I am comparing the Date (releaseDt) that the item was logged as missing a report to the last time the database was updated (@lastupdate). This way, if the reports database hasn’t updated but the report is complete, the website isn’t ratting someone out for missing a report.

The SQL code works fine with admin level privledges, but for obvious reasons I’m not letting the ASP.NET account have server admin level.

I have set up a SQL account that the ASP.NET C# code uses to log in, and the permissions for everything else are fine. (Read access only for the specific databases it uses.) I can’t figure out what to give it access to in order to have access to read this specific dynamic management view.

Would appreciate suggestions using either Management Studio, or using a GRANT SQL statement.

This appears to have related information on the view in question:

sys.dm_db_index_usage_stats (Transact-SQL)

DECLARE @lastupdate datetime
     SELECT @lastupdate = last_user_update from sys.dm_db_index_usage_stats
     WHERE OBJECT_ID = OBJECT_ID('MissingReport')

SELECT 
    COALESCE(Creator, 'Total') AS 'Creator',
    COUNT(*) AS Number, 
    '$' + CONVERT(varchar(32), SUM(Cost), 1) AS 'Cost' 
    FROM MissingReport 
    WHERE NOT( 
        [bunch of conditions that make something exempt from needing a report]
        OR
        (
            DATEDIFF(day,ReleaseDt,@lastupdate) <= 3
        )
    )
    GROUP BY Creator WITH ROLLUP
  • 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-06-07T17:14:16+00:00Added an answer on June 7, 2026 at 5:14 pm

    You can’t grant SELECT on DMVs, since this is prevented by policy for server-scoped DMVs:

    GRANT SELECT ON sys.dm_db_index_usage_stats TO peon;
    

    Results in:

    Msg 4629, Level 16, State 10, Line 1
    Permissions on server scoped catalog views or system stored procedures or extended stored procedures can be granted only when the current database is master.

    The BOL page you referenced tells you that you need to grant VIEW SERVER STATE. You would apply this to the login from master:

    USE master;
    GO
    GRANT VIEW SERVER STATE TO peon;
    -- if it's a Windows login then:
    GRANT VIEW SERVER STATE TO [Domain\peon];
    

    But there isn’t a way to do this per database. Not that you should be all that concerned, since even if someone could figure out how to hack into your server with the ASP.NET account credentials, all they can do is see server state, they can’t change anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an jQuery accordion for a form on an internal company website. They
I have a internal website hosted on IIS. I added the following meta code
We have a large internal data collection website. I don't have time to create
I have a login-protected website. It's an internal application and it's not avaiable to
I have website, usually all looks fine but sometimes one div is on the
I have website on the server, which is not precompiled (with source code, so
i have website of application which sells applications online.on the home page i want
I have an internal website that is using integrated windows authentication and this website
I want to have a feature for my website which can print the page
I would need to have two different projects, let's say internal and external, which

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.