Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if text file exists in stored procedure 1

Status
Not open for further replies.

ssmat

MIS
Jul 11, 2002
5
US
Hello All,

I have a stored procedure that uses a bulk insert to insert records into a table from a dynamically produced text file name.

SET @FileName = "\\server\frompack\WT" + @MachineCounter + @MonthCounter + @DayCounter + ".txt"

Select @SQL = 'Bulk Insert #Temp '
Select @SQL = @SQL + 'From "' + @FileName + '"'
Select @SQL = @SQL + 'With ( FIELDTERMINATOR = "," , ROWTERMINATOR = "\n" , KEEPNULLS )'

Exec (@SQL)

The problem is... how do verify that the text file exists before I execute the bulk insert?

Any help would be appreciated,
ssmat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top