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 |
zero1de
Posting Yak Master
105 Posts |
Posted - 2014-08-21 : 04:25:33
|
I get the Procedure not to run, can somebody help me to get run the SP ?USE [DWData];GOSET ANSI_NULLS ON;GOSET QUOTED_IDENTIFIER ON;ALTER PROCEDURE usp_Qualco_Delete_Attachments(@SourceDir varchar(1024), @SourceFile varchar(512))AS DECLARE @SourceDirFOR varchar(255) ,@FileName varchar(512) ,@DynDelete varchar(512) ,@Error intSET @SourceDirFOR = 'FOR %I IN ("' + @SourceDir + @SourceFile + '") DO @ECHO %~nxtI'SET @Error = 0-- Start temp table population(s).CREATE TABLE #_File_Details_01 (Ident int IDENTITY(1,1) ,Output varchar(512))INSERT INTO #_File_Details_01EXEC master..xp_cmdshell @SourceDirFORCREATE TABLE #_File_Details_02 (Ident int ,[TimeStamp] datetime ,[FileName] varchar(255))INSERT INTO #_File_Details_02 SELECT Ident, CONVERT(char(10), SUBSTRING([Output],1,10), 121) AS [TimeStamp] ,SUBSTRING([Output],21,255) AS [FileName] FROM #_File_Details_01 WHERE [Output] IS NOT NULL ORDER BY Ident-- Start delete ops cursor.DECLARE curDelFile CURSORREAD_ONLYFOR-- I try to check if the File exsist in Table France on Field Abgleich, in this Field is the Filename saved.SELECT [FileName] FROM #_File_Details_02 where [Filename] in (Select abgleich FROM France)OPEN curDelFileFETCH NEXT FROM curDelFile INTO @FileNameWHILE (@@fetch_status <> -1)BEGIN IF (@@fetch_status <> -2) BEGIN SET @DynDelete = 'DEL /Q "' + @SourceDir + @FileName + '"' EXEC master..xp_cmdshell @DynDelete ENDFETCH NEXT FROM curDelFile INTO @FileNameENDCLOSE curDelFileDEALLOCATE curDelFileDROP TABLE #_File_Details_01DROP TABLE #_File_Details_02 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-21 : 07:53:24
|
What error do you get? |
|
|
zero1de
Posting Yak Master
105 Posts |
Posted - 2014-08-21 : 09:09:42
|
Sorry i found the syntax error now but i must check if the logic works :) |
|
|
zero1de
Posting Yak Master
105 Posts |
Posted - 2014-08-21 : 10:15:39
|
The SP is now cleanly compilied. But when i execute sp nothing is deleted? What it the problem?File name = integration Lettre 2 purchase24147_241472012112809504511424147.docDB field Entry = integration Lettre 2 purchase24147_241472012112809504511424147.docquote: Originally posted by gbritton What error do you get?
|
|
|
|
|
|
|
|