Recursive update query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinit
    New Member
    • Jun 2007
    • 43

    Recursive update query

    hi
    i have a table like

    col1 col2 col3 col4
    35 R 0 0
    36 W 1 35
    37 R 0 0
    38 W 2 35,36

    I am giving col1 value 35 as input
    i want to write a update query so that the result
    col1 col2 col3 col4
    35 C 0 0
    36 R 0 0
    37 R 0 0
    38 W 1 36

    pls give me any clues to write this recursive update query
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    You will need to write a stored proceudure for that!!

    Comment

    • srinit
      New Member
      • Jun 2007
      • 43

      #3
      Originally posted by amitpatel66
      You will need to write a stored proceudure for that!!
      Can you please tell me how can i write that procedure.

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        in column 2 what do C,R,W mean?
        What are the rules to follow for the update?
        There are lots of other questions that will come up

        Really, you are in the best position to see how the stored proc should be written
        because
        You have access to the data.
        You know what you want to achieve.
        You know the environment you are working in.
        You know the design of the database
        You can write test queries,UDF's etc etc on your data and run them to see what happens

        Think about the above questions and try and come up with ideas to achieve it.
        Perhaps you could use a cursor? (Recommended as a last resort)
        You can write recursive queries! (This could be the path you should follow)
        Maybe some other method there are hundreds?
        The help documents can help you there
        If you get stuck we are only too happy to help you over the bit you are stuck on.


        PS I am trying to be helpfull here

        Comment

        Working...