The code looks like this, and it's clear:
--To add a project large class stored procedure UsechaiqianD2Goif object_id('P_insertbigtype','P') is not NULLDrop procedureP_insertbigtypeGoCreate procedureP_insertbigtype@Name nvarchar( -)--[Big class name] as begin Insert into [major categories of projects]([Large class name]) Values(@name)End
2, a bit difficult to drip, most of them do not use it
--add household and household information UsechaiqianD2IF object_id('P_insertfamilymember','P') is not NULLDROP PROCEDUREP_insertfamilymemberGOCREATE PROCEDUREP_insertfamilymember@name NVARCHAR( -),--name @sex CHAR(2),--Sex @idNumber NVARCHAR( -),--ID Number @workUnit NVARCHAR( -),--Work Unit @workUnitAddress NVARCHAR( -),--Address of work unit @accountAddress NVARCHAR( -),--Account Location @accountNature CHAR(Ten),--hukou Nature @residentialAddress NVARCHAR( -),--Residential Address @mobileNumber CHAR( A),--Mobile phone number @remarks NVARCHAR( $),--Notes @titles NVARCHAR(Ten),--appellation @nation NVARCHAR( the),--ethnic @politicStatus NVARCHAR( -),--political landscape @familyId INT = NULL,--Family Number @accounts INT,--total number of accounts @houseNature NVARCHAR(Ten),--Housing Properties @phoneNumber NVARCHAR( A),--Phone number @familyAddress NVARCHAR( -),--Home Address @projectId INT,--Demolition Project Number @priorityBusinessArea FLOAT,--The size of the business Room can be purchased @priorityHousingArea FLOAT,--Affordable Housing Area @typistId INT,--Entry Clerk position serial number @flag INT = 0 --flag Information, 0: Add family members, 1: Add household information and family information asBEGIN SETXact_abort on;--This sentence must be added BEGIN TRANSACTIONMytran--Add Home Information IF @flag = 1 BEGIN INSERT intofamily (number of family members, total number of accounts, housing nature, telephone number, home address, job serial number _ Input)VALUES(0,@accounts,@houseNature,@phoneNumber,@familyAddress,@typistId) --get a family number SELECT @familyId = MAX(family number) fromFamilyWHEREJob Serial Number _ input Clerk= @typistId END IF @flag = 1 BEGIN INSERT intoHome Settlement (demolition item number, family number, can purchase the business room area, can purchase the housing area)VALUES(@projectId,@familyId,@priorityBusinessArea,@priorityHousingArea) END --Add a family member INSERT intofamily member (family number, name, gender, ID number, work unit, work address, account location, account nature, residence address, mobile number, remark, appellation, nationality, political appearance)VALUES(@familyId,@name,@sex,@idNumber,@workUnit,@workUnitAddress,@accountAddress,@accountNature,@residentialAddress,@mobileNumber,@remarks,@titles,@nation,@politicStatus) --number of family population plus one UPDATEFamilySETNumber of family population=Number of family population+ 1 WHEREFamily number= @familyId COMMIT TRANSACTIONMytranEND
View Code
Example of a stored procedure with SQL Server attached