Need to run SQL statement using values from different table.

  • HI All

    I want to run the following statement changing Document ID value. I have the document ID's in different table.

    How do i run one time, using document values from different table.

    declare

    @ORDDOCID char(15)

    select @ORDDOCID = '00001'

          insert into B(ORDDOCID, DATE1)

               select

    ORDDOCID, DATE1 from A

                   where

    ORDDOCID = @ORDDOCID

    Thx

    Vijay

  • use an inner join

    e.g.

    select @ORDDOCID = '00001'

          insert into B(ORDDOCID, DATE1)

               select A.

    ORDDOCID, A.DATE1 from A

                 inner join othertable C

                   on

    A.ORDDOCID = C.ORDDOCID

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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