Wrox Programmer Forums
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2008, 08:20 AM
Authorized User
 
Join Date: Dec 2006
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default XP shell commands...

Hi,

I need a code which should look for the particular folder (d:\test)
and find out the COUNT of the files (not the directory), if it has >= 3 files, the system should compare with my predefined date, something 2008-07-09 with the filedates and accordingly i should process...further.

So is there any way in TSQL where i can find out the count of the files and compare predefined date with the file date in the archive folder (predefined > filedate)



Thanks,
Chandra
__________________
Thanks,
Chandra
 
Old July 24th, 2008, 11:16 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is there a reason you are looking to do this in SQL? This is not such a SQL friendly task. Sure, it could probably be done, but it seems like the wrong tool for the job. You could create some .NET code that does this and make it a SQL CLR stored procedure if you really want to "run" it from SQL. Otherwise, use a better tool such as a command line app.

-Peter
compiledthoughts.com
 
Old July 24th, 2008, 06:21 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

So, if you're using xp_CmdShell already, by not use DIR with the /s option to find the diretory. Then use master.dbo.xp_Dirtree 'directoryname',1,1 to examine the file names.

--Jeff Moden





Similar Threads
Thread Thread Starter Forum Replies Last Post
ABOUT AT COMMANDS bobwith5 Visual Basic 2005 Basics 1 October 31st, 2007 02:25 PM
Help-Implementing a unix shell to run commands ssimkhan Java Basics 1 June 15th, 2007 06:43 AM
Help-Implementing a unix shell to run commands ssimkhan Pro Java 0 June 7th, 2007 04:58 AM
Using 2 SQL commands attipa Classic ASP Databases 2 September 20th, 2003 05:23 PM
SendKey commands charlie3 VBScript 1 July 6th, 2003 02:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.