What will happen if we execute below query?Will below view be created or not?

create view vw_emp_information
select * from employee_master order by employee_name;

 Posted by vishalneeraj-24503 on 7/1/2014 | Category: Sql Server Interview questions | Views: 1206 | Points: 40

No it will not execute and will give an error saying that:-

Msg 1033, Level 15, State 1, Procedure vw_test, Line 3
The order by clause is invalid in views,inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.

Means we can not write order by clause until and unless Top clause is specified in Select statement.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response