x

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.
more ▼

asked Dec 11, 2012 at 09:07 AM in Default

shijushaji gravatar image

shijushaji
0 1 1 2

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.
Dec 11, 2012 at 05:29 PM ThomasRushton ♦
Looks like a homework question to me.
Dec 11, 2012 at 11:35 PM SirSQL

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?
Dec 12, 2012 at 04:29 AM shijushaji
Is there a theoretical maximum value for N?
Dec 12, 2012 at 09:25 AM ThomasRushton ♦

Nope.. Where i am stuck is if(filename==x) call procedure1 else if (filename==y) call procedure2 else call procedure3

here
Dec 12, 2012 at 10:12 AM shijushaji
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

If you're just having problems with the IF 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...

more ▼

answered Dec 12, 2012 at 11:25 AM

ThomasRushton gravatar image

ThomasRushton ♦
33.8k 18 20 44

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1834
x716

asked: Dec 11, 2012 at 09:07 AM

Seen: 636 times

Last Updated: Dec 12, 2012 at 11:27 AM