Using While in Stored procedure
Posted on 2004-08-23
I am trying to import a text file to an SQL table.
I would like to check if the text file exists, if it exists, do the import, exit, if not, wait for 5 seconds, check again, and I want to loop through this process 5 times.
Here is my code, but it seems not working. Please help. Thanks
SET @TextFile = 'C:\ClaimsInquiry\Inbox\'+@ProviderNumber+'.Login.txt'
WHILE @t = 6
exec master..xp_fileexist @TextFile, @i out
SET @WriteToDB = "BULK INSERT Inbox_Login FROM @TextFile WITH (FIELDTERMINATOR = ';') "
WAITFOR DELAY '00:00:03'