使用 SQL Server Management Studio 添加新行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2789256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding a new row Using SQL Server Management Studio?
提问by sooprise
I'm learning how to use SQL Server Management Studio and can't figure out how to insert a new row into a table.
我正在学习如何使用 SQL Server Management Studio,但不知道如何在表中插入新行。
Table Structure:
表结构:
ID,
Field1,
Field2
Query:
询问:
INSERT INTO Table (Field1,Field2) VALUES(1,2)
Error:
错误:
Major Error 0x80040E14, Minor Error 25503
主要错误 0x80040E14,次要错误 25503
I'm probably missing something very simple. Any help would be appreciated.
我可能错过了一些非常简单的东西。任何帮助,将不胜感激。
采纳答案by sooprise
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.
谢谢大家的回复。这是我的错误。
回答by TLiebe
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.
你的表有自动递增的ID
字段吗?如果没有,您将需要ID
在您的INSERT
语句中手动指定 的值。
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 Falseit means that the ID
field is NOT auto-incrementing.
您可以ID
通过使用对象资源管理器、导航到表并展开列节点来检查该字段是否自动递增。找到该ID
列,右键单击它并选择Properties。如果 Identity 属性设置为False,则表示该ID
字段不会自动递增。
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.
向表中添加行的另一个选项是导航到对象资源管理器中的表,右键单击它并选择Open Table。然后,您可以转到网格中的最后一行并手动输入列的值。