Вопрос

(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