创建存储过程:
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 [email protected] GROUP BY t.Name,t.FType
END
---执行添加条件内容
exec [HBSH_MS_BillType_in_ofmine] ‘ ‘ --单引号当中直接添加筛选的条件内容