Syntax error

  • What am I doing wrong here?

    I'm executing this:

    execute ('select * From fn_my_permissions(NULL, 'database')') AS USER = 'firstuser'

    and am receiving this error:

    Msg 102, Level 15, State 1, Line 1

    Incorrect syntax near 'SERVER'.

    Thanks for any hlep!

  • You have add two single quotes within a string in order to read it as a part of the string. For e.g.

    EXECUTE ('select * From fn_my_permissions(NULL, ''database'')') AS USER = 'firstuser'

    --Ramesh


  • thanks ramesh

    another question:

    when i execute:

    execute ('select * From fn_my_permissions(NULL, ''SERVER'')') AS USER = 'firstuser'

    REVERT

    i get no rows returned; however, when i execute:

    EXECUTE AS LOGIN = 'firstuser'

    GO

    SELECT *

    FROM fn_my_permissions(NULL, 'SERVER');

    REVERT;

    GO

    i get back rows. What's the difference between the two statements?????

  • I got it... one has LOGIN, the other USER.

    thanks

Viewing 4 posts - 1 through 3 (of 3 total)

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