(I know the question sounds ridiculous, but bear with me ...)

Our DBA changes the 'sa' account name to something else for their own security purposes. There are business needs to use the account name in script (e.g. sp_add_job), but this will break in this situation. I'd like to be able to submit a script that doesn't need to be edited to use the new 'sa' username before running.

Is there a function/property similar to @@SERVERNAME that will return the name of this account?

有帮助吗?

解决方案

Have you tried using:

SELECT SUSER_NAME()

其他提示

There's no function to return the new SA name but since SA is UID = 0x01, it can be retrieved from the logins tables. This will work on SQL 2000 and up.

select name from master..syslogins where sid = 1
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top