Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping backslash in SQL Server GRANT

GRANT SELECT ON tableName TO something\user_name

Unfortunately, when I execute this in SQL Server 2008 R2 I get an Incorrect syntax near '\'. error.

Is there a way to escape a backslash, or what should I do?

like image 330
hermann Avatar asked May 22 '13 09:05

hermann


People also ask

How do you handle a backslash in SQL query?

When a backslash immediately precedes a new line in a string literal both the backslash and the new line are removed. If you actually require a string literal with a backslash followed by carriage returns you can double them up.

How does grant work in SQL?

Grant in SQL Server SQL Grant is used to provide permissions like Select, All, Execute to user on the database objects like Tables, Views, Databases and other objects in a SQL Server. Here privilageName is the access right or permission that is granted to the user like All, Select, Execute.


1 Answers

GRANT SELECT ON tableName TO [something\user_name]
like image 168
Andomar Avatar answered Oct 05 '22 06:10

Andomar