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
 Formatting Data after bulk copy

Author  Topic 

Firemaple
Starting Member

14 Posts

Posted - 2011-10-04 : 12:44:52
Ok, This is more of a "best practices" type question.

Basically, I am getting a feed of data into a csv file. I built a small C# app to bulkcopy the data to the table. However, this just throws that data in there, I want to reform some of the data to make it cleaner. I can do this in C#, but it take a lot longer than necessary.

Is there a better/quicker way to do this. using triggers or some other sql approach?

Thanks in advance!

Kristen
Test

22859 Posts

Posted - 2011-10-04 : 14:40:23
Our normal way is to use a "staging table". "throw", as you put it!, the CSV data into the staging table, then run one/many update statements to tidy it up, or split the data into additional columns, etc and then once that is done move/"apply" the data to the main tables.

We add an "Error Message" column to the staging table so that any process that wants to mark a row as having a problem can update the Message column with a suitable message (and any row that already has Message IS NOT NULL can be ignored from further processing)
Go to Top of Page
   

- Advertisement -