This is one of the tricky interviews. In one interview, the interviewer asks this question to my friend. He asked to write the insert script to insert a record a record into a table which has only one identity column.
Identity column: Identity column of a table is a column whose value increases automatically. The value in an identity column is created by the server. A user generally cannot insert a value into an identity column. An identity column can be used to uniquely identify the rows in the table.
See the example
I am creating a table with one identity column.
CREATE TABLE TestTable
( Id int identity(1,1) )
|
Table is created successfully.
Now I am trying to insert a record into this table.
For inserting the record we need to use “DEFAULT VALUES”
Let’s see the example.
See the result.
question and answer not matching
ReplyDeleteIncorrect screenshots placed! Correct them
ReplyDelete