views:

22

answers:

2

Trying to run the command:

grant exec on GetPrograms to fp\ouruser_api

When I run it, I get the error message "incorrect syntax near \", but this is the login id stored in our database, how can I grant this user permissions?

Thanks

+3  A: 

grant exec on GetPrograms to [fp\ouruser_api]

G Mastros
A: 

Delimit unusual identifiers with []. Always.

Don't use them in system stored proc calls though:

CREATE USER [fp\ouruser_api] FROM LOGON [fp\ouruser_api];;
GRANT CONNECT TO [fp\ouruser_api];
EXEC sp_addrolemember 'foobar', 'fp\ouruser_api';

Speaking of which, best practice is to create roles and assign permission to the role. Add user to roles. So continuing my example...

grant exec on GetPrograms to foobar;
gbn