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.
| Author |
Topic |
|
MuadDBA
628 Posts |
Posted - 2003-02-12 : 15:17:53
|
| I am writing a one-time SP that uses some cursors to page through my drives to try to find some files and then update a table with the file paths.I am using 3 cursors:One for the Drive LetterOne for the FolderOne for the File NameThe object is to page through the drive letters, by folder, until the file is found (ie successful run of xp_getfiledetails) and put that file and path in a table. My problem is how to manage the multiple cursors?@@Fetch_Status will only return the status of the most recent cursor, but I don't want my while loops to drop out completely once I run out of folders (ie the file does not exist) to search through. @@cursor_Rows doesn't work on dynamic cursors, which is what I am using to store all the drive letters, folders, and file names, and CURSOR_STATUS is pretty useless on dynamic cursors as well.Can someone help me? My initial plan was to do something like this:While (filename_cursor fetch is successful) fetch first from driveletter_cursor While (driveletter_cursor fetch successful and found_flag = false) fetch first from folder_cursor While (folder_cursor fetch successful and found_flad = false) look for filename on driveletter in folder if found set found_flag = true else fetch next from folder_cursor end while fetch next from driveletter_cursor end whilefetch next from filename_cursorend whileEdited by - crazyjoe on 02/12/2003 15:21:21 |
|
|
ojn.
Starting Member
10 Posts |
Posted - 2003-02-21 : 02:39:11
|
| The easiest way is to use 'dir /s ' dos command to locate the file on a particular drive.e.g.exec master..xp_cmdshell 'dir c:\myfile.txt /s'---ojwww.rac4sql.net |
 |
|
|
|
|
|