locked
inserting one value to multiple rows and one column RRS feed

  • Question

  • Hi maybe this is a easy question to you, how can i insert one value to multiple rows and one value lets say

    ID Date

    1

    2

    3

    4

    5

     

    so i want to insert date 2011-12-09 to all of the rows

    so it must be:

     

    ID     Date

    1   2011-12-09

    2   2011-12-09

    3   2011-12-09

    4   2011-12-09

    5  2011-12-09

     

    please advise.

    thanks!

    Monday, December 12, 2011 3:07 AM

Answers

  • Do you want to update all existing rows to the same Date value?  In that case, try:

     

    UPDATE dbo.MyTable
    SET [Date] = '2011-12-09';
    


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    • Proposed as answer by Vinay Valeti Monday, December 12, 2011 3:25 AM
    • Marked as answer by iamnewtosql Monday, December 12, 2011 4:22 AM
    Monday, December 12, 2011 3:10 AM