Interview Question

Q1). char,varchar,nvarchar difference?

Char means every entry  in a row will take 8000 character space.
whether you store 5 letter string or 1000 letters string.

Varchar means you can specify during the schema design that how much space you want the column should  use for each entry.
e.g if you specify username varchar(10) then for each entry in a row the 10 character space will be use.

nvarchar means you can not only specify the space in the column but also additional asci characters are also included which can be entered in that column.

Q2)What are Triggers?
Trigger are special type of store procedures which can be set with the table so that for each update,insert or delete in the table. A query is run which saves the detail of operation done on table along with the data.
For example if we set update trigger on ITEM table then for each update of ITEM table a trigger will be fired which will save updated item record and time  in another table to maintain log of updates.
Trigger are of 3 type Onupdate, OnInsert, OnDelete.

Q3). Primary Key Vs Unique Key?

Primary key can not have null value unique key can have one null value.
Primary key automatically generates non clustered index where as unique key does not generate index automatically .



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s