如何从T-SQL获取当前实例名称 [英] How to get current instance name from T-SQL

查看:149
本文介绍了如何从T-SQL获取当前实例名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用T-SQL脚本获取当前连接的SQL Server服务器和实例名称?

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

推荐答案

只需在

Just found the answer, in this SO question (literally, inside the question, not any answer):

SELECT @@servername

返回服务器名\实例(如果这不是默认实例)

returns servername\instance as far as this is not the default instance

SELECT @@servicename

返回实例名称,即使这是默认名称(MSSQLSERVER)

returns instance name, even if this is the default (MSSQLSERVER)

这篇关于如何从T-SQL获取当前实例名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆