-- 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 procp3 go create PROCEDURE ProcP3 -- Add the parameters for the stored procedure here @provaID varchar(10), @cnnStr nvarchar(200) AS BEGIN SET NOCOUNT ON; declare @delCmd varchar (max); declare @str varchar(max); select @str = 'SELECT destino, comando FROM Pendente where destino not like ''''+%'''' and modoSaida =7 and provaid=' + @provaID ; select @delCmd = 'delete FROM Pendente where destino not like ''''+%'''' and provaid=' + @provaID ; exec ('INSERT into pendente Select * from OPENROWSET(''SQLNCLI'',''' + @cnnStr + ''',''' + @str + ''') AS a;') exec ('delete from OPENROWSET(''SQLNCLI'',''' + @cnnStr + ''',''' + @str + ''');') END GO