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 |
boogy
Starting Member
4 Posts |
Posted - 2007-06-24 : 05:00:58
|
I need to delete the empty subfolders under my "uploads" folderhow can i perform that using triggersi need to delete old records in database and the folders associated with them, i've used triggers to delete the records before 180 days, but i don't know how to remove the folders associated with each folder.note:name of folders is the same as record numberis that possible? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-24 : 05:24:31
|
it is not advisable to do this within triggers. You should do this from the application or if you want to do it via T-SQL stored procedure, use the xp_cmdshell function KH[spoiler]Time is always against us[/spoiler] |
|
|
boogy
Starting Member
4 Posts |
Posted - 2007-06-24 : 08:09:36
|
Thanks, i will try it |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-06-24 : 13:41:44
|
Why don't set scheduled sql job to delete old rows? Much efficiency than trigger. |
|
|
m.abh
Starting Member
3 Posts |
Posted - 2007-06-25 : 04:51:16
|
i make the stored procedure that delete the directory and call it from Trigger , but it not delete the Directory, but whene you call the stored procedure from SQL Query Analyzer it Done and Delete the Directory , if any one can help me, please. |
|
|
m.abh
Starting Member
3 Posts |
Posted - 2007-06-25 : 09:06:59
|
the problem is the Premission , how i can get the premission to user of dataBase to execute xp_cmdshell |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-25 : 11:03:08
|
Why do you want this to be done in TRIGGER ? KH[spoiler]Time is always against us[/spoiler] |
|
|
m.abh
Starting Member
3 Posts |
Posted - 2007-06-25 : 11:54:52
|
i make this stored procedure CREATE PROCEDURE [dscwebworks].[DelDirectory] @IssueID varchar(100) ,@Result int=0ASDeclare @command varchar(500)select @command='EXEC master.dbo.xp_cmdshell'+'"rmdir /s/Q C:\Inetpub\wwwroot\DSCWEBWORKS\UPLOADS\Issues\'+@IssueID+'", no_output'EXEC (@command)GObut the command not execute , and when you go to SQL Query Analyzer and connect by user dscwebworks and call this stored Procedure you get the Message:xpsql.cpp: Error 1326 from LogonUserW on line 488 |
|
|
|
|
|
|
|