Pregunta

(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?

¿Fue útil?

Solución

Have you tried using:

SELECT SUSER_NAME()

Otros consejos

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top