Here is a sample solution:
/** Table to hold GPS data **/
CREATE TABLE Pings (
RowID INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
PingDate DATETIME,
Lat FLOAT,
Long FLOAT
)
/** View for bulk insert **/
CREATE VIEW V_Pings AS
SELECT
PingDate,
Lat,
Long
FROM Pings
The GPS data comes from a pipe-delimited file > C:\GPS\Pings
2010/01/01 00:00:00|30.1|50.1
2010/01/01 00:00:01|30.1|50.2
2010/01/01 00:00:02|30.1|50.3
2010/01/01 00:00:03|30.1|50.4
2010/01/01 00:00:04|30.1|50.5
You have a stored procedure which is being called intermittently via SQL Agent:
CREATE PROCEDURE usp_LoadPings AS
DECLARE
@firstRow INT,
@sql NVARCHAR(1000)
SELECT TOP 1 @firstRow = RowID + 1
FROM Pings ORDER BY RowID DESC
SET @sql = N'
BULK INSERT V_Pings
FROM ''C:\GPS\Pings.txt''
WITH (
FIELDTERMINATOR =''|'',
ROWTERMINATOR =''\n'',
FIRSTROW = ' + CAST(@firstRow AS NVARCHAR(50)) + '
)'
EXEC(@sql)
The stored procedure will not load data unless there is a new set of rows starting after the last row loaded in the table.
I realize this simply looks like an implementation of devmake's answer but I actually created it separately. That said, I upvoted his answer since he posted his first.