How To Find Host Name In Sql Server
I have the exact Query Text and the exact time & date the Query was executed, how can I detect the Host Name that executed this query?
I'm using SQL Server 2008.
Arulkumar
12.5k 13 gold badges 46 silvery badges 65 statuary badges
asked Jun 24, 2016 at 12:33
4
4 Answers iv
Practise you lot need @@SERVERNAME
SELECT @@SERVERNAME
will return the server name where the query was executed.
HOST_NAME
volition return the workstation name
SELECT HOST_NAME()
answered Jun 24, 2016 at 12:45
ArulkumarArulkumar
12.5k 13 gold badges 46 silver badges 65 statuary badges
1
-
this we know for sure, I'thou request about the host name or the figurer name that executed this query
Jun 24, 2016 at 12:53
answered Jun 24, 2016 at fourteen:03
Andriy TolstoyAndriy Tolstoy
5,244 2 aureate badges 28 silver badges 27 bronze badges
4
-
the query that write before gives most likely accurate results
Jun 24, 2016 at 14:57
-
The key point is that
sys.dm_exec_requests
returns data nigh requests that are executing andmaster.dbo.sysprocesses
contains data nigh processes that are running at present.Jun 24, 2016 at fifteen:08
-
tin can the sql server admin know these information or accept them?
Jun 24, 2016 at 16:56
-
I don't think they do unless you accept got a profiler running at that time.
Jun 25, 2016 at 8:30
answered Jun 24, 2016 at xiii:sixteen
Ajay2707Ajay2707
5,595 6 gilt badges 38 silver badges 55 bronze badges
This is as close every bit y'all'll go, I believe:
select host_name()
Every bit is mentioned in the docs: "The client application provides the workstation name and can provide inaccurate data. Do non rely upon HOST_NAME as a security feature."
answered Jun 24, 2016 at 12:54
Tim LehnerTim Lehner
14.2k 4 gold badges 54 silvery badges 73 bronze badges
4
-
this volition requite me my host name, please read the question once again
Jun 24, 2016 at 12:57
-
I'm not asking about my host proper noun, please read the question once more
Jun 24, 2016 at 12:58
-
@ShahimKhlaifat Are you executing the query on the server itself? If y'all're going through a web app, the host_name() will render the web server.
Jun 24, 2016 at xiii:43
-
Starting in SQL Server 2016 Host_Name() will return the name of the workstation. Prior to that I think it returned something less useful.
Apr ix, 2020 at 4:39
Not the reply you lot're looking for? Scan other questions tagged sql sql-server sql-server-2008 or ask your ain question.
How To Find Host Name In Sql Server,
Source: https://stackoverflow.com/questions/38013577/sql-server-query-host-name
Posted by: ashfordtered1955.blogspot.com
When you say Host Name, are you thinking Web Server?
Jun 24, 2016 at 12:forty
Practise you want
SELECT @@SERVERNAME
?Jun 24, 2016 at 12:42
I guess that OP needs host name of the machine from which the query was executed.
Jun 24, 2016 at 12:49
you can use Sql profiler too.
Jun 24, 2016 at xiii:thirteen