concatenating NULLS in a View

  • I am using SQL 2K

    I am using a view to concatenate two fields (software and version). If the version field is null I am getting the result as null.

    If I run the query in QueryAnalyser and put SET CONCAT_NULL_YIELDS_NULL OFF

    before it , then it works OK

    How can I achieve the same results using a view.

    SELECT basesoftwarename + N' ' + basesoftwareversion AS Software from tblsware

    tblsware definition

    basesoftwarename nvarchar(40)

    bassoftwareversion nvarchar(12)

    Sample Data

    Access 97

    Norton Antivirus NULL

    DB2 7.0

  • Try:

    SELECT ISNULL(basesoftwarename,N'') + ISNULL(basesoftwareversion,N'') AS Software from tblsware


    Cheers,
    - Mark

  • Thanks - that's achieved the perfect result

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply