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
 Transact-SQL (2000)
 Xp_cmdshell

Author  Topic 

svicky9
Posting Yak Master

232 Posts

Posted - 2006-04-22 : 16:50:13
hi guys

I am listing the directories on the windows server 2003 using the Xp_cmdshell

when i execute
<b>xp_cmdshell 'dir \\servername\IT\'</b>

it lists all the files within the directory but it does not list for the folders that contain space in the middle

for eg

<b>xp_cmdshell 'dir \\servername\IT\sql program'</b>

It says the system cannot find the file specified

but when i use start-->run-->\\servername\IT\sql program
it opens the directory

so how do i execute the path in xp_cmdshell

thanks
Vic

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-22 : 17:00:39
try
xp_cmdshell 'dir \\servername\IT\"sql program"\'
or
xp_cmdshell 'dir "\\servername\IT\sql program\"'

Can never remember when the quotes go round the whole string.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

svicky9
Posting Yak Master

232 Posts

Posted - 2006-04-22 : 17:07:33
Thanks

Both the queries worked
Go to Top of Page
   

- Advertisement -