SQL Server,当插入Excel“链接服务器”时出现“列名无效”错误
我有一个简单的Excel电子表格文档(运行Office 2013),用作使用“Microsoft Office 15.0 Access数据库引擎OLE DB提供程序”的数据库。
我可以使用MS SQL Server Management Studio 2012连接到这个,我甚至可以从命名范围“Employee”中select数据。
SELECT * FROM [X]...[Employee] GO
结果:
ID Name Description Salary 1 Rob Cool 1 2 Bob Awesome 2 3 Robert DUDE! 3
现在我想在这里插入数据。 所以我写道:
INSERT INTO [X]...[Employee] ([ID] ,[Name] ,[Description] ,[Salary]) VALUES (4 ,"John" ,"Boss" ,500)
这实际上主要是由SQL Server Management Studio生成的。 当我运行这个时,我得到:
Msg 207, Level 16, State 1, Line 8 Invalid column name 'John'. Msg 207, Level 16, State 1, Line 9 Invalid column name 'Boss'.
任何想法我做得不好?
您使用双引号而不是单引号。 IE:
INSERT INTO [X]...[Employee] ([ID] ,[Name] ,[Description] ,[Salary]) VALUES (4 ,'John' ,'Boss' ,500)