Creating Script - date fields in two columns

  • New at some of this scripting - have a table that has multiple fields with dates - I need to have the date in column B the same as the date in column A - keep running into a problem using update or do I have to have a select statement first -

    Greatly appreciate any help!!!

    THANKS

     

     

  • UPDATE TableName SET

         CoumnB = ColumnA

     

    [Note: this update will change the all of the values for ColumnB since there is no WHERE statment.  Is this what you want?] 

     

    I wasn't born stupid - I had to study.

  • Yes - do I have to put in a statement selecting a database?

  • I was working under the assumption that you were doing this from Query Analyzer with the database already defined.  Where are you planning on running this statement? 

     

    I wasn't born stupid - I had to study.

  • Question - if the dates in both columns have to be the same, what exactly are they used for? Why do you then need both columns? Column B seems redundant.

    If you must also ensure this for future data, you could alter column B to be to be derived automatically from Column A.

  • This is the correct approach if in fact both fields are always the same...  

     

     

    I wasn't born stupid - I had to study.

Viewing 6 posts - 1 through 5 (of 5 total)

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