Sql Server Interview Questions and Answers (1758) - Page 67

Which in-built function is used to get Last incremented value in MySql Database.

NOTE: This is objective type question, Please click question title for correct answer.
Which function is used to get Last increment value in Sql Server Database?

NOTE: This is objective type question, Please click question title for correct answer.
What is the use of Auto Increment option in Sql Server?

There are the uses of auto increment in sql server which are listed below:-
1). Identifying Each Row Uniquely:
->Can be used in primary table to generate auto key as primary key in master table.
2). Maintaining Row Number:
->Identity (Auto increment) can be used to maintain row number.
3). Performance Reasons:
->Auto increment can be used as a primary key and as we know that primary key creates cluster index which results faster.
Which property is used to SET auto increment in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
What does below script mean? Create Table emp_master(emp_id int identity(1,1))

This will create a table having emp_id column identity.
Default identity column start with 1 and incremented by 1 only.
Which property is used to auto increment in MySql database?

NOTE: This is objective type question, Please click question title for correct answer.
How can we start row number to 100 or How can we start row number to to start from 100?

We can use below script
Syntax:-
Create Table tbl_name(col1 dataType Identity(StartingValue,Inrement),col2 dataType);

For Example:-
Create Table Project_Master(Project_ID int identity(100,5),Projct_Name varchar(100));


Above query will create a table called Project_Master,Project_ID column will start with 100 and increment will be +5 like 100,105 ,110 ... and so on..
Which statement is FALSE about Row_Number() Sql Server function?

NOTE: This is objective type question, Please click question title for correct answer.
Why do we use Unique Key?

Unique Keys Identify Record Uniquely:- Enforcing Unique key on column helps user to avoid duplicate records.PAN Number column can be treated as Uniqe Key because it can not be same for different employees.

Even if we have made a unique key and inserting duplicate data in the unique column(s),Sql Server throws the error.
How to Create Unique Key on the columns?

We have to write Unique keyword after Datatype as:-
Syntax:-
Create Table Table_Name(Col1 DataType Unique(ID),Col2 DataType);

For Example:-
Create Table Employee_Master(Emp_Name varchar(20),PAN_Number varchar(10) Unique,Address Varchar(100),Phone_Number int);

How to Create a New Table From Another Table in Sql Server or Copy Table Structure Only?

We will use INTO clause to create a new table from any existing tables.
For Example:-
Select * INTO New_Tbl From Existing_Tbl Where 2 = 4;

Here,2 = 4 means condition will be false,so it will create only table structure.
How to Create a New Table From Another Table in Sql Server or Copy Table Structure As well as Data?

Use below script:-
For Example:-
Select * INTO New_Tbl From Existing_Tbl;

It will copy all data along with all columns.
If we want to copy specific rows then give valid condition,so that where condition will satisfy.
How To Reset MySQL Auto_Increment Column?

Alter table syntax provides a way to reset Auto_Increment column.
For Example:-
Alter Table table_name AUTO_INCREMENT = 1;

So,it will again start with 1.
Which Database is a system Database which is used as a Template whenever a new Database is created on Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
When does the UPDATE_STATISTICS command used?

1). When the processing of large data is done,UPDATE_STATISTICS command is used.
2). Whenever large number of deletions,modification or copy takes place into the tables,the indexes need to be updated to take care of these changes.UPDATE_STATISTICS performs this job.
3). It updates query optimization statistics on a table or indexed view.
How to Update all statistics on a table or what is the syntax?

Use below script:-
Update Statistics Tbl_Name.

For Example:-
If we want to update all statistics on a Table called Employee_Master,then we will write as:-
Update Statistics Employee_Master.

How to update the statistics for an index?

We will use below script:-
Update Statistics Tbl_Name,Index_Name;

It will update specified index.
How to find out if any index has updated or not?

We can use the dbcc show_statistics command as:-

dbcc show_statistics(table_name,index_name);

Note:- This command will not tell us when statistics were last updated.
How to fetch Month Number from any specified Month Name?

Use below query:-
SELECT MONTH(CAST('February' + '1 2014' AS Datetime)) AS Month_No

What does Describe command mean in SQL Server?

Describe command as name suggests describes or shows information about tables meaning that it shows which primary key,foreign keys,indexes applied to which columns.

Just Highlight the Table name and then Press ALT + F1 Key Combination.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories