Using 'XYZ' where ever null data is existing in the column

  • I have requirement. I want use 'xyz' where ever null data is existed in the column

    query is

    select firstname from address where firstname is null - this gives null data

    i want ti use 'xyz' insead of null.

    please help me. please send me sample query . presently i am using oracle DB.

    if possible please send query using pl/sql

    thanks

  • In T SQL

    Select ISNULL(FirstName, 'xyz') from tableName where firstname is null..

    In PLSQL you can replace the ISNULL with NVL i guess..

  • Hi,

    In SQL Server we have ISNULL function.

    You can write your query as below:

    SELECT ISNULL(FieldName,'XYZ') AS 'Result' FROM TableName

    Shatrughna

  • Could please help me to regarding one more issue

    I want to replace not null data with some other data

    for Ex

    In previous case we replaced null with some data. I want to do replace valid data with some other data

  • Hi,

    Some simple example of REPLACE:

    SELECT REPLACE('SQL Server Central','Server')

    SELECT REPLACE(FieldName,'ABC','PQR') AS 'Result' FROM TableName

    WHERE

    FieldName IS NOT NULL

    Shatrughna

  • SELECT CASE WHEN firstname IS NULL

    THEN 'xyz'

    ELSE 'abc' END AS new

    FROM address


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • UPDATE MyTable set MyField = 'MyField was NULL' where MyField IS NULL

    UPDATE MyTable set MyField = 'MyField was not NULL' where MyField IS NOT NULL

  • gmrose (9/20/2011)


    UPDATE MyTable set MyField = 'MyField was NULL' where MyField IS NULL

    UPDATE MyTable set MyField = 'MyField was not NULL' where MyField IS NOT NULL

    Doesn't that just updates everything?

  • Ninja's_RGR'us (9/20/2011)


    gmrose (9/20/2011)


    UPDATE MyTable set MyField = 'MyField was NULL' where MyField IS NULL

    UPDATE MyTable set MyField = 'MyField was not NULL' where MyField IS NOT NULL

    Doesn't that just updates everything?

    :laugh: Yeah, I think that about covers it!

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

  • mtillman-921105 (9/20/2011)


    Ninja's_RGR'us (9/20/2011)


    gmrose (9/20/2011)


    UPDATE MyTable set MyField = 'MyField was NULL' where MyField IS NULL

    UPDATE MyTable set MyField = 'MyField was not NULL' where MyField IS NOT NULL

    Doesn't that just updates everything?

    :laugh: Yeah, I think that about covers it!

    For once I can do this => It depends 😀

  • What kind of underwear do DBA's use?

    "Depends."

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

  • mtillman-921105 (9/20/2011)


    What kind of underwear do DBA's use?

    "Depends."

    We'ev a had a few bad dba jokes thread flying around.. maybe you need to copy that over there :-D.

  • Ninja's_RGR'us (9/20/2011)


    mtillman-921105 (9/20/2011)


    What kind of underwear do DBA's use?

    "Depends."

    We'ev a had a few bad dba jokes thread flying around.. maybe you need to copy that over there :-D.

    Sorry, I'm too stressed and busy here lately.

    But only in a couple of days, I'm moving to Colorado! WOOT!

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

Viewing 13 posts - 1 through 12 (of 12 total)

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