>데이터 베이스 >MySQL 튜토리얼 >简单的存储过程的使用

简单的存储过程的使用

WBOY
WBOY원래의
2016-06-07 16:01:44938검색

创建存储过程: USE [AIS20140417092531] GO /****** Object: StoredProcedure [dbo].[HBSH_MS_BillType_in_ofmine] Script Date: 09/01/2014 14:34:24 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[HBSH_MS_BillType

创建存储过程:

USE [AIS20140417092531]
GO
/****** Object: StoredProcedure [dbo].[HBSH_MS_BillType_in_ofmine] Script Date: 09/01/2014 14:34:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[HBSH_MS_BillType_in_ofmine]
-- Add the parameters for the stored procedure here
@type varchar(20) --添加查询条件参数
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;


-- Insert statements for procedure here
--创建临时表,存放膜,胶供应商名称
CREATE TABLE #temp(

ID INT IDENTITY(1,1),
Name VARCHAR(50),
FType INT

)

INSERT INTO #temp
(
-- ID -- this column value is auto-generated
NAME,
FType


)

(
SELECT ts.FName,200
FROM t_Supplier ts
)

INSERT INTO #temp
(
-- ID -- this column value is auto-generated
NAME,FType
)
(
SELECT ts.FName,200 FROM AIS20140417092652.dbo.t_Supplier ts
)

INSERT INTO #temp
(
-- ID -- this column value is auto-generated
Name,
FType
)
VALUES
(
'河北智能',
200
)

INSERT INTO #temp
(
-- ID -- this column value is auto-generated
Name,
FType
)

(
SELECT to1.FName,201 FROM t_Organization to1
)

INSERT INTO #temp
(
-- ID -- this column value is auto-generated
Name,
FType
)

(
SELECT to1.FName,201 FROM AIS20140417092652.dbo.t_Organization to1
)

INSERT INTO #temp
(
-- ID -- this column value is auto-generated
Name,
FType
)

(
SELECT hmc.fname,hmc.ftype FROM AcctCommerce.dbo.HBSH_MS_CustomName hmc
)

SELECT t.Name,t.FType FROM #temp t where t.ftype=@type GROUP BY t.Name,t.FType

END

---执行添加条件内容

exec [HBSH_MS_BillType_in_ofmine] ' ' --单引号当中直接添加筛选的条件内容

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.