Results 1 to 2 of 2

Thread: @@error and stored procedures

  1. #1
    Dean Furness Guest

    @@error and stored procedures

    I was wondering if anyone knows how to suppress error messages that get returned from a stored procedure. For example, in a stored procedure I have a convert statement that takes some dates and substrings them together into a new date format:

    select convert(datetime(substring(col1,1,2)+ '/' +.......etc.

    Some of the data I am working with is not guaranteed to be good. For example, sometimes the users had entered 2/2/97 - which is invalid - no leap year in 1997. So, the convert to datetime fails.

    The typical error message about the convert pops up on the screen. Can I shut that off.....and still catch @@error <> 0....?

    Thanks!

    Dean

  2. #2
    gpbuenrostro Guest

    @@error and stored procedures (reply)

    You can use ISDATE fuction to determine if date in your string column
    is a valid date; then you convert it from var/char to datetime datatype.

    Check next sample:

    declare @vsDate varchar(20)
    select @vsDate = &#39;19990210&#39; -- invalid date

    if isdate(@vsDate)= 1
    begin
    select convert(datetime,@vsDate)
    end
    else
    begin
    print &#39;date is no valid&#39;
    end
    ------------
    Dean Furness at 9/22/99 4:02:36 PM

    I was wondering if anyone knows how to suppress error messages that get returned from a stored procedure. For example, in a stored procedure I have a convert statement that takes some dates and substrings them together into a new date format:

    select convert(datetime(substring(col1,1,2)+ &#39;/&#39; +.......etc.

    Some of the data I am working with is not guaranteed to be good. For example, sometimes the users had entered 2/2/97 - which is invalid - no leap year in 1997. So, the convert to datetime fails.

    The typical error message about the convert pops up on the screen. Can I shut that off.....and still catch @@error <> 0....?

    Thanks!

    Dean

Posting Permissions

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