SQLServer 存储过程的使用

sql语句


declare @Sysid char(36),@ContractId nvarchar(50),@ContractName nvarchar(50),@ContractType nvarchar(50),@ContractOtherSide nvarchar(50),@TimeOfPerformance nvarchar(50),@HostDepartment nvarchar(50)
	,@CreatorName nvarchar(50),@DeptName nvarchar(50),@DataLevelId varchar(200),@DataLevelNo nvarchar(200),@DataLevelName nvarchar(900) ,@ContractMoney decimal(18,2),@CreateOn datetime,@PurchaseWay nvarchar(50),
	@PurchaseWayNo nvarchar(50),@ContractDescribe nvarchar(500),@Remark nvarchar(500)


	select @Sysid=SysId,@ContractId=ContractNo,@ContractName=ContractName,@ContractType=ContractType,@ContractOtherSide=ContractTheOtherSide,@TimeOfPerformance=ContractDeadline,
	@HostDepartment=HostDepartment,@CreatorName=CreatorName,@DeptName=DeptName,@DataLevelId=DataLevelId,@DataLevelNo=DataLevelNo,@DataLevelName=DataLevelName,@CreateOn=CreateOn,
	@ContractMoney=ContractMoney,@PurchaseWay=PurchaseWay,@PurchaseWayNo=PurchaseWayNo,@ContractDescribe=ContractDescribe,@Remark= Remark from OA_SignContract 
	where SysId='[EntityID]'


	insert into OA_ContractParameter  (SysId,ContractId,ContractName,ContractType,ContractOtherSide,TimeOfPerformance,HostDepartment,CreatorName,DeptName,DataLevelId,DataLevelNo,DataLevelName,ContractAmount,PerformanceState,CreateOn,PerformanceStateId,PurchaseWay,PurchaseWayNo,ContractDescribe,Remark) values
	(@SysId,@ContractId,@ContractName,@ContractType,@ContractOtherSide,@TimeOfPerformance,@HostDepartment,@CreatorName,@DeptName,@DataLevelId,@DataLevelNo,@DataLevelName,@ContractMoney,'生效',@CreateOn,'Effect',@PurchaseWay,@PurchaseWayNo,@ContractDescribe,@Remark)

存储过程的定义形式如下

declare @变量名 类型

@Sysid char(36)  //定义变量名为Sysid 类型为char(36)


赋值形式为  @Sysid=SysId

 可以把存储过程理解为定义变量 

int a

int b

var a

var b

你可能感兴趣的:(sqlserver,数据库)