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 |
jbon
Starting Member
20 Posts |
Posted - 2009-05-31 : 17:00:16
|
Hi, how to import a csv file into sql server 2008 using SQL Server Mgmt Studio? The CSV file is structured into different rows, differentiated with a different number for each row type. Each row type will be imported into different tables. Therefore import process must check the initial number and put this rows information into the right table. Can I do this via SQL Mgmt Studio in a simple/standard process/script or do I need to write a dedicated application for this? All ideas/answers/recommendations are very much appreciated! Thx in advance. |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-06-01 : 05:00:14
|
Suggestion:Import the data into a staging table and then have a stored proc insert into the real tables based on the column that tells you which table to go to.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
jbon
Starting Member
20 Posts |
Posted - 2009-06-01 : 05:26:28
|
Kindly, explain more in detail what you mean with a staging table? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-01 : 05:36:26
|
A staging table is a table to temporary hold the data for further processing, it may not necessary be a temp table.What Charlie suggests is 1. to create a staging table with single column and import the CSV file into the staging table.2. use a Stored procedure to parse (extract) the CSV value and insert into your actual tableyou may reference here for string parsing functionhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033 KH[spoiler]Time is always against us[/spoiler] |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-06-01 : 07:28:37
|
Exactly,sorry -- maybe I should have explained it a little better!Cheers khtanCharlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|