I know this question is asked so many times but some issue is still not clear to me. Please don't mark it as duplicate. I am little bit confused with View. Is View create a table internally or execute sql query internally when I select data from view? I know view treated as virtual Table and using view I can also do DML operation. But if View execute sql query internally every time when I select data from View, then what is the requirement of adding extra additional layer. In View I can do complex join query and in stored procedure(SP) also I can do.
So I mean, in place of View, I can easily use direct SP without doing extra effort by creating View and again SP for that View and calling from c# back end.
I mean, using View it will be faster or not, I dont know. It may be as it is treated as virtual table, please clarify those things.
Example:
CREATE TABLE EMPLOYEE(Emp_ID INT PRIMARY KEY CLUSTERED,Address VARCHAR(50) NOT NULL)
INSERT INTO EMPLOYEE VALUES(1,'West BEngal');
INSERT INTO EMPLOYEE VALUES(2,'Bihar');
INSERT INTO EMPLOYEE VALUES(3,'MP');
VIEW:
---
CREATE VIEW vw_all_Employee
AS
SELECT Emp_ID, Address FROM EMPLOYEE;
SP1:
---
CREATE PROCEDURE sp_select_All_Employee
AS
BEGIN
SELECT Emp_ID, Address FROM EMPLOYEE;
END
SP2(On VIEW):
----------
CREATE PROCEDURE sp_select_All_Employee1
AS
BEGIN
SELECT Emp_ID, Address FROM vw_all_Employee;
END
My question is: I will use the SP from c# back end, so which SP will be faster? SP1 or SP2?