ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
select top 5 * from emp order by newid()

my question is , how this query get executed?
 Question Submitted By :: Y Babu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: select top 5 * from emp order by newid() my question is , how this query get executed?
Answer
# 1
SQL server will execute the query in following way...

Select All top 5 rows which are created in the table from 
the time it is created.

reason: newid is the key given to each row regardless of 
the values that goes into the row of the table.

For example.
if you have created a table temp
and inserted 10 rows, Only fives rows which are created 
first will be listed.
 
Is This Answer Correct ?    0 Yes 3 No
Praveen N H
 
  Re: select top 5 * from emp order by newid() my question is , how this query get executed?
Answer
# 2
Random 5 rows are selected when newid() is used.
 
Is This Answer Correct ?    7 Yes 0 No
Kb
 
 
 
  Re: select top 5 * from emp order by newid() my question is , how this query get executed?
Answer
# 3
first of all order by clause will be executed that is first 
it will be arranged as ascending or descending order and 
than first 5 records will be fatched.....
 
Is This Answer Correct ?    0 Yes 0 No
Ankita Bosamiya
 
  Re: select top 5 * from emp order by newid() my question is , how this query get executed?
Answer
# 4
newid() function return random row and top 5 return top 5 
rows.
So query return top 5 row using random order.
 
Is This Answer Correct ?    0 Yes 1 No
Anil Sharma
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
explain different types of jions with examples briefly? Zensar3
Please give me queries for the following 1. To get the count of duplicate records. 2. A query to delete the duplicate records. 247Customer3
What types of integrity are enforced by a foreign-key constraint  1
What are the four main query statements?  3
WHAT IS UNIQUE IDENTIFIER DATA TYPE? Sparsh2
what command is used to create a table by copying the structure of another table?  5
About Indexed Views? with example? plz reply...  2
What is the use of placing primary key and foreign key constrains on columns. Value-Labs2
How will u get 5 years back record?  4
What is the difference between Drop and Truncate  10
How to determine the service pack currently installed on SQL Server? HCL4
How do you know which index a table is using?  4
What is the system function to get the current user's user id? TCS3
what is the difference between group and having give an example with query and sample output  2
What is the use of CASCADE CONSTRAINTS?  2
Assume,there are three tables in a database, Can i have both primary key and foreign key for each table in the same database?  4
How to link up the text file to a Database table? Allianz1
WRITE A FUNCTION TO DISPLAY THE OUTPUT OF AN EXISTING TABLE RANGE LIKE COMMAM SEPERATED VALUES LIKE RANGE1,RANGE2,... TVS2
How to select nth record from a table? DELL9
WHICH INDEX IS FAST CLUSTER AND NON CLUSTER INDEX L&T2
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com