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)
 Conditionally splitting a table into two tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-16 : 09:31:52
chris writes "Hi
I am importing a table from Access to SQL Server, and am creating a DTS package to aid in the importation. For each record, based on whether a certain field (say "contract_number") in the old table is empty or not, I want to throw that record into one of two tables.
Any ideas on how to accomplish this?
Cheers,
Chris"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-16 : 10:11:57
You are going to want two distinct data pump task, each with a query for the source enumerating the rows you desire.

<O>
Go to Top of Page

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-07-16 : 10:21:11
Import all data into a first table (call it table_name_DTS or something along those lines). In the DTS package, execute SQL code along these lines:

insert into table1
select * from table_name_DTS where bleh='bleh'

insert into table2
select * from table_name_DTS where bleh='not bleh'

then just a final piece of code that truncates the _DTS table


-----------------------
Take my advice, I dare ya

Edited by - M.E. on 07/16/2002 10:21:49
Go to Top of Page
   

- Advertisement -