none
CREATE USER 'FOR LOGIN' VS 'FROM LOGIN' RRS feed

  • Question

  •                 

    SQL SERVER 2012

    For CREATE USER books on line shows FOR and FROM options but I cannot see where it explains the difference. Could someone please enlighten me.

    Thanks

    Examples from BOL:

    CREATE USER [Domain1\WindowsGroupManagers] FOR LOGIN [Domain1\WindowsGroupManagers]

    CREATE USER [Domain1\WindowsGroupManagers] FROM LOGIN [Domain1\WindowsGroupManagers]





    Saturday, November 23, 2013 6:33 PM

Answers

  • I've always user FOR but according to Books Online syntax reference the two words are interchangeable (they mean the same thing use the one which you feel is most cozy).

    Tibor Karaszi, SQL Server MVP | web | blog

    Saturday, November 23, 2013 7:59 PM
  • Yes, both for and from are used in same way, by default we use for but both are optional and can use as per your convince

    Check below link

    http://technet.microsoft.com/en-us/library/ms173463.aspx

    Syntax mentioned link { FOR | FROM }which clearly suggest any one can be used,

    CREATE USER user_name

    [

            { FOR | FROM } LOGIN login_name 
        ]
        [ WITH DEFAULT_SCHEMA = schema_name ] 
    [ ; ]


    Please click the Mark as answer button and vote as helpful if this reply solves your problem

    Sunday, November 24, 2013 6:58 AM

All replies

  • I've always user FOR but according to Books Online syntax reference the two words are interchangeable (they mean the same thing use the one which you feel is most cozy).

    Tibor Karaszi, SQL Server MVP | web | blog

    Saturday, November 23, 2013 7:59 PM
  • Yes, both for and from are used in same way, by default we use for but both are optional and can use as per your convince

    Check below link

    http://technet.microsoft.com/en-us/library/ms173463.aspx

    Syntax mentioned link { FOR | FROM }which clearly suggest any one can be used,

    CREATE USER user_name

    [

            { FOR | FROM } LOGIN login_name 
        ]
        [ WITH DEFAULT_SCHEMA = schema_name ] 
    [ ; ]


    Please click the Mark as answer button and vote as helpful if this reply solves your problem

    Sunday, November 24, 2013 6:58 AM
  • Thank you both.

    I read { FOR | FROM } as exclusive alternatives rather than equivalents. Clearly I need to brush up on my BOL syntax!

    Thanks again.

    Sunday, November 24, 2013 8:36 AM
  • Brendan, I think you're completely right to interpret it as alternatives.  The syntax as expressed is not clear at all.  I think someone at MS messed up.  The whole purpose of the syntax guide is to eliminate ambiguity.
    Monday, June 17, 2019 8:51 PM