-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXECUTE sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
-- Read Plc Registry
declare @mytab as table(id int identity(1,1),res nvarchar(200))
declare @cmd as nvarchar(max)
set @cmd='exec xp_cmdshell "C:\TcpModbus\TcpModbus read word 192.168.1.23 502 1 22 0"'
insert into @mytab exec(@cmd)
select * from @mytab where res is not null
-- Write Plc Registry
exec xp_cmdshell 'C:\TcpModbus\TcpModbus write word 192.168.1.23 502 1 22 5'