raise error

  • Can any

  • Some questions...

    1. Does this proc compile?

    2. You have a ROLLBACK TRANSACTION but no begin or commit tran? Can you explain?

    3. You are trying to create a table in your sproc? Why?

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • If @File_Exists=1

      BEGIN

     TRUNCATE TABLE SIRSInput

     EXEC('BULK INSERT Emp FROM ''E:\Development\Emp\'+@FileName+'.txt''

     WITH (formatfile =''E:\Development\Emp\InputFormat.fmt'')')

    END

    ELSE

     BEGIN

       RAISERROR ('File does not exist!', 16, 1)

      END


    Kindest Regards,

    Vasc

  • I've just read what Vasc has written, and I agree with that approach. I just wanted some answers first

    A further question is why you're removing data from SIRSInput, but inserting into Emp?

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • sorry that was my mistake..I edited the table name.

    but still am unable to get that error mesg when failed and also executing the bulkinsert command though it didnt meet the if statement.

  •  

    Every time I execute EXEC Master..xp_fileexist , It is giving the error mesg file not found, either success or failure.

  • -did you check if the file really exists?

    -the executing user has required security rights to access the file?


    Kindest Regards,

    Vasc

  • yeah THe file exists there.

    when I am able to bulk insert out of SP then it says that I have rights to that file.

  • The problem here is it is not executing IF statement , directly jumping to ELSE though the return value is 1

  • can t jump to else if return value is 1

    the problem is that when you test you use a USER that has access rights to file and when you actually run it that user doesn t have access rights to file. Check the access rights for executing user.

    (do a FULL SHARED FOLDER FOR ALL  put your file there and pass the UNC path to SP if it works you have rights problem )


    Kindest Regards,

    Vasc

  • I shared the folder, but still the same.

    is there anything else i can try

  • both files? the format and source file ?

    I tried the statement and it works fine ... the problem is somewhere else...

    Did you HARDCODED the file name for testing purposes?


    Kindest Regards,

    Vasc

  • yeah i have both files in the same shared folder.

    No..its real file not hardcoded.

    ANY HELP.............

  • EXEC Master..xp_fileexist 'E:\Development\Emp\@FileName.txt', @File_Exists OUTPUT

    ya after a closer look .... this file DOESN T EXISTS

    this one might

    EXEC Master..xp_fileexist 'E:\Development\Emp\'+@FileName+'.txt', @File_Exists OUTPUT


    Kindest Regards,

    Vasc

  • yeah exactly...but i think single quotes doesnt work here again.

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply