如何用sql命令获取ip地址 - MS-SQL Server / 应用实例
如何用sql命令获取当前数据库服务器的ip地址
学习,帮顶
SQL code:
exec master..xp_cmdshell 'ipconfig'
SQL code:
SELECT @@SERVERNAME
SQL code:
create Procedure sp_get_ip_address (
@ip varchar(40) out
)
as
begin
Declare @ipLine varchar(200)
Declare @pos int
set nocount on
set @ip = NULL
Create table #temp (ipLine varchar(200))
Insert #temp exec master..xp_cmdshell 'ipconfig'
select @ipLine = ipLine from #temp where upper (ipLine) like '%IP ADDRESS%'
if (isnull (@ipLine,'***') != '***')
begin
set @pos = CharIndex (':',@ipLine,1);
set @ip = rtrim(ltrim(substring (@ipLine ,@pos + 1 ,len (@ipLine) - @pos)))
end
drop table #temp
set nocount off
end
go
declare @ip varchar(40)
exec sp_get_ip_address @ip out print @ip
SQL code:
create table #tmp(aa varchar(200))
insert #tmp exec xp_cmdshell 'ipconfig'
select s
相关问答:
今天做了一个存储过程 环境是SQL2000数据库
大致如下
建立临时表
定义员工游标
循环员工(属于1个公司)
......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
有TABLEA 字段为 采购单号、行号、物料编码、入库日期
现想按照物料编码查询最大入库日期
语句如下:
SELECT 采购单号、行号、物料编码、入库日期 from TABLEA A WHERE 入库日期=(SELECT MAX(入库日期 ......
有这样一条SQL
Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......