here id col have primary key and identity
id name
1 a
2 b
3 c
4 d

delete 2nd row then o/p will be

id name
1 a
3 c
4 d

next inssert 2nd row and i want o/p will be
id name
1 a
2 e
3 c
4 d

Answers were Sorted based on User's Feedback



here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / challa yerriswamy

set identity_insert <table_name> on
insert into text1(id,id_name) values(2,'insertedat2')

Is This Answer Correct ?    13 Yes 0 No

here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / qwerty

set identity_insert <table_name> on
insert into <table_name>(id,name) values(2,'e')
set identity_insert <table_name> off

Is This Answer Correct ?    12 Yes 0 No

here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / sunilkumar

set identity_insert on
insert into test1(Id ,id_name) values (2 ,'insertedat2')

Is This Answer Correct ?    7 Yes 3 No

here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / boby

insert into <table_name>(id,name) values(2,'e')ORDER BY ID

Is This Answer Correct ?    1 Yes 0 No

here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / pradeep aryan

set identity_insert on
insert into test1(Id ,id_name) values (2 ,'e')
set identity_insert off

Is This Answer Correct ?    0 Yes 3 No

here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / s pattnaik

SET IDENTITY_INSERT dbo.test1 OFF
Then
insert into test1(Id ,id_name) values (2 ,'insertedat2')

Is This Answer Correct ?    6 Yes 12 No

here id col have primary key and identity id name 1 a 2 b 3 c 4 d delete 2nd row ..

Answer / karthikeyan

select * from table_name order by id;

Is This Answer Correct ?    1 Yes 14 No

Post New Answer

More SQL Server Interview Questions

What is difference between restoration and recovery in SQLServer?

3 Answers   Microsoft,


How get current date in SQL server 2000

6 Answers   Cap Gemini,


How will you find out if there are expensive SQL statements running or not?

0 Answers   Atos Origin,


What are the features of Embedded SQL

0 Answers   HCL,


How to Run a Query on a Remote SQL Server?

2 Answers  






What is the difference between an index and a unique index?

0 Answers  


Can we add an identity column to decimal datatype?

0 Answers  


What's the maximum size of a row?

4 Answers   IBM,


What is the difference between Temporary table variable and a Table variable? Or Which Table variable I should use inside Stored procedure?

3 Answers   Microsoft, TCS, Techastrum,


How to convert numeric expression data types by assignment operations?

0 Answers  


i have made a project i vb.net n created a .exe of it after installing it in to any pc, the database (sql express) is not geting accesed i.e the aplication cuts the link of the database, so plz help in this matter.

0 Answers  


What is purpose of normalization?

0 Answers  


Categories