Wednesday 12 October 2011

T-SQL to give domain accounts sysadmin access

For those moments where you can only get access via osql.exe....

CREATE LOGIN [Domain\UserName] FROM WINDOWS;
GO


EXEC master..sp_addsrvrolemember [Domain\UserName],'sysadmin'


GO

Why yes. I did just lock myself out of a server accidentally this morning. Where Management Studio wasn't installed. Go figure.

1 comment:

  1. Hello Jane,

    Thank you so much for replying to my comment on Sepha's blog. My husband is still healthy. I am glad to hear everyone is doing well, and I still say a little prayer for Sepha and her family even though I never knew any of them.

    Please take care of yourself!
    Melissa

    ReplyDelete