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 |
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2009-06-03 : 16:41:08
|
| Hey Guys,Need suggestion on how to tackle this or any existing code is even better.... I will have a table that will have the filename and the field delimeter... first row of the file will have the column names... how can I create I create a table with first row as column name and then load the file in that table?We will have multiple files in the directory at one time; however, the metatable will have the filename and delimeter info.Thanks for the help guys. |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2009-06-04 : 12:14:12
|
| datafile can be as big as 10gb. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-04 : 12:53:29
|
| you can use ssis for this. you require a for each loop to loop through files. then a flat file source and oledb destination to transfer data from file to table. |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2009-06-04 : 13:54:54
|
| I have created the script to load the data into temp table and then use the first row from that temp table to create another table using first row as the column names; loading all data again into second table from row2.... I need to know if we can load only few records from datafile into temp table using bulk insert or any other method using script? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-04 : 14:03:59
|
| yup you can use like:-SELECT TOP 100 fields... FROM OPENDATASOURCE(...) |
 |
|
|
SQLRatankalwa
Starting Member
42 Posts |
Posted - 2009-06-04 : 14:10:21
|
| HiFirst of all, You need to determine the datatype and format of each column. If you know the number of columns in the file, You have to read the first few recods in the file and understand the data type and format of all the columns based on the data sampling performed on the file, based on the data sampling create the table and then upload the data using bcp, which is the fastest way to upload the data.I hope this helpsRatan KalwaSQL Server Professionals User Grouphttp://www.revalsys.com |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2009-06-04 : 14:58:00
|
| Thanks guys...it works. |
 |
|
|
|
|
|