Hello and thanks for your fast Answers and that you try to Help me!!!
The thing is that I really dont have a primary key or refernece Number and that way I cant normalize my Data.
I give you a better example:
inv_number;vat;amout;deliveryPlace
H;123442;23%;78.99;52000990889
itemDescription;color;qty
L;socks;blue;100
L;socks;red;200
So my raw data comes in that way -->
H;123442;23%;78.99;52000990889
L;socks;blue;100
L;socks;L;red;200
H;123443;23%;500.99;52000990111
L;skirt;blue;100
L;pants;red;200
I want to split my Data and \insert them in two tables. A header table and an item table. The Problem is that I dont have a reference key (not primary.. Sorry!!) and I must first generate one. The only thing that I have is,that the H letter in the First column shows that this raw is the header and the L means thats the Line. The Data comes subquential. That means that the inv_number 123442 has the two items that follow (socks) and the other one has the skirt and pants.
That means I must somehow generate the reference key that shows the relation between the invoice and the items. Its then the primary key for the Header Table and the Foreign Key for the item table.
Example:
222;H;123442;23%;78.99;52000990889
222;L;socks;blue;100
222;L;socks;red;200
223;H;123443;23%;500.99;52000990111
223,L;skirt;blue;100
223,L;pants;red;200
I already have write a simple code in VB. It reads the file in a array string and I generate the ref number in that way -But I am sure there is a better way to do that only with sql. Please help!!! I hope my code here helps to explain the logik.->
------------------------
Dim strFileName() As String
strFileName = IO.File.ReadAllLines(filename, Encoding.GetEncoding(1253))
Dim headerIdent as string = "H"
Dim Num as Integer = 222
For Each myLine In strFileName
If Not myLine = Chr(endCharacter) Then
If myLine.Substring(0, 2) = headerIdent Then
num = num + 1
End If
tempStr &= num.ToString.PadLeft((idLen), "0"c) & myLine.ToString & Environment.NewLine
End If
Next
---------------------------------------
Thank you!!!!:-):-):-)