1. Data paging
OFFSET: Specifies the number of rows that will be skipped before rows are returned from a query expression.
FETCH: Specifies the number of rows to be returned after the offset clause.
Offset is a synonym for the leaf number, and Frtch represents the number of rows displayed per page.
Select ProductID, ProductNumber, Name as ProductName, Listpricefrom Production.productorder by Productidoffset 0 rowsfetc H Next ten rows only
2. Using variables
Declaring variables: declare @variable int
Three methods of assignment: You can use the Set keyword, which is the best choice, you can assign a value to a variable in a SELECT statement, and you can assign a value to it during the declaration of a variable.
DECLARE @variable intset @variable = <value>
Select @variable = <column or Expression>from <table name>
declare @variable int = <value>
This article is from the "Night So Deep" blog, please be sure to keep this source http://lvhz94zm6.blog.51cto.com/9805380/1880099
SQL Server from getting started to mastering