Grant All User to view Server State

nikeman77nikeman77 Member Posts: 517
edited 2013-02-28 in SQL General
Hi All,

I need to transfer all users from LIVE to another Server.
Export part was done using query: exec sp_help_revlogin which will provide a lists of login id's and password. i copied this to a text file.
CREATE LOGIN [BruceLee] WITH PASSWORD = 0x01002A52EF6D9FBDB5DC11780391626B2DD9E3E2511F46138952 HASHED, SID = 0x0056703E08AE099D999453A4382428AA, CHECK_POLICY = ON, CHECK_EXPIRATION = OFF;


1.When I execute this query of create login it give me error:
Msg 15433, Level 16, State 1, Line 1
Supplied parameter sid is in use.


2. Also how or where can I get a script to grant all users that is created in the above lists to view State?

PS: I am a newbie in SQL

Comments

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    nikeman77 wrote:
    2. Also how or where can I get a script to grant all users that is created in the above lists to view State?
    1.
    USE [master]
    GO
    GRANT VIEW SERVER STATE TO [public]

    2
    If you want go grant VIEW SERVER STATE permission ONLY to the users created by your script (and personally I can't see any good reason why not to grant VIEW SERVER STATE to public role) copy a list of users taken from Windows Login table to some Excel speadsheet and prepare a list of GRANT VIEW SERVER STATE TO [user 1], GRANT VIEW SERVER STATE TO [user 2] and so on statements. Copy and paste it into SSMS and you are done.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • nikeman77nikeman77 Member Posts: 517
    Slawek Guzek,

    thanks for advising, I'll be granting ALL users with GRANT VIEW SERVER STATE.

    is the syntax exactly >> USE [master] GO GRANT VIEW SERVER STATE TO [public]

    by the way, how do I create user based on the users lists (text format) generated ?
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    nikeman77 wrote:
    is the syntax exactly >> USE [master] GO GRANT VIEW SERVER STATE TO [public]
    Why don't you try it yourself ? Is it too hard to copy these 3 lines to SSMS and run them ? Harder than post here ?
    nikeman77 wrote:
    by the way, how do I create user based on the users lists (text format) generated ?
    Create USERs or create LOGIN?

    It is enought if you create SQL Server LOGINs corresponding to users found in Database User and or Windows Login tables. NAV will create users in the database for you when you re-validate entries or synchronize security,

    For LOGINS using database authentication (entries found in Database User table)
    CREATE LOGIN [BruceLee] WITH PASSWORD = 0x01002A52EF6D9FBDB5DC11780391626B2DD9E3E2511F46138952 HASHED
    

    For LOGINS using Windows Authentication (entries found Windows Logins table)
    CREATE LOGIN [domain\BruceLee] FROM FROM WINDOWS
    
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • nikeman77nikeman77 Member Posts: 517
    Why don't you try it yourself ? Is it too hard to copy these 3 lines to SSMS and run them ? Harder than post here ?
    Anyway SSMS says commands execute successfully. BUT when i went in to user account and check server state not granted. ](*,)
    PS: I click on Database Server> Query> Paste the code
    USE [master]
    GO
    GRANT VIEW SERVER STATE TO [public]

    Create USERs or create LOGIN?
    LOGIN
Sign In or Register to comment.