CREATE VIEW View_1--Create a new view name as--functions for building viewsSelectStudent.sno,sname,cno,degree fromStudent join score on student.sno=Score.sno GoSelect* fromView_1wheresno='1'Select* from(SelectStudent.sno,sname,cno,degree fromStudent join score on STUDENT.SNO=SCORE.SNO) asTable2 wheresno='101'--define as a temporary table with AS and then query the results from the table. is also a sub-query, the subquery query out the result set, as a temporary table to use. --views are only query-scoped. Reduce the amount of code you write when you repeatedly query the results in subqueries--paging queries, querying the information in a table and the first fewSelect* fromStudentSelectTop2* fromStudentwhereSno notinch(SelectTop3Sno fromstudent)--trailing not in is masking the contents of the previous page of the current page, and the front top is the number of pages showing the data after masking--two Behavior one page--Paged Stored procedure create proc Fenye----use functions to query for pagination. Query the first and last information in a table @nowyeint, --Current Page @numberint--number of rows displayed as SelectTop (@number) * fromDingdanbiaowhereSno notinch(SelectTop (@nowye-1) * @number) Sno fromstudent) go EXEC fenye2,3
SQL Server Fourth Lesson: View Query method, paging Query method