Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    46

    Unanswered: Ignore null fields

    Hi,

    I have a query like this one

    SELECT expense_id, CAST(expense_id AS char(10)) + ' - ' + CAST(trip_km AS char(5))+ ' - ' + CAST(expense_amount AS char(5)) + ' - ' + charge_centre AS ExpenseDesc

    If charge center is null, I need to ignore this field. How can I achieve this? The reason is that if any of the field is null, it will return ExpenseDesc as null.

    Thanks

  2. #2
    Join Date
    Feb 2005
    Location
    Utah
    Posts
    73
    SELECT expense_id, CAST(expense_id AS char(10)) + ' - ' + CAST(trip_km AS char(5))+ ' - ' + CAST(expense_amount AS char(5)) + ' - ' + isnull(charge_centre,'') AS ExpenseDesc

    oh, and by the way if any of these fields can be null then you want to do that kind of a check because anything plus a null is a null.
    Dandy
    Aspiring Database Dwarf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •