Results 1 to 2 of 2

Thread: Whats wrong with this transact sql?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Whats wrong with this transact sql?

    declare @PartNoParam varchar(14)

    @PartNoParam = SELECT part_no_struc
    FROM dbo.gq67_operation_mtrl
    WHERE (operation_no = @OpNo) AND (part_no = @PartNo) AND (internal_order_no = @OrderNo)

    IF(@@ROWCOUNT =0)
    BEGIN



    @PartNoParam = SELECT part_no_struc
    FROM dbo.gq61_operation_test
    WHERE (operation_no = @OpNo) AND (part_no = @PartNo) AND (internal_order_no = @OrderNo)

    END

    The query goes like this


    1)Check if a value exist in table A
    2)Check if a value exist in table B
    3)Use that value as a parameter when querying table C


    So I want to get a value from either A or B... it can only exist on one of the tables but I don't know which one so I ahve to ask them both... I want then to use that result in an additional quety using @PartNoParam as a parameter... but I get errors in this code...

    is it incorrect?? it should be a piece of cake?

    kind regards
    Henrik

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    but I get errors in this code.
    Usually, it helps to post the error messages. Buts its probably a syntax error.

    Code:
    Set @PartNoParam = (SELECT part_no_struc
    FROM dbo.gq67_operation_mtrl
    WHERE (operation_no = @OpNo) AND (part_no = @PartNo) AND (internal_order_no = @OrderNo) )
    
    'or change it to 
    
    SELECT @PartNoParam = part_no_struc
    FROM dbo.gq67_operation_mtrl
    WHERE (operation_no = @OpNo) AND (part_no = @PartNo) AND (internal_order_no = @OrderNo)

Posting Permissions

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



Click Here to Expand Forum to Full Width