• Not sure it matters but i noticed the following mismatch, NVARCHAR(MAX) for images and VARCHAR(12) for current_image

    declare @images nvarchar(max)

    set @images = ''''

    declare @current_image varchar(12)

    The other issue i see is the use of global temp tables (##Temp) vs local temp tables (#Temp), If there are multiple instances of this proc running you will get a race condition where each proc is deleting from the same table as they run.

    the other question is how are you generating your hard coded list? Are you running the loop to build @images and then returning the variable to the screen (SELECT @images)?

    It is a weird issue. the other thing to do is to remove the entry for the offending file and then seeing if it would run using @images or if it errors on a different file at the same place in the string as the "Bad" file.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]