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

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -