为什么 SQL Server 认为这个函数是不确定的?
CREATE FUNCTION [Util].[BuildStreetFullName]
(
@StreetNumber VARCHAR(20),
@StreetDir VARCHAR(2),
@StreetName VARCHAR(50) ,
@StreetType VARCHAR(4) ,
@StreetPostDir VARCHAR(2)
)
RETURNS VarChar(100)
AS
BEGIN
SET @StreetNumber = NULLIF( Util.Trim(@StreetNumber ), '');
SET @StreetDir = NULLIF( Util.Trim(@StreetDir ), '');
SET @StreetName = NULLIF( Util.Trim(@StreetName ), '');
SET @StreetType = NULLIF( Util.Trim(@StreetType ), '');
SET @StreetPostDir = NULLIF( Util.Trim(@StreetPostDir ), '');
DECLARE @Result VarChar(100) = @StreetNumber;
IF @StreetDir IS NOT NULL BEGIN
IF @Result IS NOT NULL
SET @Result = @Result + ' ' + @StreetDir;
ELSE
SET @Result = @StreetDir;
END
IF @StreetName IS NOT NULL BEGIN
IF @Result IS NOT NULL
SET @Result = @Result + ' ' + @StreetName;
ELSE
SET @Result = @StreetName;
END
IF @StreetType IS NOT NULL BEGIN
IF @Result IS NOT NULL
SET @Result = @Result + ' ' + @StreetType;
ELSE
SET @Result = @StreetType;
END
IF @StreetPostDir IS NOT NULL BEGIN
IF @Result IS NOT NULL
SET @Result = @Result + ' ' + @StreetPostDir;
ELSE
SET @Result = @StreetPostDir;
END
RETURN NULLIF(@Result, '');
END
CREATE FUNCTION [Util].[Trim]
(
@value nVarChar(max)
)
RETURNS nVarChar(max)
AS
BEGIN
RETURN LTrim(RTrim(@value))
END