Select m.MOID, a.DATE, m.NAME, a.RAR, a.ZIP
FROM (SELECT * FROM (SELECT MOID, RAR,null ZIP, DATE FROM MDA
UNION ALL
SELECT MOID, RAR,null ZIP, DATE FROM MDA2)
UNION ALL
(SELECT MOID,null RAR, ZIP, DATE FROM SAS
UNION ALL
SELECT MOID,null RAR, ZIP, DATE FROM SAS2))a
LEFT JOIN ORIGINAL m ON m.MOID = a.MOID;
@ECHO OFF
sc query "Peer" %1 | findstr RUNNING
if %ERRORLEVEL% == 2 goto trouble
if %ERRORLEVEL% == 1 goto stopped
if %ERRORLEVEL% == 0 goto started
echo unknown status
goto end
:trouble
net stop Peer
if %errorlevel% == 2 goto trouble
if %errorlevel% == 0 goto stopped
:started
net stop Peer
if %errorlevel% == 2 goto trouble
if %errorlevel% == 0 goto stopped
:stopped
net start Peer
if %errorlevel% == 2 goto stopped
if %errorlevel% == 0 goto end
:end