
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		SafetyRally
-- Create date: 
-- Description:	
-- =============================================
drop procedure ProcSyncParticipacao
go
create PROCEDURE ProcSyncParticipacao 
	-- Add the parameters for the stored procedure here
	@provaID varchar(10),
	@cnnStr nvarchar(200)
AS
BEGIN
	SET NOCOUNT ON;
	
	delete from participacaoProva

	declare @str varchar(max);
	select @str = 'select P.*, S.unitid from participacaoprova P, safetybox S where P.SafetyBoxId = S.dispositivoid and provaid=' +  @provaID ; 
	
	exec ('INSERT into participacaoprova Select * from OPENROWSET(''SQLNCLI'',''' + @cnnStr + ''',''' +  @str + ''') AS a;')
	
END
GO
