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.
| Author |
Topic |
|
yossibaram
Yak Posting Veteran
82 Posts |
Posted - 2002-12-01 : 11:34:53
|
| Hi,I have a text file contains many rows of data as follows:03 5000189363069 00004.50 00022.50 00001.00 00 03 5000189009233 00008.70 00021.75 00001.93 00 03 4008400102528 00014.99 00074.95 00003.32 00 etc....As you've noticed the delimeter between data is spaces.All I need to do is to copy this text file into a single column of a Staging table.For that i use the following stored procedure:CREATE PROCEDURE Lan_BCP_StagingTable@Filestr nvarchar(256)ASEXEC ('BULK INSERT Staging_Table From ''' +@Filestr + '''')It copies all the data BUT the spaces between data is different from the text file and the location of each data is critical for me.How can i use BCP (its fast and good for me) and to maintaine same number of spaces as in the text file?The above text file is only an example (the original has more data in each row).ThanksYossi |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-12-02 : 04:57:39
|
| If you know how many fields there are in the file and each field is a fixed width then is it not easier to import each seperate field into a different column instead of all into one column? Then you wouldn't need to bother about the spaces because each item would have its own column..-------Moo. |
 |
|
|
yossibaram
Yak Posting Veteran
82 Posts |
Posted - 2002-12-02 : 05:14:18
|
quote: If you know how many fields there are in the file and each field is a fixed width then is it not easier to import each seperate field into a different column instead of all into one column? Then you wouldn't need to bother about the spaces because each item would have its own column..-------Moo.
Yes,The thing is I do not know number of data/fields.All I have is a text file with data seperated with spaces (changeble number between each other) and I need to copy the file as it is to column in a table.All manipulation from there will be on the server side via SP's. Please adviseThanks |
 |
|
|
|
|
|