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
 General SQL Server Forums
 New to SQL Server Programming
 read local drive in store procedure

Author  Topic 

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2009-07-21 : 00:49:17
hi
how to read local drive in computer in use to store procedure
like C,D,E


thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-07-21 : 00:56:53
You can run CMD commands from xp_cmdshell. For instance: EXEC master.dbo.xp_cmdshell 'dir C:\', but you'll need to enable xp_cmdshell if you are using 2005 or later.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-07-21 : 00:57:20
Here's a quick script to enable xp_cmdshell for >=2005: http://weblogs.sqlteam.com/tarad/archive/2006/09/14/12103.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2009-07-21 : 01:24:01
thank for replay it is useful for my code
but i have read all local drive without specify the name of drive
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-21 : 03:18:50
This should work

EXEC master.dbo.xp_cmdshell 'Dir '

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

amirs
Constraint Violating Yak Guru

260 Posts

Posted - 2009-07-21 : 07:53:27
EXEC master.dbo.xp_cmdshell 'Dir '

this command read only c drive
Go to Top of Page
   

- Advertisement -