Can you do it in a sproc instead?Insert Into Ledger_Folder exec master..xp_cmdshell 'Dir d:\Data\Tax\SmartStreamExtracts\*.*' SELECT @Result_Count = @@ROWCOUNT, @error_out = @@error If @Error_Out <> 0 BEGIN Select @Error_Loc = 5 Select @Error_Type = 50001 GOTO Load_Ledger_Init_sp_Error END-- select * from ledger_folder Delete From Ledger_Folder_Parsed SELECT @Result_Count = @@ROWCOUNT, @error_out = @@error If @Error_Out <> 0 BEGIN Select @Error_Loc = 6 Select @Error_Type = 50001 GOTO Load_Ledger_Init_sp_Error END Insert Into Ledger_Folder_Parsed (Create_Time, File_Size, File_Name ) Select Convert(datetime,Substring(dir_output,1,8) + ' ' + (Substring(dir_output,11,5) + Case When Substring(dir_output,16,1) = 'a' Then ' AM' Else ' PM' End)) As Create_Time , Convert(Int,LTrim(RTrim(Replace(Substring(dir_output,17,22),',','')))) As File_Size , Substring(dir_output,40,(Len(dir_output)-39)) As File_Name From Ledger_Folder Where Substring(dir_output,1,1) <> ' ' And (Substring(dir_output,1,1) <> ' ' And Substring(dir_output,25,5) <> '<DIR>')
Brett8-)