I tried to create an stored procedure in a remote server using this way
EXECUTE (N'USE [master]; EXEC sp_executesql N'+ @sqlCommand) AT [LinkedServer]
However I received this error
Msg 111, Level 15, State 1, Procedure StoredProcedure, Line 5 [Batch Start Line 0] 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
in the sqlCommand has the query similar this
SET @sqlCommand = '
CREATE OR ALTER PROCEDURE [dbo].[storedName]
@nameDB varchar(50)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @SQLProcessesRep varchar(max);
--Actions in Stored
END'