Questions tagged [insert-statement]
39 questions
16
votes
2 answers
nested SELECT in INSERT sql statement
Can someone tell me why this doesnt work?
INSERT INTO Medical_History (pid, grafts, allergies, diseases, surgearies, treatment)
VALUES ((SELECT pid FROM Pet WHERE pet_name='Jack' AND cid=(SELECT cid FROM Customer WHERE last_name='Iwannidis' AND…

lephleg
- 1,724
- 2
- 21
- 41
5
votes
2 answers
VBA macro in Excel to Run SQL Insert statement
Hey im quite new to VBA and I was hoping someone could help me with last bit of code.
I am trying to take cells from a spreadsheet and add them to a SQL table but I am having trubble running the SQL statement. Here is the code I have so far.
…

user1167046
- 51
- 1
- 1
- 2
3
votes
1 answer
SQL Server Compact 4.0 chokes on INSERT statements
I'm trying to create a SQL Server Compact 4.0 database in code, and I would like to create some system lookup tables and fill them with values.
Therefore, I have a SQL script as an embedded resource in my project, which looks like this:
CREATE TABLE…

marc_s
- 732,580
- 175
- 1,330
- 1,459
3
votes
3 answers
Can I have an MySQL database auto-assign a value to a column after an insert statement?
Given a table employee with columns ID(pk) and name
ID|name
--+-----
1 |John
2 |James
3 |Tom
Can I do
INSERT INTO employee (name) VALUES (Jack);
and somehow have the database auto assign the next available ID? Can a trigger do it? If so, how?

user299648
- 2,769
- 6
- 34
- 43
2
votes
1 answer
Primary key violation triggers warning, but does not trigger error handler
I have a button on a form that runs an insert statement that takes data from some textboxes on the form and puts them in a table.
In the event that the user enters duplicate information, in the primary key (a concatenation of 2 of the textboxes), I…

BSoD'n'Syntaxes
- 35
- 8
2
votes
0 answers
Why does this method keep adding null values into my database?
The following is code for a register form. When I run it and input values, I check my database and it has added a record but every field is null. I can't see anything wrong with my code which would cause this.