Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    395

    Unanswered: Re: Get not null or empty string is not work

    Hi all,

    Could anyone see where the error is in this IF statement?
    I have three records in Shipment_history table with that work_ord_num and w/i those three records one record has a value in cust_part_num field.
    I want the query return the cust_part_num value but it returns the record w/o cust_part_num.
    Thanks much!

    spSomething
    :
    Declare popu_tbl Cursor

    For
    SELECT TOP 100 PERCENT dbo.tblShipping_sched.work_ord_num, ...
    FROM tbl
    WHERE..

    Open popu_tbl
    Fetch Next From
    While ...
    Begin

    ---***
    IF @cust_part_num is null
    SELECT @cust_part_num = cust_part_num FROM dbo.Shipment_history
    WHERE work_ord_num like (left(@work_ord_num, 6) + '%') AND work_ord_line_num = @work_ord_line_num
    AND cust_part_num <> "";
    --** the line above doesn't work

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Use:
    IF @cust_part_num is NOT null

    ...but why are you doing this in a cursor?

    I'd almost guarantee that there are other issues with the code you have ommitted.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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