任何人都可以请我提供一份包含以下内容的工作资料:
哪里包含(cars.brand, COALESCE(@ brand,cars.brand))和
答案 0 :(得分:0)
这应该让你开始,但你的WHERE子句需要工作。
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
SET NOCOUNT ON
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[theSprocName]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[theSprocName]
GO
CREATE PROCEDURE dbo.theSprocName
@brand varchar(250) -- change to suit the anticipated width.
AS
BEGIN
SELECT SomeField1, SomeField2
FROM cars
-- specify what criteria to filter by.
-- WHERE cars.brand
END
GO