Is it possible through T-SQL to Select a non nullable column and make it nullable?

Beantwortet Is it possible through T-SQL to Select a non nullable column and make it nullable?

  • Friday, December 28, 2012 3:07 PM
     
     

    I have this Oracle syntax which seems to make a <blank> column <NULL> and I am wondering if there's anyway to do the same kind of thing in Microsoft SQL Server. Here's the Oracle Syntax...

    SELECT *
    FROM    ADDRESS
    WHERE   ADDRTYPE_WHO = '123456789 '
    AND     LTRIM(RTRIM(VOID))    IS NULL

    this produces the same result set in Oracle...

    SELECT *
    FROM    ADDRESS
    WHERE   ADDRTYPE_WHO = '123456789 '
    AND     VOID = ' ' (That's 1 <blank> space)

    I have NEVER seen anything like this and actually find it kind of obscure. But I'm forced to re-engineer an Oracle Query into SQL Server and don't know what to do in this case besides the obvious of course.

    Any suggestions?

    Thanks in advance for your review and am hopeful for a reply.

    PSULionRP

All Replies

  • Friday, December 28, 2012 3:20 PM
    Moderator
     
     

    Check function NULLIF or CASE expression in BOL.

    ...
    and NULLIF(VOID, ' ') IS NULL;


    AMB

    Some guidelines for posting questions...

  • Friday, December 28, 2012 3:20 PM
     
     Answered

    try

    SELECT *
    FROM    ADDRESS
    WHERE   ADDRTYPE_WHO = '123456789 '
    AND nullif(ltrim(rtrim(Void)),'') is null


    Please mark as 'Answer', if the solution solves your problem.


    • Edited by Stan210 Friday, December 28, 2012 3:20 PM
    • Marked As Answer by PSULionRP Friday, December 28, 2012 3:26 PM
    •  
  • Friday, December 28, 2012 3:27 PM
     
     

    Perfect!

    Thank You Much!