question

shijushaji avatar image
shijushaji asked

Create a stored procedure to upload data from 3 csv files one after other.

Name of the csv file(s) already saved in a table myFileList. myFileList Table contains values like crashData_MMYYYY_vN.csv, vehecleData_MMYYYY_vN.csv, casualtyData_MMYYYY_vN.csv etc with different versions and MMYYYY values. Example: For January month, MM should be 01. For October, it should be 10. For Base version value of ‘N’ should be 1 and can be incremental for the next versions, viz., v2, v3 etc. The first version of a crash file loading for Jan 2013 should be named ‘crashData_012013_v1’. Condition: 1. If crashData_012013_v2 is available no need to consider crashData_012013_v1 ( Same case for 'vehecleData_MMYYYY_vN.csv' and 'casualtyData_MMYYYY_vN.csv') 2. If any of the file(s) is missing no need to insert any data into the table. 3. i need to ensure that only the last 1 calendar month’s data is uploaded. Thanks in advance.
sql-server-2008sql
5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

SirSQL avatar image SirSQL commented ·
Looks like a homework question to me.
1 Like 1 ·
ThomasRushton avatar image ThomasRushton ♦♦ commented ·
What's your question? How far have you got with this? What part of it is causing you trouble? Show us what you've got so far, and maybe we'll be able to point you in the right direction.
0 Likes 0 ·
shijushaji avatar image shijushaji commented ·
if(filename==x) call procedure1 else if (filename==y) call procedure2 else call procedure3 Note :filename is stored in a table. How to do this?
0 Likes 0 ·
ThomasRushton avatar image ThomasRushton ♦♦ commented ·
Is there a theoretical maximum value for N?
0 Likes 0 ·
shijushaji avatar image shijushaji commented ·
Nope.. Where i am stuck is if(filename==x) call procedure1 else if (filename==y) call procedure2 else call procedure3 here
0 Likes 0 ·

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
If you're just having problems with the [`IF`][1] clause... Try something like: IF Condition1 BEGIN EXEC Proc1 END ELSE BEGIN IF Condition2 BEGIN EXEC Proc2 END ELSE BEGIN EXEC Proc3 END END END Note that, because I've only put one statement in the THEN/ELSE parts, the BEGIN/END bits are unnecessary. I've left them in through force of habit - the number of times I've not written them and had something a bit odd happen... [1]: http://msdn.microsoft.com/en-us/library/ms182717.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.