Empty Space Data

  • Below is the code I am using to generate DimCustomer table. However, suburb column got few empty spaces there is no data in that. I want to fill 'UNKNOW' in all the empty places.

    Can anyone help me out thanx

    SELECT c.[status]

    ,c.[depot]

    ,d.[name]

    ,c. as customercode

    ,c.[name] as customerName

    ,c.[territory] as Suburb

    FROM [dbo].[Customer] c

    INNER JOIN [Depot] d

    ON c.[depot] = d.

    WHERE C.[status] = 'L'

    Thanks,

    D

  • Not tested as no test data but try this:

    SELECT c.[status]

    ,c.[depot]

    ,d.[name]

    ,c. as customercode

    ,c.[name] as customerName

    ,coalesce(nullif(c.[territory],''),'Unknown') as Suburb

    FROM [dbo].[Customer] c

    INNER JOIN [Depot] d

    ON c.[depot] = d.

    WHERE C.[status] = 'L'

  • Perfect it works fine !!!

    Thanks,

    D

  • You're welcome!

    You can also use a Case statement, by the way. I wonder if there will be a performance difference between the two approaches... It will probably generate near identical plans.

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

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