How to get current instance name from T-SQL

后端 未结 8 1017
天命终不由人
天命终不由人 2021-01-30 05:18

How can I get the SQL Server server and instance name of the current connection, using a T-SQL script?

8条回答
  •  一生所求
    2021-01-30 05:30

    To get the list of server and instance that you're connected to:

    select * from Sys.Servers
    

    To get the list of databases that connected server has:

    SELECT * from sys.databases;
    

提交回复
热议问题