Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 BCP Import changes the order

Author  Topic 

Peter01
Starting Member

16 Posts

Posted - 2014-08-13 : 20:06:36
Hello,
I am trying to BCP IN a flat file that must maintain the sequence that is within the file. For an example, row 1 in the flat file must be in row 1 of the table.

At present BCP is changing the order.
Can I do this?
Thanks,
Peter

Ifor
Aged Yak Warrior

700 Posts

Posted - 2014-08-14 : 07:00:57
A relation (table, view etc) is an UNORDERED set.

If you need the order of the flat file you will have to add a LineNumber column to the source. You will then be able to get the original order in SQL by:

SELECT *
FROM ImportedTable
ORDER BY LineNumber
Go to Top of Page

Peter01
Starting Member

16 Posts

Posted - 2014-08-16 : 18:01:14
Hi,
I have added a line number to the source.
many thanks,
Peter
Go to Top of Page
   

- Advertisement -