SQL Server,“无效的列名"插入Excel“链接服务器"时出现错误 [英] SQL Server, "Invalid column name" error when inserting into Excel "linked server"

查看:67
本文介绍了SQL Server,“无效的列名"插入Excel“链接服务器"时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Excel电子表格文档(运行Office 2013),正在使用"Microsoft Office 15.0 Access数据库引擎OLE DB提供程序"作为数据库.

I have a simple Excel spreadsheet document (running Office 2013) that I'm using as a database using the "Microsoft Office 15.0 Access Database Engine OLE DB Provider".

我可以使用MS SQL Server Management Studio 2012连接到它,甚至可以从命名范围"Employee"中选择数据.

I can connect to this using the MS SQL Server Management Studio 2012, and I can even select data from a Named Range "Employee".

SELECT *
  FROM [X]...[Employee]
GO

结果:

ID  Name    Description Salary
1   Rob     Cool        1
2   Bob     Awesome     2
3   Robert  DUDE!       3

现在,我想在此处插入数据.所以我写道:

Now I'd like to insert data here. So I wrote:

INSERT INTO [X]...[Employee]
           ([ID]
           ,[Name]
           ,[Description]
           ,[Salary])
     VALUES
           (4
           ,"John"
           ,"Boss"
           ,500)

这实际上主要是由SQL Server Management Studio生成的.当我运行它时,我得到:

This is actually mostly generated by SQL Server Management Studio. When I run this, I get:

Msg 207, Level 16, State 1, Line 8
Invalid column name 'John'.
Msg 207, Level 16, State 1, Line 9
Invalid column name 'Boss'.

知道我在做什么不好吗?

Any idea what I'm doing bad?

推荐答案

您正在使用双引号而不是单引号. IE浏览器:

You're using double quotes instead of single quotes. IE:

INSERT INTO [X]...[Employee]
       ([ID]
       ,[Name]
       ,[Description]
       ,[Salary])
 VALUES
       (4
       ,'John'
       ,'Boss'
       ,500)

这篇关于SQL Server,“无效的列名"插入Excel“链接服务器"时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆