Here is an example solution:
CREATE TABLE Pings ( RowID INT NOT NULL IDENTITY(1,1) PRIMARY KEY, PingDate DATETIME, Lat FLOAT, Long FLOAT ) CREATE VIEW V_Pings AS SELECT PingDate, Lat, Long FROM Pings
GPS data comes from a channel 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 that interrupts through 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)
A stored procedure does not load data if there is no new rowset, starting with the last row loaded into the table.
I understand that this is just like implementing a devmake response, but I really created it separately. However, I supported his answer, since he published his first.
source share