将备份文件放在以当前时间为命名的文件夹,如果不存在就创建。declare   @path   nvarchar(1000)
declare @execSql nvarchar(1000)  set @path='C:\智能封印管理系统数据'+RTRIM(convert(char(10),getdate(),112))+'\完全备份'+convert(char(10),getdate(),112) 
print @path
  insert tempName   exec   master..xp_fileexist   @path   
  if  not exists(select   *   from   tempName   where   b=1)   
  
  set @execSql = 'mkdir '+ @path + ''
  ExEc xp_cmdshell @execSql
文件创建不出来,C盘没反应。

解决方案 »

  1.   

    set @execSql = 'md '+ @path + ''
      

  2.   

    declare   @path   nvarchar(1000)
    declare @execSql nvarchar(1000)
    set @path='c:\智能封印管理系统数据'+RTRIM(convert(char(10),getdate(),112))+'\完全备份'+convert(char(10),getdate(),112) 
    print @path  
    declare @te table (id1 int,id2 int,id3 int)
    insert @te   exec   master..xp_fileexist  @path   
    if  not exists(select   *   from   @te   where   id1=1)   
    set @execSql = 'mkdir '+ @path + ''
    ExEc xp_cmdshell @execSql我这测试正常
      

  3.   

    select 'C:\智能封印管理系统数据'+RTRIM(convert(char(10),getdate(),112))+'\完全备份'+convert(char(10),getdate(),112) C:\智能封印管理系统数据20100810\完全备份20100810  (1 行受影响)