Here is the stored procedure:
CREATE PROCEDURE shettle.SearchAddRepAddLine
@AddressLine varchar(1000),
@Location varchar(100)
AS
IF @Location = '%'
SELECT IsNull(Num, '') As StreetNumber,
IsNull(PreDir, '') As Predirection,
IsNull(shettle.InitCap(StrName), '') As StreetName,
IsNull(shettle.InitCap(StrType), '') As StreetType,
IsNull(SecUnitDes, '') As SecUnitDesignator,
IsNull(SecUnit, '') As SecUnit,
IsNull(shettle.InitCap(City), '') As City,
IsNull(State, '') As State,
IsNull(Zip, '') As Zipcode,
IsNull(X, '') As X,
IsNull(Y, '') As Y
FROM addrep.dbo.Addpt WITH (INDEX = 4)
WHERE MailAddLine = @AddressLine
ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9
ELSE
SELECT IsNull(Num, '') As StreetNumber,
IsNull(PreDir, '') As Predirection,
IsNull(shettle.InitCap(StrName), '') As StreetName,
IsNull(shettle.InitCap(StrType), '') As StreetType,
IsNull(SecUnitDes, '') As SecUnitDesignator,
IsNull(SecUnit, '') As SecUnit,
IsNull(shettle.InitCap(City), '') As City,
IsNull(State, '') As State,
IsNull(Zip, '') As Zipcode,
IsNull(X, '') As X,
IsNull(Y, '') As Y
FROM addrep.dbo.Addpt WITH (INDEX = 4)
WHERE MailAddLine = @AddressLine
AND MailCityLine LIKE @Location
ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9
GO
-Aaron
-Aaron
|