如何在sql server 2000、2005、2008中向表中插入值?

时间:2023-01-14 00:15:37

I have a table having a single auto Auto Incremented column. How Can i insert the value. Using

我有一个具有单个自动递增列的表。如何插入值。使用

Insert into table or some other way

插入到表格或其他方式

Thanks Waiting for your replay..

谢谢您的回复。

5 个解决方案

#1


4  

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=90116

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=90116

provided some insight here.

这里提供了一些见解。

INSERT INTO TableName DEFAULT VALUES

#2


1  

CREATE TABLE products
(
   Id int IDENTITY(1,1) PRIMARY KEY
)
GO    


SET IDENTITY INSERT ON

INSERT INTO MyTable (Id) VALUES (2)

SET IDENTITY INSERT OFF

#3


0  

Without knowing your table schema it's not going to be possible to give you a good answer, but you could do something like:

在不了解表模式的情况下,不可能给出一个好的答案,但是您可以这样做:

insert into tableName (column2, column3, column4) values (value2, value3, value4)

Since you're using an autoincrement column you don't need to specify it when inserting data.

由于您使用的是自动增量列,所以在插入数据时不需要指定它。

#4


0  

INSERT INTO tableName (columnName1, ...) VALUES (value1, ...);

#5


0  

you can either

你可以

insert into tableName ()

either "insert into tableName VALUES (NULL)" where NULL is the first and only column value of the row (the syntax is

或者“插入到tableName值(NULL)”,其中NULL是行的第一个和惟一的列值(语法是

insert into tableName(column2, column3) VALUES (value2, value3)

as provided by Michael. )

由Michael提供。

#1


4  

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=90116

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=90116

provided some insight here.

这里提供了一些见解。

INSERT INTO TableName DEFAULT VALUES

#2


1  

CREATE TABLE products
(
   Id int IDENTITY(1,1) PRIMARY KEY
)
GO    


SET IDENTITY INSERT ON

INSERT INTO MyTable (Id) VALUES (2)

SET IDENTITY INSERT OFF

#3


0  

Without knowing your table schema it's not going to be possible to give you a good answer, but you could do something like:

在不了解表模式的情况下,不可能给出一个好的答案,但是您可以这样做:

insert into tableName (column2, column3, column4) values (value2, value3, value4)

Since you're using an autoincrement column you don't need to specify it when inserting data.

由于您使用的是自动增量列,所以在插入数据时不需要指定它。

#4


0  

INSERT INTO tableName (columnName1, ...) VALUES (value1, ...);

#5


0  

you can either

你可以

insert into tableName ()

either "insert into tableName VALUES (NULL)" where NULL is the first and only column value of the row (the syntax is

或者“插入到tableName值(NULL)”,其中NULL是行的第一个和惟一的列值(语法是

insert into tableName(column2, column3) VALUES (value2, value3)

as provided by Michael. )

由Michael提供。