I am getting Bulk insert: Syntax error or access violation while moving the data from data table to SQL
@omar_ismail can you share full error.
Hi @omar_ismail,
Share the error details, If not possible check out below things
- Check the SQL statement: Make sure that the SQL statement is correct and that all the column names match the table structure. You can try running the SQL statement directly in SQL Server Management Studio to see if it returns any errors.
- Check the data: Make sure that the data being inserted matches the data type of the columns in the table. For example, if the column is of type “int”, make sure that the data being inserted is an integer.
- Check for special characters: If the data being inserted contains special characters such as quotes or apostrophes, make sure that they are properly escaped.
- Check for NULL values: If any of the columns in the table do not allow NULL values, make sure that the data being inserted does not contain any NULL values.
- Check for constraints: Make sure that there are no constraints on the table that would prevent the data from being inserted. For example, if there is a unique constraint on a column, make sure that the data being inserted does not violate that constraint.
If a syntax error appears, check to make sure that the parentheses are matched up correctly. If one end is missing or lined up incorrectly, then type in the correction and check to make sure that the code can be compiled. Keeping the code as organized as possible also helps.
Regards,
Rachel Gomez
When you do bulk insert you have to make sure…to match the column names exactly with the sql database columns and also the data should be of the same format as the sql data columns
Please make sure of these and then try…to be sure to match column names first …try with only a single row of data and then try with multiple rows …so that if there is any column name issue we can catch ieasily
Cheers
CREATE TABLE stocks (
sc_code INT PRIMARY KEY,
security_id CHAR(15),
nse_code CHAR(15));
BULK INSERT stocks
from ‘C:\Users\khunt\Desktop\study files\bse code and name.csv’
with (format = csv,
firstrow = 2,
fieldterminator = ‘,’,
rowterminator=‘\n’,
batchsize=10000,
maxerrors=10);
this piece of code is also showing ER_PARSE_ERROR. Please help on this .