Have several text files that have over 125,000 records. Many of the records have duplicate sales amounts.
Currently creating T-SQL scripts to bulk insert the text files into several Sql Server 2012 table.
For example, the text files are in a format similar to;
Initially, I was planning to setup a primary key on the field "AcctNo."
However, although the AcctNo is a unique number, there should be one record per product.
Is it possible to utilize T-SQL bulk insert to reformat the data so that the following is displayed?
If this is not possible, then, maybe the deletion of all records after the first one may be considered...
My thought is that this is a sort of un-pivot within T-SQL...
Any insight as to if this is possible and/or feasible?
It is not possible to alter the setup of the text file from the source department whereby the data is normalized - with one
record per product. Have already tried numerous times without much success... Therefore, I have to work with the text files as is.
Thanks in advance.
Currently creating T-SQL scripts to bulk insert the text files into several Sql Server 2012 table.
For example, the text files are in a format similar to;
Code:
AcctNo Product SalesAmount
1002575 Green Widgets_Part B $10.00
1002516 Green Widgets_Part B $10.00
1002446 Blue Widgets_Part A $25.00
1002447 Blue Widgets_Part A $25.00
1002448 Blue Widgets_Part A $25.00
Initially, I was planning to setup a primary key on the field "AcctNo."
However, although the AcctNo is a unique number, there should be one record per product.
Is it possible to utilize T-SQL bulk insert to reformat the data so that the following is displayed?
If this is not possible, then, maybe the deletion of all records after the first one may be considered...
Code:
AcctNo1 AcctNo2 AcctNo3 Product SalesAmount
1002575 1002516 Green Widgets_Part B $10.00
1002446 1002447 1002448 Green Widgets_Part A $25.00
My thought is that this is a sort of un-pivot within T-SQL...
Any insight as to if this is possible and/or feasible?
It is not possible to alter the setup of the text file from the source department whereby the data is normalized - with one
record per product. Have already tried numerous times without much success... Therefore, I have to work with the text files as is.
Thanks in advance.