15

I'm learning how to use SQL Server Management Studio and can't figure out how to insert a new row into a table.

Table Structure:

ID,
Field1,
Field2

Query:

INSERT INTO Table (Field1,Field2) VALUES(1,2)

Error:

Major Error 0x80040E14, Minor Error 25503

I'm probably missing something very simple. Any help would be appreciated.

2
  • The insert syntax is right (assuming your table isn't named 'Table', I can see that causing issues). What is the entire table structure (data types, nullability, keys)? I almost wonder about checking for database corruption.. Commented May 7, 2010 at 14:32
  • Is your table actually called Table? If so, try INSERT INTO [Table].... If not, please post the real code. Commented May 7, 2010 at 15:10

2 Answers 2

11

Ok, I was on the verge of pulling out all of my hair, and it appears using single quotes instead of double quotes fixed the problem.

Now, I want to pull my hair out even more.

Thanks for the replies everyone. This one was my mistake.

Sign up to request clarification or add additional context in comments.

Comments

3

Does your table have an auto-incrementing ID field? If not, you will need to manually specify the value for the ID in your INSERT statement.

You can check if the ID field is auto-incrementing by using the Object Explorer, navigating to the table and expanding the Columns node. Find the ID column, right-click on it and select Properties. If the Identity property is set to False it means that the ID field is NOT auto-incrementing.

Your other option for adding a row to the table is to navigate to the table in Object Explorer, right clicking on it and selecting Open Table. You can then go to the last row in the grid and manually enter the values for the columns.

6 Comments

ID is set as the primary key, and identity, with the identity seed and increment set to 1. Based on my understanding of this software, this is the equivalent of specifying an auto increment. So that is why I do not specify the ID explicitly.
Try adding a row through the Open Table process as I describe in my edited post. Do you get the same error? Also - what are the field types for Field1 and Field2? Are you sure they're numeric fields? If not you'll need to surround the values you're adding with quotes.
When I navigate to the table, there are two folders: Columns and Indexes. I don't see the option to view the whole table.
Right-click on the actual table name and there should be an option to open the table. I'm using SQL Server 2005, SQL Server 2008 might call it something slightly different.
These are the options I see: Edit Tables Properties Delete Reports > Custom Reports Refresh I'm using Microsoft SQL Server Management Studio. Maybe I'm using the wrong software?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.