如何在T-SQL中获取主机名?

时间:2022-02-02 01:43:24

I need to save my client's name in related database on SQL Server, and i don't want received it by parameter even i want to insert from stored-procedure.

我需要在SQL Server上的相关数据库中保存我的客户端名称,即使我想从存储过程中插入,我也不希望通过参数接收它。

2 个解决方案

#1


2  

Another good approach would be using sp_who2 system procedure like below. Checkout for the login, hostname, dbname and command column.

另一个好的方法是使用sp_who2系统过程,如下所示。检查登录名、主机名、dbname和命令列。

exec sp_who2

#2


3  

my problem was solved by using below code in stored-procedure.

我的问题通过在存储过程中使用下面的代码得到了解决。

SELECT HOST_NAME()

#1


2  

Another good approach would be using sp_who2 system procedure like below. Checkout for the login, hostname, dbname and command column.

另一个好的方法是使用sp_who2系统过程,如下所示。检查登录名、主机名、dbname和命令列。

exec sp_who2

#2


3  

my problem was solved by using below code in stored-procedure.

我的问题通过在存储过程中使用下面的代码得到了解决。

SELECT HOST_NAME()