Home Forums SQL Server 2005 T-SQL (SS2K5) Inserting data in one table as selecting from other tables RE: Inserting data in one table as selecting from other tables

  • If you add a NULL into a string, the result is NULL, so you need to handle the nulls individually like this:

    ISNULL(first value, second value) - returns the first non-null value. COALESCE can handle more than 2 values - I don't think you need this though.

    So you would use:

    Select ISNULL(Father_FirstName + ' ', '') + ISNULL(Father_LastName + ' ', '') + ISNULL(Father_Occupation... AS Parent

    You only need to deal with the columns which contain nulls (of course).

    Note: The way it's written stops too many spaces being entered in the string.