0

My code:

dbContext.Database.ExecuteSqlCommand(
    @"BULK INSERT dbo.tblAudit FROM @FileName WITH (FIRSTROW=2, FIELDTERMINATOR='|', ROWTERMINATOR='\n')",
    new SqlParameter("@FileName", auditCsvFileName)
    );

It should perform a bulk insert from a csv file.

It throws an error

System.Data.SqlClient.SqlException: Incorrect syntax near '@FileName'

I can run this command (with the filename inserted) in SSMS without an error.

  1. Is this an invalid use of parameters?

  2. Does Entity Framework not support BULK INSERT as a raw SQL command?

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Without Haste
  • 507
  • 2
  • 6

0 Answers0