Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving Database to another Database.

Status
Not open for further replies.

bind

IS-IT--Management
Dec 13, 2004
25
0
0
I have a Microsoft SQL database thats rather large in size and I need to come up with a store procedure to move this database by the year and month. for example

SELECT * FROM plat_calls.dbo.calls where calldate >= '2001-01-01' and calldate < '2002-02-01'

I need to somehow break this query up into months and then insert it into another database 20020201- would contain all of the entries for 2002 for the month of feb.

Anyone have any advise or sample code as to how I might be able to do this ?
 

SELECT * FROM plat_calls.dbo.calls
where year(calldate) = 2001 And Month(calldate) = 2

==========================
Date is a way to show you care
Time is a great healer
DateTime is just damn confusing

Tim
 
Thanks for the formatting tip =)
 
I can see the need to avoid doing unnecessary backups, but why not just warehouse all of the data into just one DB table? If it's a query time issue, then why isn't separate tables rather than DB's ok...maybe you meant that? Dynamic SQL could do it, but if you don't need to repeat the process more than once a month, then I'd just create the tables and run queries to do the job on each one...unless you're talking 10 years worth!
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Karl,

Yes I would like to premake each table for each year and month then write a store procedure with the query for each month to insert sections of the huge database into each one of those premade tables. The problem is I am semi new to SQL and im not entirely sure how I would go about writing this store procedure. I was actually looking for maybe some examples or direction.

Thanks again
 
Maybe someone who uses dynamic SQL can help you out, sorry.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top