How can I get the SQL Server server and instance name of the current connection, using a T-SQL script?
SELECT @@servername will give you data as server/instanceName
SELECT @@servername
server/instanceName
To get only the instanceName you should run select @@ServiceName query .
instanceName
select @@ServiceName