zoukankan      html  css  js  c++  java
  • sqlserver 常用的语句

    1.更新一个字段的类型

    alter table VendorForm
    alter column applicationCode char(30)

    2.添加/删除一个字段

    if Exists( select * from syscolumns where id = OBJECT_ID('Chop_ApplicationInfo') and name = 'junctionChop')
    alter table Chop_ApplicationInfo
    add junctionChop char(8)

    删除

    alter table  TableName

    drop column deleted

    3.更新表中一个字段的值

      update Student

      set age =29  where Id = 2

    4.更新表列名字的值

    sp_rename 'DAT_Form_4_1_1_D1.Name','name','column'

    5.更新表名字的值

    sp_rename 'DAT_Family','DAT_FamilyOld'

    6.在表中插入一行数据

    insert into Student ( name, age) 

    values 

    ('Tom', 28),

    ('LiLy', 25)

    7.创建表

    create table TableName ( 

      [Id] [int] IDENTITY(1,1) NOT NULL,
      [category] [nvarchar](128) not NULL

    )

    8.创建视图

    create view ViewName 

    as 

    select

      a.Id

      b.address

    from student as a

    left join school as b on a.schoolid = b.id;

    9.创建自定义函数

      标量值函数:

      create FUNCTION fn_week (@id int) 

      returns int 

      AS

      begin

        declare @d int

        set @d = Year(NOW()) + @id;

        return @d;

      end

      

      表值函数:

      create FUNCTION  Fun_Proc_WorkItem_AgencyApplication ( @ id  int)

      returns  table

      as

      return (

        select * from Student where id = @id

      )

    10.创建存储过程

      create PROCEDURE  PRO_Update_Student  @id

      AS

      BEGIN

        update Student set deleted = 1

        where id = @id

      END

  • 相关阅读:
    vue
    vue
    vue 中使用style(样式)
    vue 中使用class(样式)
    第17课
    第16课
    第15课
    第14课
    第13课
    第12课
  • 原文地址:https://www.cnblogs.com/kingsmart/p/12884214.html
Copyright © 2011-2022 走看看