Friday, February 24, 2012

File Operations SQL 2000

I have a directory on our SQL server that contains certain temporay
files that have been generated from another application.
I want to periodically clean this directory up by running an SQL job.
How would I go about this?
Essentially, I just want to delete everything from C:\\application_temp
\ *.*
TIAHi
xp_cmdshel + DEL commanad . Do you rememeber DOS commands?
"pinhead" <dlynes2005@.gmail.com> wrote in message
news:1184843844.787726.12240@.k79g2000hse.googlegroups.com...
>I have a directory on our SQL server that contains certain temporay
> files that have been generated from another application.
> I want to periodically clean this directory up by running an SQL job.
> How would I go about this?
> Essentially, I just want to delete everything from C:\\application_temp
> \ *.*
> TIA
>|||use xp_cmdshell
eg. exec master.dbo.xp_cmdshell 'dir c:\temp\*.sql'|||xp_cmd_shell gives you the ability to perform any os command, such as DEL.
xp_cmd_shell is turned on by default in SQL 2000 but is turned off by
default in SQL 2005 so this might / might not be easy in your case.
xp_dir_tree also lets you traverse a directory to get a list of files (much
better than using xp_cmd_shell + DIR)
In SQL 2005, you can also write a CLR procedure with external access that
can do something similar.
Regards,
Greg Linwood
SQL Server MVP
http://blogs.sqlserver.org.au/blogs/greg_linwood
Benchmark your query performance
http://www.SQLBenchmarkPro.com
"pinhead" <dlynes2005@.gmail.com> wrote in message
news:1184843844.787726.12240@.k79g2000hse.googlegroups.com...
>I have a directory on our SQL server that contains certain temporay
> files that have been generated from another application.
> I want to periodically clean this directory up by running an SQL job.
> How would I go about this?
> Essentially, I just want to delete everything from C:\\application_temp
> \ *.*
> TIA
>|||Hi Greg
Did you mean xp_cmdshell ? I also missed 'l' in my post
"Greg Linwood" <g_linwood@.hotmail.com> wrote in message
news:%23JKwwjfyHHA.4640@.TK2MSFTNGP03.phx.gbl...
> xp_cmd_shell gives you the ability to perform any os command, such as DEL.
> xp_cmd_shell is turned on by default in SQL 2000 but is turned off by
> default in SQL 2005 so this might / might not be easy in your case.
> xp_dir_tree also lets you traverse a directory to get a list of files
> (much better than using xp_cmd_shell + DIR)
> In SQL 2005, you can also write a CLR procedure with external access that
> can do something similar.
> Regards,
> Greg Linwood
> SQL Server MVP
> http://blogs.sqlserver.org.au/blogs/greg_linwood
> Benchmark your query performance
> http://www.SQLBenchmarkPro.com
> "pinhead" <dlynes2005@.gmail.com> wrote in message
> news:1184843844.787726.12240@.k79g2000hse.googlegroups.com...
>>I have a directory on our SQL server that contains certain temporay
>> files that have been generated from another application.
>> I want to periodically clean this directory up by running an SQL job.
>> How would I go about this?
>> Essentially, I just want to delete everything from C:\\application_temp
>> \ *.*
>> TIA
>|||Hi Uri
No - I actually meant xp_dirtree (i had it as xp_dir_tree previously which
wasn't quite correct)..
Regards,
Greg Linwood
SQL Server MVP
http://blogs.sqlserver.org.au/blogs/greg_linwood
Benchmark your query performance
http://www.SQLBenchmarkPro.com
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%23zg%23uoDzHHA.3772@.TK2MSFTNGP06.phx.gbl...
> Hi Greg
> Did you mean xp_cmdshell ? I also missed 'l' in my post
>
> "Greg Linwood" <g_linwood@.hotmail.com> wrote in message
> news:%23JKwwjfyHHA.4640@.TK2MSFTNGP03.phx.gbl...
>> xp_cmd_shell gives you the ability to perform any os command, such as
>> DEL. xp_cmd_shell is turned on by default in SQL 2000 but is turned off
>> by default in SQL 2005 so this might / might not be easy in your case.
>> xp_dir_tree also lets you traverse a directory to get a list of files
>> (much better than using xp_cmd_shell + DIR)
>> In SQL 2005, you can also write a CLR procedure with external access that
>> can do something similar.
>> Regards,
>> Greg Linwood
>> SQL Server MVP
>> http://blogs.sqlserver.org.au/blogs/greg_linwood
>> Benchmark your query performance
>> http://www.SQLBenchmarkPro.com
>> "pinhead" <dlynes2005@.gmail.com> wrote in message
>> news:1184843844.787726.12240@.k79g2000hse.googlegroups.com...
>>I have a directory on our SQL server that contains certain temporay
>> files that have been generated from another application.
>> I want to periodically clean this directory up by running an SQL job.
>> How would I go about this?
>> Essentially, I just want to delete everything from C:\\application_temp
>> \ *.*
>> TIA
>>
>

No comments:

Post a Comment