Mauro Cazabonnet
asked on
SQL XPCMDSHELL SQLCMD
Hi,
I'm trying to run a sqlcmd from sql server1 on remote sql server2
I setup the proxy account
XEC MASTER.dbo.sp_xp_cmdshell_ proxy_acco unt 'domain\user', 'password'
I'm getting the following output
output
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
guest
NULL
(1 rows affected)
NULL
I need it to be dbo
Since I would like to drop a database and whatever else on server2
What am I missing here?
Thanks in advance
I'm trying to run a sqlcmd from sql server1 on remote sql server2
I setup the proxy account
XEC MASTER.dbo.sp_xp_cmdshell_
SET @dbname = 'Vantage'
SET @ReplicaServer = 'Server2'
SET @SQLCMD = 'SQLCMD -S' + @ReplicaServer + ' -Q '
SET @command = 'SELECT CURRENT_USER'
SET @CommandText = @SQLCMD + '"' + @command + '"'
PRINT @CommandText
EXEC MASTER.dbo.Xp_cmdshell @CommandText --Drop database on secondary server
I'm getting the following output
output
--------------------------
guest
NULL
(1 rows affected)
NULL
I need it to be dbo
Since I would like to drop a database and whatever else on server2
What am I missing here?
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.