all groups > sql server dts > april 2005 >
You're in the

sql server dts

group:

increament primary key when reading each line of text


increament primary key when reading each line of text pelican
4/29/2005 11:46:06 AM
sql server dts:
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?
Re: increament primary key when reading each line of text Allan Mitchell
4/30/2005 12:00:00 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


[quoted text, click to view]

Re: increament primary key when reading each line of text pelican
5/2/2005 6:59:33 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.
[quoted text, click to view]
AddThis Social Bookmark Button