exporting by year and month from 100 tables

I've been asked to export data out of 100 tables.

for each table it would be something like this:

select * from table1
where datepart(yyyy,table1.DOS)=2011
and datepart(mm,table1.DOS)=01

and then:

select * from table1
where datepart(yyyy,table1.DOS)=2011
and datepart(mm,table1.DOS)=02

etc...

i would need to do this for every YEAR and for every MONTH for every table

i need to export these data sets to a CSV

can you please give me some guidance on how i can automate this instead of using the IMPORT/EXPORT wizard manually?

Answers


Dynamic SQL with sp_msforeachtable. Here is a link with info and examples:

http://weblogs.asp.net/nunogomes/archive/2008/08/19/sql-server-undocumented-stored-procedure-sp-msforeachtable.aspx


My Suggestion - Window Services help you out by setting the timing(Scheduling) in Application Configuration file


Need Your Help

Optimizing drawing on UITableViewCell

iphone cocoa-touch uitableview core-animation core-graphics

I am drawing content to a UITableViewCell and it is working well, but I'm trying to understand if there is a better way of doing this.

MySQL limiting by foreign key

mysql database join enums foreign-keys

I have a complex object I'm trying to store in the database.