Results 1 to 4 of 4

Thread: SQL assistance

  1. #1
    Mohan Kambli Guest

    SQL assistance

    I need some explanantion on the following query that I'm trying to run:

    if exists (select * from sysobjects
    where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450

    When I run this query within a database where the slice_trace table does NOT exist, it still seems to execute the delete statement and hence fails because the object is not there.
    Essesntially I need this statement to execute only in databases where the table exists.



  2. #2
    Bob Lane Guest

    SQL assistance (reply)

    Try:
    if exists (select * from sysobjects where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    begin
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450
    end
    else
    begin
    return
    end




    ------------
    Mohan Kambli at 9/16/99 7:50:20 AM

    I need some explanantion on the following query that I'm trying to run:

    if exists (select * from sysobjects
    where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450

    When I run this query within a database where the slice_trace table does NOT exist, it still seems to execute the delete statement and hence fails because the object is not there.
    Essesntially I need this statement to execute only in databases where the table exists.



  3. #3
    Bob Lane Guest

    SQL assistance (reply)

    Try:
    if exists (select * from sysobjects where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    begin
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450
    end
    else
    begin
    return
    end


    ------------
    Mohan Kambli at 9/16/99 7:50:20 AM

    I need some explanantion on the following query that I'm trying to run:

    if exists (select * from sysobjects
    where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450

    When I run this query within a database where the slice_trace table does NOT exist, it still seems to execute the delete statement and hence fails because the object is not there.
    Essesntially I need this statement to execute only in databases where the table exists.



  4. #4
    mohan kambli Guest

    SQL assistance (reply)


    Bob,

    Thank You. I cut and pasted your query exactly as it is and even though the object slice_trace does not exist in the database I tried to run the command in, it still tried to execute the delete part of the if statement. So. I'm still puzzled.

    ------------
    Bob Lane at 9/17/99 9:25:56 AM

    Try:
    if exists (select * from sysobjects where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    begin
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450
    end
    else
    begin
    return
    end


    ------------
    Mohan Kambli at 9/16/99 7:50:20 AM

    I need some explanantion on the following query that I'm trying to run:

    if exists (select * from sysobjects
    where id = object_id ('slice_trace&#39
    and sysstat & 0xf = 3)
    delete from slice_trace
    where control_seq_number = 130
    and claim_number = 7912450

    When I run this query within a database where the slice_trace table does NOT exist, it still seems to execute the delete statement and hence fails because the object is not there.
    Essesntially I need this statement to execute only in databases where the table exists.



Posting Permissions

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