当前位置: 代码迷 >> Sql Server >> 存储过程根据字段的某个特定值来显示这一条记录解决方法
  详细解决方案

存储过程根据字段的某个特定值来显示这一条记录解决方法

热度:83   发布时间:2016-04-27 12:31:32.0
存储过程根据字段的某个特定值来显示这一条记录
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
  相关解决方案