When creating a user defined function is it "bad" to just automatically use the largest string possible?
For example, given the following UDF, I've used nvarchar(max)
for my input string, where I know perfectly well that the function currently isn't going to need to accept nvarchar(max)
and maybe I'm just forward thinking too much, but I supposed that there would always be the possibility that maybe an nvarchar(max)
would be passed to this function.
By doing something "bad" I'm wondering that by declaring that this function could possibly receive and actual nvarchar(max)
am I doing anything to possibly cripple performance?
CREATE FUNCTION [dbo].[IsMasNull] (@value nvarchar(max))
RETURNS BIT
AS
BEGIN
RETURN
CASE
WHEN @value IS NULL THEN 1
WHEN CHARINDEX(char(0), @value) > 0 THEN 1
ELSE 0
END
END