Say if we have a table that contains only a single column ,
say OrderID, which has IDENTITY attribute defined on it. So
how can we insert data in this table.

I am reframing my question, that how can we make the table
to increment the column "OrderID" value several times???

Answers were Sorted based on User's Feedback



Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attrib..

Answer / madhu

To insert values into Identity column use the
IDENTITY_INSERT option like

SET IDENTITY_INSERT Table_Name ON
Insert Table_Name
(OrderID)
Values(10)
SET IDENTITY_INSERT Table_Name OFF

Is This Answer Correct ?    4 Yes 0 No

Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attrib..

Answer / brahma

create table t1(a int identity(1,1))
insert into t1 default value

set identity_insert t1 off
(or)
set identity_insert t1 on

Is This Answer Correct ?    0 Yes 0 No

Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attrib..

Answer / deepak

Madhu, actually the answer which u have given is quite
common. Now i m gonna tell u a new one. The above question
has one more solution that is stated below:


"Insert into Table_name DEFAULT values"


that's it.

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More SQL Server Interview Questions

What's the information that can be stored inside a bit column?

0 Answers  


Delete duplicate records from the table?(Table must have unique id)

7 Answers   TCS, Thomson Reuters,


What the different topologies in which replication can be configured?

0 Answers  


What is a trace frag?

0 Answers  


What is a transact-sql statement?

0 Answers  






What is the difference between delete and truncate statements?

0 Answers  


What are the different types of stored procedures?

0 Answers  


difference between function and procedure

3 Answers   Cognizant, HCL, TCS, Theorem,


What do you understand by triggers?

0 Answers  


hi i am having .mdf file and .ldf file ..how can i get the all table in my .mdf..plz give solution

2 Answers  


How exceptions can be handled in sql server programming?

0 Answers  


can primery key be a non clustered index?

10 Answers  


Categories