Question:
In Microsoft Query I can’t seem to use the Execute SQL function. I’m learning SQL from a book called The ColdFusion 4.0 Web Application Construction Kit (Macmillan, 1998). The book has an example that goes like this:
- Open Execute SQL in Microsoft Query.
- Specify Data source.
- Type:
INSERT INTO Departments(Department) VALUES ('Administration')
Each time I try to do this I get an error message that says, “This operation must use an updateable query”. I am not really sure what that means and I can’t find any help files to explain it to me.
Please help!
Answer:
I must admit I find it mystifying myself but I will hazard a guess that what makes a query updateable is the presence of a primary key column, a way to distinguish one row from another.
In your example you provide only “Administration” as a value. I wonder what would happen if the Departments table also had a field called “ID”? If so, I bet changing your statement to read something like this will fix it:
INSERT INTO Departments(Department, ID)VALUES ('Administration', 4) would do it.
Mind the data type of ID. As you can see, I have assumed INT and that there is no other ID of 4 in the column, but it could be almost anything.