使用 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:11:15  来源:igfitidea点击:

Adding a new row Using SQL Server Management Studio?

sqlinsert

提问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 IDfield? If not, you will need to manually specify the value for the IDin your INSERTstatement.

你的表有自动递增的ID字段吗?如果没有,您将需要ID在您的INSERT语句中手动指定 的值。

You can check if the IDfield is auto-incrementing by using the Object Explorer, navigating to the table and expanding the Columns node. Find the IDcolumn, right-click on it and select Properties. If the Identity property is set to Falseit means that the IDfield 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。然后,您可以转到网格中的最后一行并手动输入列的值。