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

How to get Row Index in MySQL?

select employee_id,employee_name,@index := @index + 1 as 'sr. no.' from employee_master,(select @index := 0) Emp order by employee_name;

@index > Is an User Defined variable.
:= -> Is an Assignment operator.
@index := @index + 1 -> It sets the variable to the Next Incremental Value for each rows.

Setting @index in the sub-selection or sub-query makes it simple to put it into 1 query.The incrementing number can be adjusted.

After the "Emp" which stands for derived and it is mandatory to have an alias,we can use order by or group by clause.
Which of the following is FALSE regarding PRIMARY KEYS in SQL Server 2012?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is an example of a scalar subquery?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is FALSE regarding FOREIGN KEYS in SQL Server 2012?

NOTE: This is objective type question, Please click question title for correct answer.
How to delete a stored procedure named as MyProc from the SQL Server 2012 database?

NOTE: This is objective type question, Please click question title for correct answer.
How to remove any table from DB in SQL-Server

NOTE: This is objective type question, Please click question title for correct answer.
Which operation Resets Identity column in Table.

NOTE: This is objective type question, Please click question title for correct answer.
Which Select statement will not execute successfully about Distinct clause?

NOTE: This is objective type question, Please click question title for correct answer.
What is an Alternative way of getting Distinct or Unique records in SQL-Server?

With the help of Group-By clause,we can get unique records:-

select program_name,program_desc,created_date from program_details
group by program_name,program_desc,created_date order by program_name,program_desc,created_date;

Apart from Distinct clause used in select statement, we can get the same records using Group-by clause.
How to Concat 2 Column values in MySQL?

With the help of CONCAT in-built mysql function,we can add 2 column values to make one value as shown:-

select Concat(employee_firstname,' ',employee_lastname) as 'Employee Full Name' from employee_master where status = 'AA';

We can Concat more columns as many as we can,

select Concat(Concat(employee_firstname,' ',employee_lastname),' ',employee_code) as 'Employee Name' from employee_master where status = 'AA';
How to Concatnate 2 column values to make one column value in SQL-Server?

Using '+' sign or Concat in-built function we can Concatnate 2 column values as shown below:-

select(employee_firstname + ' ' + employee_lastname) AS Name from employee_master;

select Concat(employee_firstname , ' ' ,employee_lastname) AS Name from employee_master;
Which of the following is FALSE regarding filtered indexes?

NOTE: This is objective type question, Please click question title for correct answer.
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