Dynamic Bulk Insert executing as background task?

  • Question.. the following code:

    set @strSQL = 'bulk insert MYServer..[' + @tablename + '] from ''\\mylocation\subfolder\' + @tableName + '.dat'' with (fieldterminator = ''|'');'

    exec sp_executesql @strSQL

    print @tableName

    will run for a while and then spit out 20 or 30 table names...then run for a while and then spit out 20 or 30 more names....

    ...as it runs through my list of files to import.

    Can someone tell me why it's not operating in a sequential order? ie, 1. bulk insert statement created, 2. run bulk insert statement, 3. PRINT THE DAMN TABLE NAME before going back to step one.

    Is this a dynamic sql issue or a bulk insert issue or a completely unrelated issue?

  • PRINT is buffered, you can use instead:

    RAISERROR ('Message', 1, 1) WITH NOWAIT

  • Ah.. that makes sense. Thank you very much.

Viewing 3 posts - 1 through 2 (of 2 total)

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