请考虑以下功能和函数调用:
create function [dbo].[GetCidrIpRange2](@CidrIp varchar(15))
returns @result table
(
LowRange varchar(15) not null,
HighRange varchar(15) not null,
AddressQty bigint not null
)
as
begin
declare @Base bigint = cast(4294967295 as bigint)
declare @Mask int = cast(substring(@CidrIp, patindex('%/%' , @CidrIP) + 1, 2) as int)
declare @Power bigint = Power(2.0, 32.0 - @Mask) - 1
declare @LowRange bigint = dbo.[IPAddressToInteger](left(@CidrIp, patindex('%/%' , @CidrIp) - 1)) & (@Base ^ @Power)
declare @HighRange bigint = @LowRange + @Power
insert @result
select
LowRange = @LowRange
,HighRange = @HighRange
,AddressQty = convert(bigint, power(2.0, (32.0 - @Mask)))
return
end
select [dbo].[GetCidrIpRange2]('195.65.254.11/2');
我收到以下错误:
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.GetCidrIpRange2", or the name is ambiguous.
名称是唯一的,当我只运行该函数时,它在会话中正确创建了函数:
Command(s) completed successfully.
我做错了什么?
答案 0 :(得分:3)
您错过了FROM
:
SELECT * FROM [dbo].[GetCidrIpRange2]('195.65.254.11/2');