not null value in stored procedure

  • I have a simple stored procedure to update quanty remaining if there is a value in the shipped quantity field. I am having trouble getting the records that do not contain null values in shipped quanty.

    This stored procedure below doesn't work:

    --No records created. No Syntax error

    CREATE PROCEDURE dbo.spGet_qty_remaining

    AS

    Update tblshipping_sched

    Set shipped_qty_remaining = shipped_qty_remaining - shipped_qty

    where shipped_qty is not null;

    This stored procedure below work:

    CREATE PROCEDURE dbo.spGet_qty_remaining

    AS

    Update tblshipping_sched

    Set shipped_qty_remaining = shipped_qty_remaining - shipped_qty

    where shipped_qty = 80;

    Thank you!

  • Check if query get any candidates for the update

    Select Count(*) from tblshipping_sched

    where NOT (shipped_qty is null)

  • Hi alicejwz,

    quote:


    This stored procedure below doesn't work:

    --No records created. No Syntax error

    CREATE PROCEDURE dbo.spGet_qty_remaining

    AS

    Update tblshipping_sched

    Set shipped_qty_remaining = shipped_qty_remaining - shipped_qty

    where shipped_qty is not null;


    as Len suggested, I would say that there are no NULL values, the syntax looks correct.

    BTW, are you really looking for NULL values or looking for = 0 values?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • and remember spaces are not null

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

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