SQL Server Fourth Lesson: View Query method, paging Query method

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.