I have to import a csv file to my database and then addsome values to other fields based on these values. At present I use astore procedure that does a bulk insert and then I use an update andfetch inside the sql to perform these updates. I am not sure if this isthe best way. Is this bad, since some amount of busniess logic is inthe store procedure?
If it is, how can I do this better?
Thanks for the answer.
Yes, it's fine to do add values in the stored procedure. And if as you say, all the values that need to be added can be computed from existing values in the csv file (or the corresponding table), we can add computed column(s) to the table. Then no extra update is needed. For example, if we import csv file into a table T(firstName varchar(20), LastName varchar(20)), and we want to add a full name column based on the firstName and lastName, we can add a computed column:
alter table T add fullName as firstName+' '+lastName
No comments:
Post a Comment