dbTalk Databases Forums  

Using DTS to automatically increment the primary key of the table

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


Discuss Using DTS to automatically increment the primary key of the table in the microsoft.public.sqlserver.dts forum.



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

Default Using DTS to automatically increment the primary key of the table - 06-14-2004 , 07:02 AM






I am totally new to SQL Server so apologies if this seems a silly question. I am trying to schedule a daily import from a csv file into an application that runs on SQL server. I can create a DTS package to do this but the main problem is the primary key of the table is a surrogate key that automatically increments. I cannot import a csv file without supplying a memberID(primary key). I can supply a memberID in the base csv file if I know the next number but this is not always possible as multiple sources can insert a new row into the table. If I use SQL to insert a new row into the SQL Server db (by using SQL Query Analyzer) the database will automatically increment a memberID and the value does not need to be supplied. DTS seems to be the easiest way to schedule a daily import but I cannot seem to get around the auto incrementing primary key issue. All feedback is welcome & sorry for being the annoying novice!

Reply With Quote
  #2  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: Using DTS to automatically increment the primary key of the table - 06-14-2004 , 07:32 AM






Claire,

Do not map the key column and let it auto-increment.

Ilya

"Claire" <Claire (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am totally new to SQL Server so apologies if this seems a silly
question. I am trying to schedule a daily import from a csv file into an
application that runs on SQL server. I can create a DTS package to do this
but the main problem is the primary key of the table is a surrogate key that
automatically increments. I cannot import a csv file without supplying a
memberID(primary key). I can supply a memberID in the base csv file if I
know the next number but this is not always possible as multiple sources can
insert a new row into the table. If I use SQL to insert a new row into the
SQL Server db (by using SQL Query Analyzer) the database will automatically
increment a memberID and the value does not need to be supplied. DTS seems
to be the easiest way to schedule a daily import but I cannot seem to get
around the auto incrementing primary key issue. All feedback is welcome &
sorry for being the annoying novice!




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

Default Re: Using DTS to automatically increment the primary key of the table - 06-14-2004 , 07:42 AM



Have a look at this article: It will help you get around some of the issues
you may encounter.

Problems With IDENTITY() and the DataPump task.
(http://www.sqldts.com/default.aspx?293)

--

----------------------------

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


"Claire" <Claire (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am totally new to SQL Server so apologies if this seems a silly
question. I am trying to schedule a daily import from a csv file into an
application that runs on SQL server. I can create a DTS package to do this
but the main problem is the primary key of the table is a surrogate key that
automatically increments. I cannot import a csv file without supplying a
memberID(primary key). I can supply a memberID in the base csv file if I
know the next number but this is not always possible as multiple sources can
insert a new row into the table. If I use SQL to insert a new row into the
SQL Server db (by using SQL Query Analyzer) the database will automatically
increment a memberID and the value does not need to be supplied. DTS seems
to be the easiest way to schedule a daily import but I cannot seem to get
around the auto incrementing primary key issue. All feedback is welcome &
sorry for being the annoying novice!




Reply With Quote
  #4  
Old   
Claire
 
Posts: n/a

Default Re: Using DTS to automatically increment the primary key of the ta - 06-15-2004 , 06:07 AM



Thanks Allan,

Only noticing while replying that you were the author of the excellent document you referred me to. This explained exactly the problem I was experiencing. I followed your document & can now get SQL Server to auto increment my identity/primary key column. Thanks very mcuh for your help.

Regards,

Claire

"Allan Mitchell" wrote:

Quote:
Have a look at this article: It will help you get around some of the issues
you may encounter.

Problems With IDENTITY() and the DataPump task.
(http://www.sqldts.com/default.aspx?293)

--

----------------------------

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


"Claire" <Claire (AT) discussions (DOT) microsoft.com> wrote in message
news:62B77064-0B31-421B-AA04-5B7510D031C1 (AT) microsoft (DOT) com...
I am totally new to SQL Server so apologies if this seems a silly
question. I am trying to schedule a daily import from a csv file into an
application that runs on SQL server. I can create a DTS package to do this
but the main problem is the primary key of the table is a surrogate key that
automatically increments. I cannot import a csv file without supplying a
memberID(primary key). I can supply a memberID in the base csv file if I
know the next number but this is not always possible as multiple sources can
insert a new row into the table. If I use SQL to insert a new row into the
SQL Server db (by using SQL Query Analyzer) the database will automatically
increment a memberID and the value does not need to be supplied. DTS seems
to be the easiest way to schedule a daily import but I cannot seem to get
around the auto incrementing primary key issue. All feedback is welcome &
sorry for being the annoying novice!




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.