question

opcdeep avatar image
opcdeep asked

How to delete a user from command line when username contains spaces

hello there- I need to setup a script but I am not able to delete users using sp_dropuser when username contains a space. Any help would be highly appreciated. example - sp_dropuser [AMR\Business Apps- PSFIN Security Team] Thanks, Deep
sqlsecurityserver
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

K. Brian Kelley avatar image
K. Brian Kelley answered
Wrap the whole command in double quotes: "exec sp_dropuser [AMRBusiness Apps- PSFIN Security Team];" This is the standard way to do this with respect to the command prompt. For instance: cd "\Program Files"
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

opcdeep avatar image opcdeep commented ·
no luck ..when i do that, it says Msg 2812, Level 16, State 62, Line 1 Could not find stored procedure 'EXEC sp_dropuser 'AMR\Business Apps- PSFIN Security Team';'. Thanks, Deep
0 Likes 0 ·
K. Brian Kelley avatar image K. Brian Kelley commented ·
This isn't a command line issue. Drop the EXEC and see if that works for you.
0 Likes 0 ·
opcdeep avatar image opcdeep commented ·
nope. no luck...
0 Likes 0 ·
K. Brian Kelley avatar image K. Brian Kelley commented ·
At this point I can't help you troubleshoot what's going on. But you're getting everything passed in. If you can say what you're using or post a bit of code, we might be able to help more.
0 Likes 0 ·
ThomasRushton avatar image
ThomasRushton answered
Have you tried quoting the parameter: exec sp_dropuser 'AMRBusiness Apps-PSFIN Security Team'; And if that doesn't work, then try square brackets as well: exec sp_dropuser '[AMRBusiness Apps-PSFIN Security Team]';
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.