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 2000 Forums
 SQL Server Development (2000)
 Error Using xp_cmdshell in Query

Author  Topic 

Pezamystik
Starting Member

8 Posts

Posted - 2000-11-29 : 13:21:44
I am getting 'Message 2812, Level 16, State 4' when I try to run the query below. I am currently running SQL Server version 6.50.409 on Windows NT Version 4.0, Service Pack 4. The procedure xp_cmdshell is owned by the dbo and I am connected as the sa. I believe I made an error in the usage of the apostrophe's.

USE master
SET NOCOUNT ON
DECLARE
@pc int,
@cmd char(32)
SELECT @pc = 1

WHILE @pc < 25
BEGIN
SELECT @cmd = RTRIM ('xp_cmdshell ' + '''ping servername' + RTRIM (CONVERT (char(2), @pc)) + 'a' + '''')
EXEC @cmd
SELECT @pc = @pc + 1
END

The purpose of this query is to ping the servers on one side of a duplexed network. Any help that can be offered is greatly appreciated. Have a Groovy Day!!!

   

- Advertisement -