What result will you get from running the following script:

CREATE TABLE Patient

(
PatientId int IDENTITY(1,3) PRIMARY KEY,
Name varchar(50)
)

INSERT Patient VALUES('Hollan Daise')
INSERT Patient VALUES('Amy Dexterous')

TRUNCATE TABLE Patient

INSERT Patient VALUES('Hollan Daise')
INSERT Patient VALUES('Amy Dexterous')

DELETE FROM Patient

INSERT Patient VALUES('Hollan Daise')
INSERT Patient VALUES('Amy Dexterous')

SELECT MAX(PatientId) FROM Patient

DROP TABLE Patient

 Posted by Virendradugar on 10/29/2009 | Category: Others Interview questions | Views: 3112
Answer:

Answer : 10

Explanation: The identity column can be omitted when using and INSERT that doesn't specify a column list. So, you won't get an error. According to BOL, "If the table contains an identity column, the counter for that column is reset to the seed value defined for the column when you TRUNCATE the table. If no seed was defined, the default value 1 is used. To retain the identity counter, use DELETE instead."


Source: From SQLServerCenteral.Com (Original Author : Dun) | | Alert Moderator 

Comments or Responses

Login to post response