码迷,mamicode.com
首页 > 数据库 > 详细

关于SQL server的一些知识点

时间:2015-09-15 01:32:18      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

  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的一些知识点

标签:

原文地址:http://www.cnblogs.com/justhappy/p/4808942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!