SQL build table, build SP

Source: Internet
Author: User

Give me a chestnut.

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 () 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 ' not done ' 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 (=null),
@Question nvarchar (=null),
@Answer nvarchar (=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][email protected]
SET NOCOUNT OFF
End
Go
Grant execute on [dbo]. [Testforekoy_uspstaffsecurity_update] to [Db_spexecute],[siteuser]
Go

SQL build table, build SP

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.