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
 Transact-SQL (2000)
 How to cut one table in 2 or 3 tables?

Author  Topic 

Chleb
Starting Member

1 Post

Posted - 2005-12-28 : 08:31:37
hello,

I've got a big table and I want to cut it in 3 tables. What is the command to do it with Transact SQL?

Thanks for your help.
Chleb

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-28 : 08:35:03
It depends on how you want it to cut. One of the solutions is create Views and filter data

Create View view1
as
Select columns from yourTable where <condition1>

Similarly create two more views with valid conditions

Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2005-12-28 : 09:08:19
Select * into BkupTbl from OriginalTbl

Select top 10000 * into Tbl_1 from OriginalTbl order by PrimKey
Delete from OriginalTbl where PrimKey in (select PrimKey from Tbl_1)

Select top 10000 * into Tbl_2 from OriginalTbl order by PrimKey
Delete from OriginalTbl where PrimKey in (select PrimKey from Tbl_2)

and so on


Go to Top of Page
   

- Advertisement -