Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Split Huge Table Into Smaller Tables

Author  Topic 

ellasisking
Starting Member

2 Posts

Posted - 2005-06-07 : 16:42:40
I have a table with over 50 fields and would like to split it into smaller tables. Here is a simplified example of what I am trying to do.

Suppose I have a table, "ProductInfo" with fields:

ProductID
ProductSubID
Descript
Color
Size
Texture
Style


I would like to split it into tables, "ProductColor","ProductSize","ProductTexture","ProductStyle". Keep in mind that the actual table I will be doing this with are much more complicated. The table productinfo already has over 100,000 rows. I want to split into tables that look like:

ProductInfo : Product ID,ProductSubID,Descript
ProductColor : Product ID,ProductSubID,Color
ProductSize: Product ID,ProductSubID,Size
ProductTexture: Product ID,ProductSubID,Texture
ProductStyle: Product ID,ProductSubID,Style

How would I write a script to do this?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-06-07 : 17:08:53
I have to question your reason for doing this. You appear to be taking attributes related of the primary key and splitting them into separate tables.

This will almost certainly have a very negative impact on performance, and make programming much more complicated.



CODO ERGO SUM
Go to Top of Page

ellasisking
Starting Member

2 Posts

Posted - 2005-06-07 : 17:19:28
This is a project I took over and at this point, none of the tables have primary keys defined explictly. The actual table I am trying to split up has 5 fields used to identify the object (FederalLaw, SubLaw, Regulation, BusinessUnit, and Division) and about 45 fields describing this object. Although this makes no sense in the actual table, suppose one of the fields was "Color", I want a different row for say "Blue" and "Green" of the same (FederalLaw, SubLaw, Regulation, BusinessUnit, and Division). The problem is that the only way to do this is by inserting another row with the exact same values (all 50 fields) with the exception of the color field. I want to split up the tables so there isn't that much space wasted and because I want each (FederalLaw, SubLaw, Regulation, BusinessUnit, and Division) in the original table to be Unique.
Go to Top of Page

zokho
Starting Member

10 Posts

Posted - 2005-06-07 : 19:12:55
i've read your question but i didnt understand it well
and i think you should normalized your table on a pice of paper first and divide it to smaller tables then write that code...an go on
Go to Top of Page
   

- Advertisement -