SQL Server - Select list and update a field in each row -
i hate ask know has been answered, after 45 minutes of searching yield here.
i have table need select list of items based on value, , take 1 field , add year , update column value.
example:
select * table description='value_i_need' update table set enddate=dateadd(year, 1, begindate) -- each item in select
edit: select statement return ton of results. need update each row uniquely.
i don't know how combine select or loop through results.
my sql knowledge limited, , wish have figured out without having ask. appreciate help
edit 2:
have 1 table need go through , update end date on each item matches description. have 1000 "computers" example, need update field in each row description based on field in same row. coming 1 table
try this
update table t1 set t1.enddate=dateadd(year, 1, begindate) t1.description='value_i_need'
Comments
Post a Comment