SQL Server Note 8

Source: Internet
Author: User

---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

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.