set @data_2ago='Y:\'+'BACKUP_'+convert(varchar(10),getdate()-5,112)+'.bak' if file(@data_2ago)
set @cmd = 'del '+ @data_5ago
exec master..xp_cmdshell @cmd
end if以上 if file(@data_2ago) 语句不行,请教高手如何做呢? 请指教,谢谢!
set @cmd = 'del '+ @data_5ago
exec master..xp_cmdshell @cmd
end if以上 if file(@data_2ago) 语句不行,请教高手如何做呢? 请指教,谢谢!
SQL 不認吧
2009-09-08 13:24DECLARE
@retval int,
@param1 int
EXECUTE @retval=master..xp_fileexist 'd:\1.csv ', @param1 OUTPUT
IF @param1 = 0
PRINT 'File does not exist! '
ELSE
PRINT 'File exists! 'create proc p_QueryCheckFile
@path nvarchar(1000),
@fname nvarchar(250)
as--检查文件是否已经存在
if right(@path,1)<>'\'
set @path=@path+'\'
if exists (select *
from sysobjects
where type='u'
and
name = 'temp_xp_fileexist')
begin
drop table temp_xp_fileexist
end
create table temp_xp_fileexist(a bit,b bit,c bit)
declare @sql nvarchar(1000)
set @sql=@path+@fname
insert into temp_xp_fileexist
exec master..xp_fileexist @sql
我找到了方法, 谢谢不知名的网友代码