Being a T-SQL tool, BULK INSERT doesn't require any external programs and is easy to incorporate into your T-SQL batches. You can also use BULK INSERT within a T-SQL transaction, and doing so would let you roll back all the data inserted using the BULK INSERT statement. This capability can provide useful protection against data corruption.

Let's assume we have a comma-separated value (CSV) file named dataimport.csv that's in the C:\temp directory and contains the following sample data:

This code creates a table named MyTable to store the imported values. The table's data types must match the data that's being imported; if they don't, SQL Server Express will generate an error.

The BULK INSERT statement identifies the table into which the data will be imported, the file containing the data to be imported (in this case C:\temp\dataimport.csv), and the field separator value and end-of-line characters that the file uses--my sample file uses a comma and a \n, respectively. You can adjust these values depending on the format of the import file.