Database options

  • I am working on a Windows 2000 server running SQL Server 2000. I have set the database option "concat null yields null" to false. Then I tried concating a literal and a variable that was null and it still gave me null. The only way I have got it to work was to use the "SET CONCAT_NULL_YIELDS_NULL { ON | OFF } " to off. Why does the database option not work???

    Edited by - walker31808 on 10/29/2003 12:16:29 PM

  • Check your ANSI_NULLS setting. Usually you will want to use the ISNULL function instead though. That way regardless of how the database is set up the code still works.

    IE:

    DECLARE @var varchar(255)

    SET @var = NULL

    SET @var = ISNULL(@var,'') + 'hey it works!'

    SELECT @var

    Gary Johnson

    Microsoft Natural Language Group

    DBA, Sr. DB Engineer




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • If you're testing this in Query Analyzer (QA), check the setting in Tools|Options|Connection Properties. The default is for that setting to be checked (true) and will override the server setting.

    --Jonathan



    --Jonathan

  • Thanks Jonathan, I was testing in QA and the it was the setting there that was overriding the server setting

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

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