Set based query result possible?

Last Post 10 May 2012 09:27 AM by rerichards. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
rerichards
New Member
New Member

--
09 May 2012 08:45 AM
Let's say I have 1,000 tables, each with a column named "ChangedAt". The ChangedAt column is data type of "datetime".

Anytime a record gets changed in any of the 1,000 tables the ChangedAt column gets updated with the current datetime using GetDate().

Let's also suppose I have a baseline date, say, '1/1/2012 00:00:00.000'.

My object is to find out how many records have changed in each of the 1,000 tables since my baseline date.

I know I can do this using TBAT (table by agonizing table) using a cursor or loop construct, but is there a way to get the same results using set based logic?
gunneyk
New Member
New Member

--
10 May 2012 09:06 AM
If it were just a few tables I would suggest building a UNION dynamically and running that. But with 1K tables I don't think it is practical and a cursor may be your best bet.
rerichards
New Member
New Member

--
10 May 2012 09:27 AM
Understood. Thanks for the reply.
You are not authorized to post a reply.

Acceptable Use Policy