sql server update table from multiple insert queries without duplication
Posted on 2015-01-19
I have multiple computers that query data to be stored on a central sql server database table.
Each computer can query data that is the same as any of the other computers, but I only want unique data to be stored to the central table.
Each computer first uploads the data to a temp table. A stored procedure is then run to insert only the new data into the main table, it then truncates the temp table so that it doesn't get to be too large.
My problem is that since all the computers are running at the same time the stored procedure can be called at the same time and truncate data that hasn't been inserted yet. Is there a way to lock the stored procedure for each computer as it is called?