sql建表,建sp

举个栗子

 

if object_id(N'[dbo].[TestForekoy_Mission]',N'u') is not null
    drop table [dbo].[TestForekoy_Mission]
go
create table [dbo].[TestForekoy_Mission]
(
    [Mno]          int     identity(100001,1)     not null  primary key,
    [Mname]        nvarchar(20)      not null,
    [Detail]       nvarchar(500),
    [DateRelease]  date,
    [State]        nvarchar(20)     
)
go
alter table [dbo].[TestForekoy_Mission] add constraint DF_TestForekoy_Mission_DateRelease default (GetDate()) for [DateRelease]
go
alter table [dbo].[TestForekoy_Mission] add constraint DF_TestForekoy_Mission_State default '未进行' for [State]
go

 

if object_id(N'[dbo].[TestForekoy_uspMission_Add]',N'p') is not null
    drop procedure [dbo].[TestForekoy_uspMission_Add]
go
create procedure [dbo].[TestForekoy_uspMission_Add]
    @Mname        nvarchar(20),
    @Detail       nvarchar(500),
    @DateRelease  date,
    @State        nvarchar(20)
as
begin
    set nocount on
    insert into [dbo].[TestForekoy_Mission]
    values(@Mname,@Detail,@DateRelease,@State)
    set nocount off
end
go
grant execute on [dbo].[TestForekoy_uspMission_Add] to [db_spexecute],[siteuser]
go

 

if object_id(N'[dbo].[TestForekoy_uspStaffSecurity_Update]',N'p') is not null
    drop procedure [dbo].[TestForekoy_uspStaffSecurity_Update]
go
create procedure [dbo].[TestForekoy_uspStaffSecurity_Update]
    @Sno        int          =null,
    @Password   varchar(20)  =null,
    @Question   nvarchar(50) =null,
    @Answer     nvarchar(50) =null,
 @InputWrong int          =null
as
begin
    set nocount on
    update [dbo].[TestForekoy_StaffSecurity]
    set [Password] = isnull(@Password,[Password]),
        [Question] = isnull(@Question,[Question]),
        [Answer]   = isnull(@Answer,[Answer]),
  InputWrong = isnull(@InputWrong,InputWrong)
    where [Sno]=@Sno
    set nocount off
end
go
grant execute on [dbo].[TestForekoy_uspStaffSecurity_Update] to [db_spexecute],[siteuser]
go

转载于:https://www.cnblogs.com/forekoy/p/6296669.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值