Question: Need help knowing if the following is possible.

I am uploading supplies for new teachers. When a teacher is new, they can either use default supplies already in our system or they can send in a .csv file for custom supplies.

I have a script written to upload the .csv file and insert it into the DB. And I have a script for just inserting records for the new teacher if they are using our default values. I am wondering if these 2 scripts can be combined.

So, if the file exists in my @FPath, I would like to upload it into my #T table. If it doesn't exist, I want to insert the default values into my temp #T table.

I am familiar with IF THEN ELSE and I'm thinking that's what I'd use, but I don't know how to tell it to check if a file exists.

Here's what I have currently:

DECLARE
 @Query Varchar(2000),
 @TeacherKey Varchar(10) = 1234,
 @FPath Varchar(100) = 'FilePath\_1234.csv'

CREATE TABLE #T ( 
 SupplyName Varchar(50),
 PkgQuantity Varchar(5),
 Price Varchar(9))

-- If file exists, I want to upload it (IF @FPath exists THEN)

SELECT @Query = '
BULK INSERT #T 
 FROM ''' + @FPath + '''
 WITH
 (FIELDTERMINATOR ='','',
 ROWTERMINATOR = ''\n'',
 FIRSTROW = 2
 )'
EXEC (@Query) 

-- Otherwise I will use default values already in the DB (ELSE)

INSERT #T ( 
 SupplyName,
 PkgQuantity,
 Price)
SELECT SupplyName, PkgQty, Price
 FROM Supply
WHERE TeacherKey = 1111

Any help or guidance is much appreciated! Thanks!!

Answer: 
You need to remove the existing link before you create it:

```
ddd :
        @mkdir -p /full/path_new/to/new_dir
        @rm -f /full/path_new/to/new_dir/private
        @ln -fs /full/path_old/to/old_dir/private /full/path_new/to/new_dir/private

```
Assuming a clean slate, the proper way to do this would be to create a target which knows which dependency it is creating, and avoid creating it if it alread exists.

```
ddd: /full/path_new/to/new_dir/private
/full/path_new/to/new_dir/private:
    mkdir -p /full/path_new/to/new_dir
    ln -s /full/path/to/old_dir/private /full/path_new/to/new_dir

```