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 is the difference between index seek vs. Index scan?

0 Answers  


Define full outer join?

0 Answers  


what are the critical issues you have resloved in your company

0 Answers   Wipro,


How do you check sql server is up and running?

0 Answers  


Can a table have 2 primary keys?

0 Answers  






What are security principals used in sql server 2005?

0 Answers  


What is sub-query in sql server? Explain its properties.

0 Answers  


Explain trigger classes i.e. Instead of and after trigger?

0 Answers  


What is the difference between varchar and varchar types?

0 Answers  


What are cursors in ms sql server?

0 Answers  


What is sql profiler. What are the default templates with it? : sql server database administration

0 Answers  


Are semicolons required at the end of sql statements in sql server 2005?

0 Answers  


Categories