USE [YL_MESDB]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE OR ALTER PROCEDURE [dbo].[设计报工_项目查询]
    @过滤 nvarchar(100) = N''
AS
BEGIN
    SET NOCOUNT ON;

    SELECT DISTINCT TOP 200
        CAST([项目代码] AS nvarchar(100)) AS [项目号],
        CAST([项目名称] AS nvarchar(200)) AS [项目名称]
    FROM [SAP].[SBO_YL].[dbo].[VIEW_OPRJ]
    WHERE
        ISNULL([项目代码], N'') <> N''
        AND
        (
            ISNULL(@过滤, N'') = N''
            OR CAST([项目代码] AS nvarchar(100)) LIKE N'%' + @过滤 + N'%'
            OR CAST(ISNULL([项目名称], N'') AS nvarchar(200)) LIKE N'%' + @过滤 + N'%'
        )
    ORDER BY [项目号];
END
GO
