在此上下文中不允许使用名称"X".有效表达式是常量,常量表达式和变量.不允许使用列名

Use*_*781 4 sql sql-server

使用SQL Server.我从SQL Insert语句中收到错误:

The name "InvalidAwps" is not permitted in this context. Valid
expressions are constants, constant expressions, and (in some contexts)
variables. Column names are not permitted.
Run Code Online (Sandbox Code Playgroud)

这是产生该错误的Insert SQL:

Insert Into [PlanFinder].[ReportLinks]
(TypeOfReport, Links) Values (InvalidAwps, \\uafc.com\ReportLinks\InvalidAwps);
Run Code Online (Sandbox Code Playgroud)

这是表定义:

Create Table [PlanFinder].[ReportLinks]
(
  [TypeOfReport]      Char (11)             Not Null,
  [Links]             Money                 Null,
  Constraint pk_TypeOfReport Primary Key Clustered (TypeOfReport)
)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

gbn*_*gbn 9

你需要字符串分隔符

Insert Into [PlanFinder].[ReportLinks]
(TypeOfReport, Links) Values ('InvalidAwps', '\\uafc.com\ReportLinks\InvalidAwps')
Run Code Online (Sandbox Code Playgroud)

但是,如果将字符串\\uafc.com\ReportLinks\InvalidAwps插入money列中,则会出错...

或者\\\InvalidAwps,\\\Missing是什么意思?


JNK*_*JNK 5

尝试放入InvalidAwps单引号:

Insert Into [PlanFinder].[ReportLinks] (TypeOfReport, Links) 
Values ('InvalidAwps', '\uafc.com\ReportLinks\InvalidAwps')
Run Code Online (Sandbox Code Playgroud)