sql-server - 是否可以使用存储过程获取 mac 地址?

标签 sql-server stored-procedures

想知道是否可以使用存储过程获取服务器的 mac 地址? 我做了一些搜索,但一无所获。这是使用 SQL2008。

更新
不幸的是,使用 newsequentialid() 的答案可能返回错误 MacAddress 如果服务器上有 VMWare。

最佳答案

有点圆的方法!

declare @t table
(
i uniqueidentifier default newsequentialid(),
m as cast(i as char(36))
)

insert into @t default values;

select
    substring(m,25,2) + '-' + 
    substring(m,27,2) + '-' + 
    substring(m,29,2) + '-' +
    substring(m,31,2) + '-' +
    substring(m,33,2) + '-' +
    substring(m,35,2) AS MacAddress
FROM @t

关于sql-server - 是否可以使用存储过程获取 mac 地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3398428/

相关文章:

c# - 运行修改我的实体的存储过程后,我的 DbContext 会发生什么情况?

stored-procedures - 使用存储过程将缺失的行从一个表复制到sql server中的另一个表

Oracle 存储过程 java.sql.SQLException : Invalid column type: 2012 (REF_CURSOR)

sql-server - SQL 服务器 : How substract rows of one column from rows of another table's column

sql - SQL WHERE 子句中的条件检查

mysql - 如果不为空,则使用 "where"

sql-server - 如何将表传递给存储过程?

java - 在executeQuery 中放入字符串文字是否容易导致JDBC 中的SQL 注入(inject)?

php - Laravel 和 MS SQL Server 数据库连接抛出错误 "(3/3) QueryException could not find driver"

sql-server - SQL Server 2016 奇怪的行为 - OR 条件给出 0 行但 AND 条件给出一些行