Some knowledge points about SQL Server

Source: Internet
Author: User

  1. Methods for how to open xp_cmdshell:

    exec sp_configure ' show advanced option ', 1
    Reconfigure
    Go
    exec sp_configure ' xp_cmdshell ', 1
    Reconfigure
    Go

  2. About Intercepting table field names:

    Select Newname=left (Trim (name), 1) from student

  3. SQL Temp Table Usage:

    SELECT * Into #A the FROM student inserts student content into the staging table #a

  4. SQL Add Table Foreign Key association:
    ALTER TABLE borrow ADD constraint fk_student foreign key (STUID) references student (STUID)
  5. SQL multi-Table query:

    Select Stuent.stuname,stuent.stuid,book.title,book. Bid,borrow. T_time from Student,book,borrow where Student.stuid=borrow.stuid,book. Bid=borrow. Bid,borrow. T_time between ' 2007-12-15 ' and ' 2008-1-8 '

  6. SQL adds the corresponding ordinal number based on the number of table data:

    Update Stu
    Set Scount =
    (Select Temp.value from (select SCode, value = $ * row_number () over [order by SCode] from Stu) as Temp where Temp.scode = Stu.scode)

  7. SQL to create clustered and nonclustered indexes:

    CREATE CLUSTERED INDEX ix_id on person (Id)

    Create nonclustered index ix_name on person (Name)--Creating a nonclustered index

Some knowledge points about SQL Server

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.