Help with Error Trapping

  • i am trying to structure a query to update my table with the following status numbers when running a certain step.

    0 = Not started

    1 = In progress

    2 = completed successfully

    -1 = Failed.

     

    How do I call these out in a sql query so tht it will update the table wtih the status?

    sorry, noob questions

  • I think we need a bit more info here.  Can you post your table DDL, sample data, and an example of what you want to have happen.  What determines which status a row falls into?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • I I understand right,

    You can create a function that can accept a string ('Not started', 'In progress',...) and returns the corresponding int value.

    If the function called (fStatus)

    The stored procedure would be something like this:

    create proc pp

    ...

    @STS nvarchar(20)

    as

    insert into [yourtable] (..., [statusfield])

    values (..., fStatus(@STS))

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

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