As Noel said, this is because you are trying to combine NULL into VARCHAR - the end result will be NULL. You also need to append other varchar values ββin single quotes to pass them around, which starts to become messy / problematic.
Use parameterized TSQL instead. This will allow you to easily pass NULL to your function, as well as protect against SQL injection.
DECLARE @CLIENTPK_NEW AS VARCHAR(50)
DECLARE @CGNEEPK AS VARCHAR(50)
DECLARE @TYPE AS VARCHAR(10)
SET @CLIENTPK_NEW='6EF77AAA-1A7B-4D03-A448-D1088DED4134'
SET @CGNEEPK= NULL
SET @TYPE='Mag'
DECLARE @SQL NVARCHAR(MAX)
SET @SQL = '
SELECT
PUBLISHER
FROM CLIENT_SHIPPINGREPORTDATA_FUNCTION(
@CLIENTPK_NEW, @CGNEEPK, @TYPE)'
EXECUTE sp_executesql @SQL,
N'@CLIENTPK_NEW VARCHAR(50), @CGNEEPK VARCHAR(50), @TYPE VARCHAR(10)',
@CLIENTPK_NEW, @CGNEEPK, @TYPE
source
share