declare @a int
select @a = -1062729436
if @a < 0
begin
select '' + cast(((@a & 0x00000000FF000000) /16777216 + 256) as varchar) + '.' +
cast(((@a & 0x00FF0000) / 65536) as varchar) + '.'
+ cast(((@a & 0x0000FF00) / 256) as varchar) + '.'
+ cast((@a & 0x000000FF) as varchar)
end
else
select '' + cast(((@a & 0xFF000000) /16777216) as varchar) + '.' +
cast(((@a & 0x00FF0000) / 65536) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 256) as varchar) + '.' +
cast((@a & 0x000000FF) as varchar)
CREATE FUNCTION [dbo].[f_Int2IP](
@IP bigint
)RETURNS varchar(15)
AS
BEGIN
DECLARE @re varchar(15)
SET @re=''
SELECT @re=@re+'.'+CAST(@IP/ID as varchar)
,@IP=@IP%ID
from(
SELECT ID=CAST(16777216 as bigint)
UNION ALL SELECT 65536
UNION ALL SELECT 256
UNION ALL SELECT 1)a
RETURN(STUFF(@re,1,1,''))
END
在SYBASE 中如何实现呢 12.5.4版本
10 个解决方案
#1
CREATE FUNCTION [dbo].[f_Int2IP](
@IP bigint
)RETURNS varchar(15)
AS
BEGIN
DECLARE @re varchar(15)
SET @re=''
SELECT @re=@re+'.'+CAST(@IP/ID as varchar)
,@IP=@IP%ID
from(
SELECT ID=CAST(16777216 as bigint)
UNION ALL SELECT 65536
UNION ALL SELECT 256
UNION ALL SELECT 1)a
RETURN(STUFF(@re,1,1,''))
END
这一段?
@IP bigint
)RETURNS varchar(15)
AS
BEGIN
DECLARE @re varchar(15)
SET @re=''
SELECT @re=@re+'.'+CAST(@IP/ID as varchar)
,@IP=@IP%ID
from(
SELECT ID=CAST(16777216 as bigint)
UNION ALL SELECT 65536
UNION ALL SELECT 256
UNION ALL SELECT 1)a
RETURN(STUFF(@re,1,1,''))
END
这一段?
#2
上面的例子都是SQLSERVER的 在 SYBASE中 不行的。
#3
这一段修改一下应该可以吧
#4
不行的 %好像要转换类型 好像SYBASE 也没有函数这个说法
#5
%在SQLSERVER中是求模,在SYBASE中用MOD
MOD( dividend, divisor )
MOD( dividend, divisor )
#6
恩 使用c++写个扩展存储过程吧
#7
我要用BCP 把数据到处来,同时把int类型转换成IP 字符串
mod 函数好像也不行Function 'MOD' not found. If this is a SQLJ function, use sp_help to check whether the object exists (sp_help may produce a large amount of output).
mod 函数好像也不行Function 'MOD' not found. If this is a SQLJ function, use sp_help to check whether the object exists (sp_help may produce a large amount of output).
#8
查了一下,SYBASE 中有%
sybase的求余函数
X % Y
sybase的求余函数
X % Y
#9
已经搞定
declare @a int
select @a = -1062729436
if @a < 0
begin
select '' + cast(((@a & 0x000000FF) /16777216 + 256) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
end
else
select '' + cast(((@a & 0x000000FF) /16777216 ) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
大家可以共享一下,呵呵 ,我很不容易才搞定的哦!!!
declare @a int
select @a = -1062729436
if @a < 0
begin
select '' + cast(((@a & 0x000000FF) /16777216 + 256) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
end
else
select '' + cast(((@a & 0x000000FF) /16777216 ) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
大家可以共享一下,呵呵 ,我很不容易才搞定的哦!!!
#10
与SQLSERVER相差不大,学习
#1
CREATE FUNCTION [dbo].[f_Int2IP](
@IP bigint
)RETURNS varchar(15)
AS
BEGIN
DECLARE @re varchar(15)
SET @re=''
SELECT @re=@re+'.'+CAST(@IP/ID as varchar)
,@IP=@IP%ID
from(
SELECT ID=CAST(16777216 as bigint)
UNION ALL SELECT 65536
UNION ALL SELECT 256
UNION ALL SELECT 1)a
RETURN(STUFF(@re,1,1,''))
END
这一段?
@IP bigint
)RETURNS varchar(15)
AS
BEGIN
DECLARE @re varchar(15)
SET @re=''
SELECT @re=@re+'.'+CAST(@IP/ID as varchar)
,@IP=@IP%ID
from(
SELECT ID=CAST(16777216 as bigint)
UNION ALL SELECT 65536
UNION ALL SELECT 256
UNION ALL SELECT 1)a
RETURN(STUFF(@re,1,1,''))
END
这一段?
#2
上面的例子都是SQLSERVER的 在 SYBASE中 不行的。
#3
这一段修改一下应该可以吧
#4
不行的 %好像要转换类型 好像SYBASE 也没有函数这个说法
#5
%在SQLSERVER中是求模,在SYBASE中用MOD
MOD( dividend, divisor )
MOD( dividend, divisor )
#6
恩 使用c++写个扩展存储过程吧
#7
我要用BCP 把数据到处来,同时把int类型转换成IP 字符串
mod 函数好像也不行Function 'MOD' not found. If this is a SQLJ function, use sp_help to check whether the object exists (sp_help may produce a large amount of output).
mod 函数好像也不行Function 'MOD' not found. If this is a SQLJ function, use sp_help to check whether the object exists (sp_help may produce a large amount of output).
#8
查了一下,SYBASE 中有%
sybase的求余函数
X % Y
sybase的求余函数
X % Y
#9
已经搞定
declare @a int
select @a = -1062729436
if @a < 0
begin
select '' + cast(((@a & 0x000000FF) /16777216 + 256) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
end
else
select '' + cast(((@a & 0x000000FF) /16777216 ) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
大家可以共享一下,呵呵 ,我很不容易才搞定的哦!!!
declare @a int
select @a = -1062729436
if @a < 0
begin
select '' + cast(((@a & 0x000000FF) /16777216 + 256) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
end
else
select '' + cast(((@a & 0x000000FF) /16777216 ) as varchar) + '.' +
cast(((@a & 0x0000FF00) / 65536) as varchar) + '.'
+ cast(((@a & 0x00FF0000) / 256) as varchar) + '.'
+ cast((@a & 0xFF000000) as varchar)
大家可以共享一下,呵呵 ,我很不容易才搞定的哦!!!
#10
与SQLSERVER相差不大,学习