Categories
Geeky/Programming SQLServerPedia Syndication

SQL Server: SELECT Machine, Computer, Instance Names

to get the instance name: SELECT @@ServerName

to get the machine name of the server: SELECT SERVERPROPERTY(“MachineName”)

to get the machine name of the computer running the query: SELECT host_name()

one tip: cast the serverproperty as a varchar if you want to use it in a string or you will get errors in your stored procs/queries.

Technorati tags: , , , , , ,

By Steve Novoselac

Director of Digital Technology @TrekBikes, Father, Musician, Cyclist, Homebrewer

3 replies on “SQL Server: SELECT Machine, Computer, Instance Names”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.