dbTalk Databases Forums  

How do I scan records and assign values to fields using DTS?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss How do I scan records and assign values to fields using DTS? in the microsoft.public.sqlserver.dts forum.



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

Default How do I scan records and assign values to fields using DTS? - 07-07-2003 , 01:08 AM






Hi!

I am new to DTS scripting and I was wondering if there's any way in DTS to
scan an existing table and change a field's value. I am generating a lookup
table as I load my raw data. As this lookup table will be used later on to
populate a dimension table, I need to programmatically scan its contents and
assign values to an empty (key) field.

Here's what I want to do in pseudo code:

i = 0
create table MYTABLE (key int, desc varchar(20))
insert into MYTABLE (select distinct 0, SomeDescField from MYSOURCETABLE)
scan MYTABLE
i = i + 1
MYTABLE.key = i
endscan

Any help will be higly appreciated. Thanks!

Greg



Reply With Quote
  #2  
Old   
Jacco Schalkwijk
 
Posts: n/a

Default Re: How do I scan records and assign values to fields using DTS? - 07-07-2003 , 05:10 AM






You could use an IDENTITY column:

CREATE TABLE #MYTABLE (key int IDENTITY (0,1), descr varchar(20))

insert into MYTABLE (descr)
select SomeDescField from MYSOURCETABLE



--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.


"Greg_Del_Pilar" <Greg_Del_Pilar (AT) hotmail (DOT) com> wrote

Quote:
Hi!

I am new to DTS scripting and I was wondering if there's any way in DTS to
scan an existing table and change a field's value. I am generating a
lookup
table as I load my raw data. As this lookup table will be used later on to
populate a dimension table, I need to programmatically scan its contents
and
assign values to an empty (key) field.

Here's what I want to do in pseudo code:

i = 0
create table MYTABLE (key int, desc varchar(20))
insert into MYTABLE (select distinct 0, SomeDescField from MYSOURCETABLE)
scan MYTABLE
i = i + 1
MYTABLE.key = i
endscan

Any help will be higly appreciated. Thanks!

Greg





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 - 2012, Jelsoft Enterprises Ltd.