dbTalk Databases Forums  

Create table, remove records?

microsoft.public.sqlserver.datawarehouse microsoft.public.sqlserver.datawarehouse


Discuss Create table, remove records? in the microsoft.public.sqlserver.datawarehouse forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
vidro
 
Posts: n/a

Default Create table, remove records? - 07-07-2005 , 08:55 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?



Reply With Quote
  #2  
Old   
JT
 
Posts: n/a

Default Re: Create table, remove records? - 07-07-2005 , 09:44 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 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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?





Reply With Quote
  #3  
Old   
Danny
 
Posts: n/a

Default Re: Create table, remove records? - 07-08-2005 , 06:51 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 (AT) microsoft (DOT) com> wrote

Quote:
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 (AT) discussions (DOT) microsoft.com> wrote in message
news:1439F5CF-1C3E-4A28-BEF8-D7CA4423CBA3 (AT) microsoft (DOT) 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?







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.