Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

Insert



Hi,
I try to insert in table "pt' but gives me erro
insert into pt
        (ptid,vr,Title,TyppeID,pn)
 values (@ReportId,"M1","T12","List",2)


Msg 128, Level 15, State 1, Line 17
The name "M1" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
0
samprg
Asked:
samprg
1 Solution
 
Kent DyerCommented:
I don't think you can place your own values in the ID as it is usually an auto-created, auto-incremented ID and ususally created with an Index in a SQL table..

Try this instead:
insert into pt
        (vr,Title,TyppeID,pn)
 values ("M1","T12","List",2)

Open in new window


On second thought, you need to back up and review the datatypes for:
vr
Title
TyppeID
pn


HTH,

Kent
0
 
samprgAuthor Commented:
"ptid" is FK, not ID, I need to insert into table
0
 
Pratima PharandeCommented:

Use single quotes


insert into pt
        (ptid,vr,Title,TyppeID,pn)
 values (@ReportId,'M1','T12','List',2)
0
 
samprgAuthor Commented:
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now