SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Pr_GetDocuments]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[Pr_GetDocuments]
AS
SELECT
Document.*,Staff.RealName
FROM
Document
INNER JOIN
Staff
ON
Staff.Staff_ID = UserID and show='yes'
'
END
就是想显示show这列里面值为yes的所有记录。
------解决方案--------------------
- SQL code
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Pr_GetDocuments]') AND type in (N'P', N'PC'))BEGINEXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[Pr_GetDocuments]ASSELECT Document.*,Staff.RealNameFROM Document INNER JOIN Staff ON Staff.Staff_ID = UserID and show=''yes''' END