Home > database >  Why didn't CREATE the storage process, directly with the ALTER
Why didn't CREATE the storage process, directly with the ALTER

Time:04-01

 
USE [db_House]
GO
/* * * * * * Object: StoredProcedure [dbo] [proc_employee_insert] Script Date: 2021/3/31 8:50:19 * * * * * */
The SET ANSI_NULLS ON
GO
The SET QUOTED_IDENTIFIER ON
GO
The ALTER proc [dbo] [proc_employee_insert]
@ employee_ID varchar (10)=null,
@ employee_name varchar (20)=null,
@ employee_sex varchar (10)=null,
@ employee_birthday datetime,
@ employee_phone varchar (20),
@ employee_cardID varchar (20),
@ employee_address varchar (50),
@ gov_id varchar (16),
@ employee_study varchar (16),
@ employee_basepay numeric

As
Select @ employee_ID=Max (employee_ID) from tb_employee
If (@ employee_ID is null)
Set @ employee_ID='emp1001 - actuation see chart number will know what is
The else
The set @ employee_ID='emp + cast (cast (substring (@ employee_ID, 4, 4) as int) + 1 as varchar (20))

Insert into tb_employee values (@ employee_ID, @ employee_name, @ employee_sex,
@ employee_birthday, @ employee_phone @ employee_cardID,
@ employee_address, @ gov_id @ employee_study, @ employee_basepay)
End

CodePudding user response:

The alter is to modify, if have the stored procedure before, you need to alter, modify, if not, is the create

CodePudding user response:

The Proc, use the alter,
Don't need to be in the new, use the Create,

Can also, of course, no matter does not exist, first delete the Proc, create:
 
If the exists (select 1 from sysobjects where name='stored procedure named')
Drop the Proc [dbo]. [the stored procedure name]
Go
  • Related