Get local server's alias in T-SQL

  • Hello,

    I'm trying to get the server name programmatically.

    Even after I do this:

    exec dbo.sp_dropserver 'FQDN\InstanceName'
    GO
    exec dbo.sp_addserver 'MURPHY', 'local'
    GO

    But @@Servername and SERVERPROPERT('ServerName') both still return FQDN\InstanceName

    In our code, we do stuff like IF <this servername> = "FQDN\InstanceName" ....

    I want to be able to do IF <this servername> = "MURPHY" .... because we're getting brand new equipment and they won't be renaming them to match the old names.

    There's gotta be a a way...surely?

    Thanks!!

     

  • ...and then restart the server. D'oh!!

    Skipped right over that line in BOL

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply