During import of excel data into SQL Server 2012 Express for User only i am getting the error. The Error is as mention below

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'User'.

And the my import statement TSQL code is as follows:

Use DB1;
    select * INTO User
    from openrowset('MICROSOFT.ACE.OLEDB.12.0',
    'Excel 12.0; Database=C:\DBTableDataRecords\User.xlsx; HDR=yes; IMEX=1',
    'select * from [User$]');

NB: From the above TSQL code i am able to import excel data for creation of other tablename (Except User table name). Even I have check the MICROSOFT.ACE.OLEDB.12.0 provider link server object. Where provider option of 'Allow inprocess' is enable.


Try putting brackets around the user table like this

select * INTO [User]

"User" is a reserved word. By putting brackets around it you are basically telling SQL Server to look at this as an object and not a reserved word.

Even though SQL Server allows you to get around issues like this by using brackets, it's generally advisable to avoid naming objects with reserved words

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.