September 8, 2006 at 2:47 am
I'm trying to figure out how to do a function that can grab a memberID and spit out their Lastname, Firstname together as a nvarchar and my function below gives me NULL values for membername. Can anyone help me?
USE
DatabaseName;
GO
CREATE
FUNCTION dbo.MemberName(@RegMemberID varchar(3))
RETURNS
nvarchar(42) WITH EXECUTE AS CALLER
AS
begin
DECLARE @fullname nvarchar(42)
SELECT @fullname = (LastName + ', ' + FirstName)
FROM dbo.RegisteredMembers
WHERE @RegMemberID = RegMemberID;
RETURN @fullname;
end
GO
USE
DatabaseName
GO
September 8, 2006 at 4:50 am
SELECT @fullname = (ISNULL(LastName,'') + ', ' + ISNULL(FirstName,''))
NULL+something=NULL
if there is no RegMemberID it still returns NULL
September 8, 2006 at 2:07 pm
I wasn't born stupid - I had to study.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply