Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data importing

Status
Not open for further replies.

cruel

Programmer
Aug 6, 2001
131
Hi, I am new to MS SQL server. I have a csv file sitting on a NT windows (it has all kinds of format, e.g. with % and $ signs), and try to import the data into SQL server database. All data are identified by MS applications as char even though most of them are numeric, integer, money or date. Since the csv file is too big and has a large number of variables, it makes it very inconvenient to manipulate the file. In the SQL script for importing data, I tried to redefine the destination data format accordingly. But importing failed because the source data are strings. I guess I can try import them as char and change data format inside the database. But it will be a very very long sql to write and a big waste of resources. Any suggestions? Appreciate it!
 
I would bcp them all as char fields into a global temp table then insert from there.
You could use a format file or an activex script in dts but these will still force you to code for each field that needs changing.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
I would build a blank table in SQL with all the correct data types then if you use Enterprise manager, just use the import wizard. Make sure to change the destination table from the default one selected to the blank table you just created. This works well.

If you don't use EM, then just use bulk insert to load the new table.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top