Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 help in executing xp_cmdshell

Author  Topic 

ruchirj07
Starting Member

37 Posts

Posted - 2008-02-06 : 07:15:36
Hi,

I'm having the problem in executing the command master ..xp_cmdshell with the variable

ex.

declare @cmd varchar(500)

set @cmd = 'http://google.com'

exec master ..xp_cmdshell pathoftheexecutable + @cmd

this is giving me an error.

Can anybody let me know how to execute this command with variables.

Ruchir

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-06 : 07:21:05
You have to use dynamic sql i guess
Go to Top of Page

ruchirj07
Starting Member

37 Posts

Posted - 2008-02-06 : 07:27:22
Dynamic sql is also not working!!!!
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-02-06 : 07:46:51
What is pathoftheexecutable?

Build the string before the exec line, also master ..xp is wrong, there should be no space.



declare @cmd varchar(500)

set @cmd = pathoftheexecutable + 'http://google.com'

exec master..xp_cmdshell @cmd

Go to Top of Page
   

- Advertisement -