關於SQL server的一些知識點

來源:互聯網
上載者:User

標籤:

  1. 關於怎麼開啟xp_cmdshell的方法:

    exec sp_configure ‘show advanced option‘,1
    reconfigure
    go
    exec sp_configure ‘xp_cmdshell‘,1
    reconfigure
    go

  2. 關於截取表欄位名稱:

    select NewName=left(trim(name),1) from student

  3. SQL暫存資料表的用法:

    select * into #A from student 將student內容插入到暫存資料表#A

  4. SQL添加表外部索引鍵關聯:
    alter table borrow add constraint FK_student foreign key(stuID) references student(stuID)
  5. SQL多表查詢:

    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根據表資料的個數添加對應的序號:

    update stu
    set sCount =
    (select Temp.value from (select sCode, value = 20 * ROW_NUMBER() over (order by sCode ) from stu) as Temp where Temp.scode = stu.sCode )

  7. SQL建立叢集索引和非叢集索引:

    CREATE CLUSTERED INDEX IX_Id ON Person(Id)

    CREATE NONCLUSTERED INDEX IX_Name ON Person(Name) --建立非叢集索引

關於SQL server的一些知識點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.