dbTalk Databases Forums  

increament primary key when reading each line of text

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


Discuss increament primary key when reading each line of text in the microsoft.public.sqlserver.dts forum.



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

Default increament primary key when reading each line of text - 04-29-2005 , 01:46 PM






Hello,
I have a text file that needs to be read into SQL. I can read the file
alright, but I have problems adding a primary key to the SQL table and make
it increament automatically. If I read the text file into a new table, the
primary key is not created. If I created an empty table and added a primary
key at the beginnin of the file, I got an error message and the import just
quit. Can anyone guide me on this?


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

Default Re: increament primary key when reading each line of text - 04-30-2005 , 01:19 AM






And what is the error. If you add a primary key column with IDENTITY then make sure you do not point your source columns to this
column in the destination

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.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


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

Quote:
Hello,
I have a text file that needs to be read into SQL. I can read the file
alright, but I have problems adding a primary key to the SQL table and make
it increament automatically. If I read the text file into a new table, the
primary key is not created. If I created an empty table and added a primary
key at the beginnin of the file, I got an error message and the import just
quit. Can anyone guide me on this?




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

Default Re: increament primary key when reading each line of text - 05-02-2005 , 08:59 AM



Thank you Allan.

I created a table first. It had only two fields: recordid, and maintext.
In the data structure, recordid's "identy" was set to "Yes" and increament
"1". Now I went to "Import", select my source file and destination file (the
table just created). In the "transform" section, under "Column Mapping", for
the recordid in the destination file, I selected "<ignore>", which I thought
it would not try to get it from the source file. The next line I mapped the
only column in hte text file to the destination file column "maintext".

Whe I started the transfer, I got an error message saying: "Integrity
violation; attempt to insert Null data or data which violates constraints."
It is true that in the source file there are lines with no data. I have made
in hte structure of column "maintext" to allow null. But apparently the
transfer does not agree with theh data structure. I can try to delete all
the null lines (empty lines) in my source file, but will be tedious.

Any suggestions? Thanks.
"Allan Mitchell" wrote:

Quote:
And what is the error. If you add a primary key column with IDENTITY then make sure you do not point your source columns to this
column in the destination

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.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


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

Hello,
I have a text file that needs to be read into SQL. I can read the file
alright, but I have problems adding a primary key to the SQL table and make
it increament automatically. If I read the text file into a new table, the
primary key is not created. If I created an empty table and added a primary
key at the beginnin of the file, I got an error message and the import just
quit. Can anyone guide me on this?





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.