dbTalk Databases Forums  

Setting Primary Keys on tables

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


Discuss Setting Primary Keys on tables in the microsoft.public.sqlserver.dts forum.



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

Default Setting Primary Keys on tables - 04-18-2005 , 02:16 PM






Hi:

I am pumping data from a Sybase database into SQL Server that will be
run daily. I am trying to set a composite Primary Key on the
destination table. In this table, it is made unique by a combination of
these Three fields:

AgentDateTime
AgentLogin
SupervisorLogin

For example, if during a certain time period an agent had two
supervisors, there will be 2 records. The SupervisorLogin refers to the
AgentLogin of the supervisor.

Problem is, there is data for Supervisors who do not have supervisors
above them, and in this case their SupervisorLogin is null. So I cannot
use a nullable field as a primary key. However, a combination of this
supervisor's login, a particular datetime, and a null value makes the
record unique.

So I think what I need to do here is set this null value to a non null
value during the data pump from Sybase to SQL Server, something like
<top level supervisor> or something like that. Right now I am just
doing a select * from each of the Sybase tables (actualy building in a
where clause dyanmically through an ActiveX Script task for the date).
What is the best way to accomplish this?>

Thanks,
Kayda


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

Default Re: Setting Primary Keys on tables - 04-18-2005 , 02:28 PM






If the source was SQL Server I would advise you to do this in the SourceSQLStatement something like

ISNULL(SupervisorLogin,'No Login Specified') as SupervisorLogin

In Sybase you may or may not have that function (not a Sybase guy).

Short of that you could check the value in an Active X transform and substitute the value you want.



--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


"kayda" <tabladude (AT) gmail (DOT) com> wrote

Quote:
Hi:

I am pumping data from a Sybase database into SQL Server that will be
run daily. I am trying to set a composite Primary Key on the
destination table. In this table, it is made unique by a combination of
these Three fields:

AgentDateTime
AgentLogin
SupervisorLogin

For example, if during a certain time period an agent had two
supervisors, there will be 2 records. The SupervisorLogin refers to the
AgentLogin of the supervisor.

Problem is, there is data for Supervisors who do not have supervisors
above them, and in this case their SupervisorLogin is null. So I cannot
use a nullable field as a primary key. However, a combination of this
supervisor's login, a particular datetime, and a null value makes the
record unique.

So I think what I need to do here is set this null value to a non null
value during the data pump from Sybase to SQL Server, something like
top level supervisor> or something like that. Right now I am just
doing a select * from each of the Sybase tables (actualy building in a
where clause dyanmically through an ActiveX Script task for the date).
What is the best way to accomplish this?

Thanks,
Kayda




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.