Using SQL Server. I am getting an error from an SQL Insert statement:
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.
This is the Insert SQL that produces that error:
Insert Into [PlanFinder].[ReportLinks]
(TypeOfReport, Links) Values (InvalidAwps, \\uafc.com\ReportLinks\InvalidAwps);
And here is the table definition:
Create Table [PlanFinder].[ReportLinks]
(
[TypeOfReport] Char (11) Not Null,
[Links] Money Null,
Constraint pk_TypeOfReport Primary Key Clustered (TypeOfReport)
)
How do I fix this?
You need string delimiters
Insert Into [PlanFinder].[ReportLinks]
(TypeOfReport, Links) Values ('InvalidAwps', '\\uafc.com\ReportLinks\InvalidAwps')
However, then you'll get errors inserting the string \\uafc.com\ReportLinks\InvalidAwps
into a money
column...
or are \\\InvalidAwps
,\\\Missing
meant to be symbols of some kind?
Try putting InvalidAwps
in single quotes:
Insert Into [PlanFinder].[ReportLinks] (TypeOfReport, Links)
Values ('InvalidAwps', '\uafc.com\ReportLinks\InvalidAwps')
Reproduce this error in SQL Server.
Create a string column and use Double quotes to insert values instead of single quotes:
create table yar (id VARCHAR(50));
insert into yar values("yarrrr");
Causes error:
Msg 128, Level 15, State 1, Line 1
The name "yarrrr" is not permitted in this context. Valid expressions are
constants, constant expressions, and (in some contexts) variables. Column names
are not permitted.
Fix it by using single quotes like this:
create table yar (id VARCHAR(50));
insert into yar values('yarrrr');
Prints:
(1 row(s) affected)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With