Files
DP44/DataPRO_sql/dbo.sp_TestObjectsGet.StoredProcedure.sql
2026-04-17 14:55:32 -04:00

76 lines
2.8 KiB
Transact-SQL
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestObjectsGet]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_TestObjectsGet]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestObjectsGet]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_TestObjectsGet] AS'
END
GO
ALTER PROCEDURE [dbo].[sp_TestObjectsGet]
@TestObjectName nvarchar(50) = null
,@TemplateName nvarchar(50) = null
,@SysBuilt bit = null
AS
BEGIN
SET NOCOUNT ON;
declare @TemplateId int
declare @TestObjectId int
set @TemplateId = dbo.foo_IdGetTemplate(@TemplateName)
set @TestObjectId = dbo.foo_IdGetTestObject(@TestObjectName)
SELECT [TestObjectName]
,tob.[LastModifiedBy]
,tob.[LastModified]
,tt.[TemplateName]
,tob.[LocalOnly]
,tob.[ParentObject]
,tob.[SysBuilt]
,tob.[OrigSerialNumber]
,tob.[OrigTemplate]
,tob.[Embedded]
FROM [dbo].[TestObjects] tob inner join [dbo].[TestObjectTemplates] tt on tt.TemplateId = tob.TemplateId
where
(@TestObjectName is null or tob.TestObjectId = @TestObjectId)
and (@TemplateName is null or tt.TemplateId = @TemplateId)
and (@SysBuilt is null or tob.SysBuilt = @SysBuilt)
END
GO