raise error

  • getting error

    Server: Msg 170, Level 15, State 1, Line 1

    Line 1: Incorrect syntax near '+'.

  • yep you can t do that

    you have to prepare file name before in a variable

    SET @FileName='E:\Development\Emp\'+@FileName+'.txt'

    EXEC Master..xp_fileexist @FileName, @File_Exists OUTPUT


    Kindest Regards,

    Vasc

  • yeah i did even that..but same problem again.

    not getting any syntax error but cudnt process the flow

  • can you post again what you did ?

     

    this one works

    SET NOCOUNT ON

    DECLARE @File_Exists  INT

    ----------------------------------------------------------

    DECLARE @FileName NVARCHAR(50)

    SET @FileName='IO'

    ----------------------------------------------------------

    SET @FileName='C:\'+@FileName+'.sys'

    EXEC Master..xp_fileexist @FileName, @File_Exists OUTPUT

    SELECT @File_Exists as Existss,@FileName as FileNames

    SET @FileName=@FileName+'sys'

    EXEC Master..xp_fileexist @FileName, @File_Exists OUTPUT

    SELECT @File_Exists as Existss ,@FileName as FileNames

     


    Kindest Regards,

    Vasc

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

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

    =

     

    DECLARE @MySQL NVARCHAR(4000)

    SET @MySQL ='BULK INSERT Emp FROM '''+@FileName+''' WITH (formatfile =''E:\Development\Emp\InputFormat.fmt'')'

    PRINT @MySQL

    EXEC (@MySQL)


    Kindest Regards,

    Vasc

  • Thanks a lot..Finally I got it done.

Viewing 6 posts - 16 through 20 (of 20 total)

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