dbTalk Databases Forums  

creating natural key from date time and integer in text file

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


Discuss creating natural key from date time and integer in text file in the microsoft.public.sqlserver.dts forum.



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

Default creating natural key from date time and integer in text file - 03-02-2005 , 01:06 AM






I'm creating a natural key for records that are generated with a dat
and timestamp.

The data and timestamp are in a textfile

To get a unique key the timestamp needs to be combined with a coupl
of other ints

Using a DTS VB script

DTSDestination("k") = DTSSource("TimeCol") + DTSSource("numbercolumn"

Column k is the primary key and defined as float in the DB

However, doing it like this does this: TimeCol (say, 10:38)
numbercolumn (say, 238) = 10:38238

I would like to do something like this Cdbl(DTSSource("TimeCol") ) bu
this generates a type mismatch error

In excel if you put a date in a cell and change the cell format t
number it converts the date to a number (julian date?)

My question is how can I generate a unique key using time and integer


I could use date part and remove all the colons or slashes, then ad
the result but I believe this has the possibility of generating
non-unique key

Also I'm importing large amounts of data and don't want to add
processor intensive amount of code in the dts package

Any suggestions would be appreciated

-Davi


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default RE: creating natural key from date time and integer in text file - 03-02-2005 , 04:37 AM






Your key sounds more like a smart key to me. Natural keys should come from
your data naturally.

You could do something like

DTSDestination("k") = REPLACE(DTSSource("TimeCol"),":","") &
DTSSource("numbercolumn")

perhaps

"wireless" wrote:

Quote:
I'm creating a natural key for records that are generated with a date
and timestamp.

The data and timestamp are in a textfile.

To get a unique key the timestamp needs to be combined with a couple
of other ints.

Using a DTS VB script:

DTSDestination("k") = DTSSource("TimeCol") + DTSSource("numbercolumn")


Column k is the primary key and defined as float in the DB.

However, doing it like this does this: TimeCol (say, 10:38) +
numbercolumn (say, 238) = 10:38238.

I would like to do something like this Cdbl(DTSSource("TimeCol") ) but
this generates a type mismatch error.

In excel if you put a date in a cell and change the cell format to
number it converts the date to a number (julian date?).

My question is how can I generate a unique key using time and integer?


I could use date part and remove all the colons or slashes, then add
the result but I believe this has the possibility of generating a
non-unique key.

Also I'm importing large amounts of data and don't want to add a
processor intensive amount of code in the dts package.

Any suggestions would be appreciated.

-David



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.