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

How many Primary Key Constraints can be included in a Table Definition?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following is not correct for Delete and Truncate statement?

NOTE: This is objective type question, Please click question title for correct answer.
Which option helps us to restore the Database to the point where it got failed?

NOTE: This is objective type question, Please click question title for correct answer.
Which keyword is used to select N no of records in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
Which keyword is used to select N no of records in MYSQL Database.

NOTE: This is objective type question, Please click question title for correct answer.
Where is Limit Keyword used in the Query in MYSql DB?

NOTE: This is objective type question, Please click question title for correct answer.
How to find which index is defined on specific tables or views?

NOTE: This is objective type question, Please click question title for correct answer.
A Sub-query in an SQL SELECT statement is enclosed in?

NOTE: This is objective type question, Please click question title for correct answer.
The result or output of a SQL Select statement is known as?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following are the five built-in functions provided by Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
In an Sql Select statement querying a single table an asterisk(*) means?

NOTE: This is objective type question, Please click question title for correct answer.
To remove duplicate rows from the results of an query,which qualifier specified must be included?

NOTE: This is objective type question, Please click question title for correct answer.
What do we mean by NEWSEQUENTIALID() function in Sql Server?

As name suggests,NEWSEQUENTIALID() function generates the unique identifier values sequentially.
In other words,we can say that,a NEWSEQUENTIALID() function creates the GUIDs greater than the previously generated GUIDs,since the last restart of the system,because after restarting the system the next NEWSEQUENTIALID can be started from the lower range.

Syntax:-
create table dummy 

(
id uniqueidentifier default newsequentialid()
not null primary key clustered,
sequence int
);

Which function is used to generate a new Guid values in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
Which function is used to generate a Random values in Sql Server?

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between Rand() and NewId() Sql Server function?

Rand() function generates random values which is only and only Numeric values whereas NewId() function generates GUID(unique identifier) which is a combination of both alpha-numeric character.
For Ex:-
Select NewId() as Unique_Id;

will produce A1F3BE10-888C-45A2-8CCB-FB4A0DF37334

Select Rand() as Random_value;

will produce 0.16028902278382
How to fetch Random Rows in Sql Server?

We can use NewID() in-built Sql Server function to fetch Random Rows.We have to give it after Order by clause,then it will populate random rows each time query is hit.

For Example:-
select * from employee_master order by newid();

Tell us about difference between NEWSEQUENTIALID() and NEWID() Sql Server function?

Following are the differences:-

1).
NEWSEQUENTIALID() generates the unique identifier values sequentially.
Whereas NEWID() generates the unique identifier values randomly.

2).
NEWSEQUENTIALID() function creates the GUIDs greater than the previously generated GUIDs,since the last restart of the system,because after restarting the system the next NEWSEQUENTIALID can be started from the lower range.

3).
Both NEWID() and NEWSEQUENTIALID() are globally unique. Starting of NEWSEQUENTIALID after the restart of the computer does not affect its globally uniqueness.

4).
NEWSEQUENTIALID() uses the default constraint,and it can't be used in SELECT or SET queries like NEWID().
Which range does fall the output of the RAND function?

NOTE: This is objective type question, Please click question title for correct answer.
How to get Random values in digits like 1,2,3,4,5 and so on without the decimal point?

If we want to generate a random integer number,then we have to simply multiply it by the maximum value we want.
For Example:-
SELECT CAST(RAND() * 10 AS INT) AS [OneDigitRandomNumber];
1 digit random number
SELECT CAST(RAND() * 100 AS INT) AS [TwoDigitRandomNumber];
2 digit random number
SELECT CAST(RAND() * 1000 AS INT) AS [ThreeDigitRandomNumber];
3 digit random number
SELECT CAST(RAND() * 10000 AS INT) AS [FourDigitRandomNumber];
4 digit random number
SELECT CAST(RAND() * 100000 AS INT) AS [FiveDigitRandomNumber];
5 digit random number
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