Using xp_cmpshell with variable in SQL Server -
i want use xp_cmdshell
ping servers. created procedure have little problem, need select server ip table created.
i created cursor server ip table don't know how use @ip varchar
variable ping command.
this syntax didn't work:
execute xp_cmdshell 'ping @ip'
you cannot reference parameters directly within xp_cmdshell, have concatenate value when creating command. recommend reading: https://msdn.microsoft.com/en-us/library/ms175046.aspx
in example, like:
declare @cmd nvarchar(4000); set @cmd = 'ping ' + @ip; exec xp_cmdshell @cmd;
Comments
Post a Comment