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
 Import data help

Author  Topic 

w1102157
Yak Posting Veteran

80 Posts

Posted - 2012-08-01 : 14:32:15
HI guys

Is there any way i can important data from a flat file and keep the order of the data the same?

The order of the data is odd but i need this order to stay the same in the sql table.

is there any way?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-08-01 : 14:34:00
There is never a reliable order of rows in a table. To get rows in a needed order you have to use ORDER BY in your select statement.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-01 : 14:34:30
yep...you can . just add an identity column in sql table

and you can retrieve it in order you inserted based on identity value generated

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

w1102157
Yak Posting Veteran

80 Posts

Posted - 2012-08-01 : 14:35:11
i cant do that it wont work fro example i import data from a pipe file and the id order is
3
5
7
1
2
6

i need the table to keep it this way :(
Go to Top of Page

w1102157
Yak Posting Veteran

80 Posts

Posted - 2012-08-01 : 14:35:49
visakh how can i do this?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-01 : 16:11:24
quote:
Originally posted by w1102157

visakh how can i do this?



as i suggested dump data onto table with additional identity column and then while retrieving use

ORDER BY ID

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -