I am trying to take all datetime fields in my database, and increment the year by 1. I've ran this query to find all tables and each field that is a datetime field: SELECT table_name, column_nameFROM information_schema.columnsWHERE data_type='datetime'
The results might look like this:TableName, FieldName-------------------Threads,PostDateReplies,ReplyDate
From there, I've pasted the results in to Excel and concatenated a statement for each row to increment the date. From Excel, I've produced this:UPDATE Threads SET PostDate = DATEADD(Year,1,PostDate)UPDATE Replies SET ReplyDate = DATEADD(Year,1,ReplyDate)
My question, is how can I use T-SQL to accomplish this, without using goofy Excel to produce a bunch of individual UPDATE statements? Basically I'm looking for some sort of for/each loop of a thing... Thanks for any help..