---Paged QuerySelect Top 2 * fromStudentwhereSno not inch(Select Top 2Sno fromstudent)--Not in () mask off the first two lines on this basis and then take the first two lines--paging stored procedures-directly with the input parameters as the table name and column name, cannot be recognized, first with ' + + ' stitching into a string, and then exec to execute, EXEC will still use this string as a statement executionCreate procfenye1@nowye int,--Current Page@number int,--number of rows displayed@tablename varchar( -),--table name@zhujian varchar( -)--primary Key name asexec('Select Top ('+@number+') *from'+@tablename+'where'+@zhujian+'Not in (select Top ('+@nowye+'-1) *'+@number+') '+@zhujian+' from'+@tablename+')')GoexecFenye12,1,'Student','Sno'---constraint: A constraint on the data value of a column, which specifies the range of values of the column--primary key, foreign key, non-null, self-growth representation column, unique column, check constraint--check constraint, find table, right-click Design--Select column, right-click Check Constraint--add-expression (expression must begin with column name)---Stored procedures accumulate sumsCreate procLeijiaqiuhe@a INT--Input parameter as Declare @b INT--Declaring variables Declare @i int--declaring Variables Set @i=1--assigning an initial value Set @b=0--assigning an initial value while @i<=@a--while Cycle conditions begin Set @b=@b+@i Set @i=@i+1-I.++End return @bGoDeclare @c intexec @c=LeijiaqiuheTenPrint @c-------Backup Restore--right-click database---Tasks--backup: Backs up data to a. Bak end folder without affecting the database's normal operation--restore: Restore bak file to database-----detach, attach--Detach: Detach a database from a database service--Attach: Attach the database MDF file to the database service
-- ---View: virtual tables -- CREATE VIEW View_1 -- as -- Go -- The equivalent of a query statement to an alias-view, as a virtual table -- subquery, the result set queried by the subquery, as a virtual temporary table to use (Sub-query statement) as + alias
SQL Server Note 8