I have written a DTS package to import a table from Oracle into SQL Server.
This table is defined as Data_Group (which is an employee id), Element_Code
(a numberic code that tells what data this row has, ie. Name, Address,
Status, etc), and then the Value. There are several elements that I will no
t
use, but I import them anyway for later use. My next step is to take these
data elements at build 1 record in my SQL Server table.
I am thinking about creating a SP that accepts the employee id and then
builds the record by using a bunch of SQL Update statements. Then write
another SP that opens a cursur on my input table (SELECT DISTINCT Data_Group
From T1) and call the SP from within the loop.
Is this a good approach or is there a better way? Thanks for your advice.insert newtbl
select id ,
(select s.name from staging s where s.id = t.id) ,
(select s.address from staging s where s.id = t.id) ,
...
from (select distinct id from staging) t
"Phill" wrote:
> I have written a DTS package to import a table from Oracle into SQL Server
.
> This table is defined as Data_Group (which is an employee id), Element_Cod
e
> (a numberic code that tells what data this row has, ie. Name, Address,
> Status, etc), and then the Value. There are several elements that I will
not
> use, but I import them anyway for later use. My next step is to take thes
e
> data elements at build 1 record in my SQL Server table.
> I am thinking about creating a SP that accepts the employee id and then
> builds the record by using a bunch of SQL Update statements. Then write
> another SP that opens a cursur on my input table (SELECT DISTINCT Data_Gro
up
> From T1) and call the SP from within the loop.
> Is this a good approach or is there a better way? Thanks for your advice.|||oops
insert newtbl (id, name, address, ...)
select id ,
name = (select s.value from staging s where s.id = t.id and s.code = 1) ,
address = (select s.value from staging s where s.id = t.id and s.code = 2) ,
...
from (select distinct id from staging) t
"Phill" wrote:
> I have written a DTS package to import a table from Oracle into SQL Server
.
> This table is defined as Data_Group (which is an employee id), Element_Cod
e
> (a numberic code that tells what data this row has, ie. Name, Address,
> Status, etc), and then the Value. There are several elements that I will
not
> use, but I import them anyway for later use. My next step is to take thes
e
> data elements at build 1 record in my SQL Server table.
> I am thinking about creating a SP that accepts the employee id and then
> builds the record by using a bunch of SQL Update statements. Then write
> another SP that opens a cursur on my input table (SELECT DISTINCT Data_Gro
up
> From T1) and call the SP from within the loop.
> Is this a good approach or is there a better way? Thanks for your advice.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment