April 28, 2009 at 6:31 pm
How can i find list of files on a disk sorting by modified date.
April 28, 2009 at 6:48 pm
Do you want to do this from within SQL server...if so, you have options...xp_cmdshell, the undocumented stored procedure master.sys.xp_dirtree (http://www.mssqltips.com/tip.asp?tip=1460), or powershell. I'm currently using xp_cmdshell for this to display some documentation in ssrs, but I think there are some security issues. I will be researching the others. Hopefully this will get you started. I'd like to hear what you settle on...
Bob
April 28, 2009 at 6:54 pm
http://msdn.microsoft.com/en-us/library/aa260689(SQL.80).aspx
EXEC master..xp_cmdshell 'dir /od'
April 29, 2009 at 5:12 am
same way if you want to check existence of file
use xp_fileexists 'path'
April 29, 2009 at 7:56 am
I ran this cmd
exec master.dbo.xp_cmdshell '\\DbStorage\Rev\*.bak'
and gettingthis error though sql server account has full permissions on that folder
The system cannot find the path specified.
actually its a netwrok drive , am not sure if it works on network shared folder.
April 29, 2009 at 8:10 am
By default, xp_cmdshell runs against the operating system as the user that the sql server service runs under. This may or may not be an active directory account. Sometimes the sql server service is set to run as a local machine user. This is probably the case here since it's a network drive. To work around that problem
From BOL:
xp_cmdshell Proxy Account
When it is called by a user that is not a member of the sysadmin fixed server role, xp_cmdshell connects to Windows by using the account name and password stored in the credential named ##xp_cmdshell_proxy_account##. If this proxy credential does not exist, xp_cmdshell will fail.
The proxy account credential can be created by executing sp_xp_cmdshell_proxy_account. As arguments, this stored procedure takes a Windows user name and password. For example, the following command creates a proxy credential for Windows domain user SHIPPING\KobeR that has the Windows password sdfh%dkc93vcMt0.
EXEC sp_xp_cmdshell_proxy_account 'SHIPPING\KobeR','sdfh%dkc93vcMt0'
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply