Saturday, December 18, 2010

SQL Server Interview Questions and Answers : Series 1

Question: What are unique identifiers in SQL Server?
The columns which are created as a data type unique identifier, contains the hexadecimal value which populates automatically. This value is used for segregating the data in rows where there is a chance of duplicate rows in data.
The Newid () is the function used for getting this value. It’s a hexadecimal value and the NewID function always returns a unique value.
Question: What is check constraint in SQL SERVER?
Check constraint is the constraint on the column where you can restrict the value in columns as per data type or some numeric value.
Limitations of check constrains is that constraint don’t apply on null value i.e. if you are inserting the null value in column that will get inserted in the column where you have put some check constraint.
For check constraint there should be at least one row in the table on which constraint can be specified.
Delete operation doesn’t s validates check constraint.
Question: What is default constraint?
Default constraint is the constraint use to put default value in column if you are not inserting any values in it.
Two types of default constraint exists ANSI standard default constraint and bound default constraint.
Question: What is Null Constraint?
Null constraint doesn’t allow any null value in column. It restricts inserting null value in columns. It’s a check at database level for columns where null values are not allowed like primary key column or primary telephone no of customer.
Question: What is Identity Column in Table?
Identity is a property of column which insert incremental value in that column automatically at the time of insertion of new row in that table.
This property generally used for primary key where user expects that primary key should populate automatically.
Question: Syntax to check current Identity of the table
Question: Can we change identity key values for a table or reset the identity key value?
Yes we can do this by using reseed identity function in SQL Server and providing the new value.
DBCC CHECKINDENT (Table Name, reseed, new identity value).

No comments:

Post a Comment