Useing Role

  • i have made a sql role that for example a role to privant inserting on a spasfic table i had created a serverlogin and a role but i still worke for the perviuse login if any body can help me on that

  • You've explained the situation, but you didn't indicate what you want to do. For instance:

    Do you want to stop the previous login from being used?

    Do you want the application to switch to the new login?

    Do you want the new login to be a member of the role?

    Do you want the role to have the permissions as the previous login?

    K. Brian Kelley
    @kbriankelley

  • You need to answer Brian's questions, but basically if you want to prevent someone from inserting,

    - create a database role

    - DENY insert on the table for the role

    - add a user to the role.

  • i had create a database role

    and DENY insert on the table for the role

    and add a user to the role but when i try to insert it do so how can i use that user i still on the pervious user how can i switch to the new user i had assigned to the role

  • You are not making sense in what you're describing.

    Which user? The way you wrote it doesn't let me know what exactly you are doing. You need to provide more details about what is happening.

  • i have add a database role and then choses and from the securables tab i assigned a spesfic table to deny insert

    then go to user on the same database and add a new user and chose the owned schema to guest and the role member tothe role i had added but now how can i use that user to privent insert on that table(when i opened a quiry and wrote " insert into mytable (colmnes),(values) "it inserted how can i make the user or my role to be active thats my question)

  • Omar halwagy (8/31/2009)


    i have add a database role and then choses and from the securables tab i assigned a spesfic table to deny insert

    then go to user on the same database and add a new user and chose the owned schema to guest and the role member tothe role i had added but now how can i use that user to privent insert on that table(when i opened a quiry and wrote " insert into mytable (colmnes),(values) "it inserted how can i make the user or my role to be active thats my question)

    Still do not understand what you are trying to achieve, if you want to deny insert rights to a table for a user. when you run your insert into that table, are you logged in as that user?.

    --------------------------------------------------------------------------------------
    [highlight]Recommended Articles on How to help us help you and[/highlight]
    [highlight]solve commonly asked questions[/highlight]

    Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
    Managing Transaction Logs by Gail Shaw[/url]
    How to post Performance problems by Gail Shaw[/url]
    Help, my database is corrupt. Now what? by Gail Shaw[/url]

  • thats my question how can i log to a specific user?

  • Perhaps you could modify the code below to test the permissions of your new user.

    Select sUser_sName() -- should give you the name of current user

    Execute as Login='' -- insert your test user here

    INSERT MyTable

    Select Value1, Value 2 --Put your insert statement here

    REVERT -- this takes Query Analyzer back to the original user

    Select sUser_sName() -- Confirm that the original user is now connected

    Elliott:hehe:

  • thanks

  • how can i set user to the defualt user ?

  • I think you're confused.

    You log in as a user, that's the user you use for execution. That's what clients will use.

    If you want to test that user, open another SSMS window and log in as the user you want to test, not your account.

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply