Wednesday, March 21, 2012

How to use sp_addlogin

Hi all,

I want to add a windows user login which looks like: MachineName\UserName, however back slash "\" is not allowed in ap_addlogin. With UserName only, the privileges are not granted correctly as far as I tested. How can I walk around? Any ideas? I use SQL express.

Br,

XZ

I don't know what documentation comes with SQL Express, but if it is that limited to not cover basic T-SQL like this I'd go get a copy of the full SQL Server Books Online (BOL), free download available. You can also use BOL through the MSDN Library website.

sp_addlogin has only been preserved for backward compatability, try CREATE LOGIN instead-

USE [master]

GO

CREATE LOGIN [XXX\ASPNET] FROM WINDOWS WITH DEFAULT_DATABASE=[master]

GO

USE [AdventureWorks]

GO

CREATE USER [ASPNET] FOR LOGIN [XXX\ASPNET]

GO

You may also like to try a more appropriate forum, perhaps the SQL Security forum. Since SQL Express does not even include SSIS I don't think this is the best one to choose.

|||

Thanks for fast reply I guess it's the most recommended way, however I am still interested in the way of using C# and sp_addlogin.

BR,

Xuan

sql

No comments:

Post a Comment