Home > Archive > MS SQL Data Warehousing > July 2005 > Create table, remove records?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Create table, remove records?
vidro

2005-07-07, 9:23 am

SQL 2000;

I have a table that has info from 2001 thru 2005, I want to create new
tables and move records from the original table to the new tables, based on
year.
What is the best way to do this?


JT

2005-07-07, 9:23 am

1. Create empty tables for 2001 to 2005 with record structures identical
to the original and no indexes.

2. For each table, do something like the following:
insert into SALES_2001 select * from SALES where period = 2001

3. Create indexes to the new tables.

Since you are inserting into new tables, you could also temporarily set the
database recovery model to "simple". If there are millions of rows, this
will reduce transaction logging and speed things up.

"vidro" <vidro@discussions.microsoft.com> wrote in message
news:1439F5CF-1C3E-4A28-BEF8- D7CA4423CBA3@microso
ft.com...
> SQL 2000;
>
> I have a table that has info from 2001 thru 2005, I want to create new
> tables and move records from the original table to the new tables, based

on
> year.
> What is the best way to do this?
>
>



Danny

2005-07-08, 7:23 am

Same advice JT gave you except if the table structures are the same use
select into instead of create table and insert into.

"JT" <someone@microsoft.com> wrote in message
news:OxqloKwgFHA.3616@TK2MSFTNGP12.phx.gbl...
> 1. Create empty tables for 2001 to 2005 with record structures
> identical
> to the original and no indexes.
>
> 2. For each table, do something like the following:
> insert into SALES_2001 select * from SALES where period = 2001
>
> 3. Create indexes to the new tables.
>
> Since you are inserting into new tables, you could also temporarily set
> the
> database recovery model to "simple". If there are millions of rows, this
> will reduce transaction logging and speed things up.
>
> "vidro" <vidro@discussions.microsoft.com> wrote in message
> news:1439F5CF-1C3E-4A28-BEF8- D7CA4423CBA3@microso
ft.com...
> on
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com