dbTalk Databases Forums  

Multiple column primary key?

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


Discuss Multiple column primary key? in the microsoft.public.sqlserver.dts forum.



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

Default Multiple column primary key? - 11-04-2003 , 12:38 PM






New to SQL server here, so if this has been asked, apologies in advance.

Using DTS to convert a file, and running into a key problem creating the new
file. The file has a two column primary key, and I'm not sure of the syntax
to set this up as part of the DTS package. Books online says I can do this,
but doesn't provide an example of one such. I know I can go back and set it
manually, but it needs to be done at conversion time. Here's a sample of
what I'm using, rightly or wrongly:

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[aidfile]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[aidfile]

CREATE TABLE [dbo].[aidfile] (
[AID_USER_ID] char (12) primary key,
[AID_USER_PSWD] char (12),
[AID_APP_UNQ_ID] int,

etc etc

The primary key is actually AID_USER_ID + AID_USER_PSWD, but I'm just not
sure of the syntax to make this happen at conversion time.

Can anyone help??

Thanks!
--
Elaine Pack, Web Analyst
Charlottesville, VA
elaineATpackwebs.net



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

Default Re: Multiple column primary key? - 11-04-2003 , 12:47 PM






If you want to create a PK consisting of > 1 column then you have to do this
at the table level so

CREATE TABLE [dbo].[aidfile] (

[AID_USER_ID] char (12) NOT NULL,

[AID_USER_PSWD] char (12) NOT NULL,

[AID_APP_UNQ_ID] int

PRIMARY KEY (AID_USER_ID,AID_USER_PSWD)

)


--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"EPPack" <epack (AT) packwebs (DOT) net> wrote

Quote:
New to SQL server here, so if this has been asked, apologies in advance.

Using DTS to convert a file, and running into a key problem creating the
new
file. The file has a two column primary key, and I'm not sure of the
syntax
to set this up as part of the DTS package. Books online says I can do
this,
but doesn't provide an example of one such. I know I can go back and set
it
manually, but it needs to be done at conversion time. Here's a sample of
what I'm using, rightly or wrongly:

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[aidfile]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[aidfile]

CREATE TABLE [dbo].[aidfile] (
[AID_USER_ID] char (12) primary key,
[AID_USER_PSWD] char (12),
[AID_APP_UNQ_ID] int,

etc etc

The primary key is actually AID_USER_ID + AID_USER_PSWD, but I'm just not
sure of the syntax to make this happen at conversion time.

Can anyone help??

Thanks!
--
Elaine Pack, Web Analyst
Charlottesville, VA
elaineATpackwebs.net





Reply With Quote
  #3  
Old   
EPPack
 
Posts: n/a

Default Re: Multiple column primary key? - 11-04-2003 , 01:07 PM



Worked like a champ, Allan! Many thanks!

elaine
--
Elaine Pack, Web Analyst
Charlottesville, VA
elaineATpackwebs.net

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
If you want to create a PK consisting of > 1 column then you have to do
this
at the table level so

CREATE TABLE [dbo].[aidfile] (

[AID_USER_ID] char (12) NOT NULL,

[AID_USER_PSWD] char (12) NOT NULL,

[AID_APP_UNQ_ID] int

PRIMARY KEY (AID_USER_ID,AID_USER_PSWD)

)


--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"EPPack" <epack (AT) packwebs (DOT) net> wrote in message
news:e4xTWLwoDHA.2444 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
New to SQL server here, so if this has been asked, apologies in advance.

Using DTS to convert a file, and running into a key problem creating the
new
file. The file has a two column primary key, and I'm not sure of the
syntax
to set this up as part of the DTS package. Books online says I can do
this,
but doesn't provide an example of one such. I know I can go back and set
it
manually, but it needs to be done at conversion time. Here's a sample of
what I'm using, rightly or wrongly:

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[aidfile]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[aidfile]

CREATE TABLE [dbo].[aidfile] (
[AID_USER_ID] char (12) primary key,
[AID_USER_PSWD] char (12),
[AID_APP_UNQ_ID] int,

etc etc

The primary key is actually AID_USER_ID + AID_USER_PSWD, but I'm just
not
sure of the syntax to make this happen at conversion time.

Can anyone help??

Thanks!
--
Elaine Pack, Web Analyst
Charlottesville, VA
elaineATpackwebs.net







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.