Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .direct-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.4
2.2.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
namespace IntegrationTests.Tests.StoredProcedureTests;

/// <summary>
/// Integration tests for [omd].[GetConsistencyTimestamp]. Two Modules each load a target from their own
/// source table. Both latest load windows carry changes, as right after a load that brought new data.
/// </summary>
[TestClass]
public class OmdGetConsistencyTimestampTests : BaseTestContainer

Check warning on line 8 in Direct_Framework.Integration.Tests/Tests/StoredProcedureTests/OmdGetConsistencyTimestampTests.cs

View workflow job for this annotation

GitHub Actions / Integration tests

Because an application's API isn't typically referenced from outside the assembly, types can be made internal (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1515)
{
private const string SpName = "[omd].[GetConsistencyTimestamp]";
private const string TableList = "TGT_CONSISTENCY_A,TGT_CONSISTENCY_B";

private static readonly DateTime FirstLoadEnd = new(2026, 1, 1, 10, 0, 0);
private static readonly DateTime SecondLoadEnd = new(2026, 1, 1, 10, 5, 0);

[TestInitialize]
public async Task TestInitialize()
{
await ContainerManager.InitializeAsync();
await ContainerManager.PopulateDatabaseAsync();
await ArrangeTwoLoadedSourcesAsync();
}

[TestCleanup]
public async Task TestCleanup()
{
await ContainerManager.DisposeAsync();
}

/// <summary>
/// Source A was loaded up to <see cref="FirstLoadEnd"/> and source B up to <see cref="SecondLoadEnd"/>, each by
/// a succeeded Module Instance whose load window ends at the latest row of its source.
/// </summary>
private async Task ArrangeTwoLoadedSourcesAsync()
{
using var conn = new SqlConnection(ContainerManager.DirectConnectionString);
await conn.ExecuteAsync(@"
CREATE TABLE dbo.SRC_CONSISTENCY_A (KEY_VALUE INT NOT NULL, LOAD_DATETIME DATETIME2(7) NOT NULL, MODULE_INSTANCE_ID BIGINT NOT NULL);
CREATE TABLE dbo.SRC_CONSISTENCY_B (KEY_VALUE INT NOT NULL, LOAD_DATETIME DATETIME2(7) NOT NULL, MODULE_INSTANCE_ID BIGINT NOT NULL);

INSERT INTO omd.MODULE (MODULE_CODE, MODULE_TYPE, DATA_OBJECT_SOURCE, DATA_OBJECT_TARGET, AREA_CODE, FREQUENCY_CODE, MODULE_DESCRIPTION, ACTIVE_INDICATOR, EXECUTABLE)
VALUES (N'm_CONSISTENCY_A', N'Ingestion', N'dbo.SRC_CONSISTENCY_A', N'TGT_CONSISTENCY_A', N'STG', N'On-demand', N'Consistency test module A', 'Y', N'SELECT 1'),
(N'm_CONSISTENCY_B', N'Ingestion', N'dbo.SRC_CONSISTENCY_B', N'TGT_CONSISTENCY_B', N'STG', N'On-demand', N'Consistency test module B', 'Y', N'SELECT 1');

INSERT INTO omd.MODULE_INSTANCE (MODULE_ID, BATCH_INSTANCE_ID, START_TIMESTAMP, END_TIMESTAMP, INTERNAL_PROCESSING_CODE, NEXT_RUN_STATUS_CODE, EXECUTION_STATUS_CODE)
SELECT MODULE_ID, 0, SYSUTCDATETIME(), SYSUTCDATETIME(), N'Proceed', N'Proceed', N'Succeeded'
FROM omd.MODULE
WHERE MODULE_CODE IN (N'm_CONSISTENCY_A', N'm_CONSISTENCY_B');

INSERT INTO dbo.SRC_CONSISTENCY_A (KEY_VALUE, LOAD_DATETIME, MODULE_INSTANCE_ID)
SELECT 1, @FirstLoadEnd, mi.MODULE_INSTANCE_ID
FROM omd.MODULE_INSTANCE mi JOIN omd.MODULE m ON m.MODULE_ID = mi.MODULE_ID
WHERE m.MODULE_CODE = N'm_CONSISTENCY_A';

INSERT INTO dbo.SRC_CONSISTENCY_B (KEY_VALUE, LOAD_DATETIME, MODULE_INSTANCE_ID)
SELECT 1, @SecondLoadEnd, mi.MODULE_INSTANCE_ID
FROM omd.MODULE_INSTANCE mi JOIN omd.MODULE m ON m.MODULE_ID = mi.MODULE_ID
WHERE m.MODULE_CODE = N'm_CONSISTENCY_B';

INSERT INTO omd.SOURCE_CONTROL (MODULE_ID, MODULE_INSTANCE_ID, START_VALUE, END_VALUE)
SELECT mi.MODULE_ID, mi.MODULE_INSTANCE_ID, N'1900-01-01 00:00:00.0000000',
CONVERT(NVARCHAR(100), CASE m.MODULE_CODE WHEN N'm_CONSISTENCY_A' THEN @FirstLoadEnd ELSE @SecondLoadEnd END, 121)
FROM omd.MODULE_INSTANCE mi JOIN omd.MODULE m ON m.MODULE_ID = mi.MODULE_ID
WHERE m.MODULE_CODE IN (N'm_CONSISTENCY_A', N'm_CONSISTENCY_B');",
new { FirstLoadEnd, SecondLoadEnd });
}

private static async Task<(int ReturnCode, DateTime? ConsistencyDateTime, string? SuccessIndicator)> GetConsistencyTimestampAsync(SqlConnection conn)
{
var parameters = new DynamicParameters();
parameters.Add("@TableList", TableList, dbType: System.Data.DbType.String, size: -1);
parameters.Add("@ConsistencyDateTime", dbType: System.Data.DbType.DateTime2, direction: System.Data.ParameterDirection.Output);
parameters.Add("@SuccessIndicator", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: 1);
parameters.Add("@MessageLog", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: -1);
parameters.Add("@ReturnCode", dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.ReturnValue);

await conn.ExecuteAsync(SpName, parameters, commandType: System.Data.CommandType.StoredProcedure);

return (
parameters.Get<int>("@ReturnCode"),
parameters.Get<DateTime?>("@ConsistencyDateTime"),
parameters.Get<string?>("@SuccessIndicator"));
}

[TestMethod]
public async Task OmdGetConsistencyTimestamp_ReturnsLatestWindowEnd_WhenEverySourceIsFullyLoaded()
{
// Arrange
using var conn = new SqlConnection(ContainerManager.DirectConnectionString);

// Act
var (returnCode, consistencyDateTime, successIndicator) = await GetConsistencyTimestampAsync(conn);

// Assert
Assert.AreEqual(0, returnCode, "Stored procedure should return 0 on success.");
Assert.AreEqual("Y", successIndicator);
Assert.AreEqual(SecondLoadEnd, consistencyDateTime,
"Both sources are fully loaded, so all data up to the latest load window end is consistent; the earlier window end of source A must not hold it back.");
}

[TestMethod]
public async Task OmdGetConsistencyTimestamp_ReturnsLaggingWindowEnd_WhenASourceHasOutstandingRows()
{
// Arrange: source A receives a row after its latest load window, which has not been processed yet.
using var conn = new SqlConnection(ContainerManager.DirectConnectionString);
await conn.ExecuteAsync(@"
INSERT INTO dbo.SRC_CONSISTENCY_A (KEY_VALUE, LOAD_DATETIME, MODULE_INSTANCE_ID)
SELECT 2, DATEADD(MINUTE, 10, @FirstLoadEnd), MAX(MODULE_INSTANCE_ID)
FROM dbo.SRC_CONSISTENCY_A;",
new { FirstLoadEnd });

// Act
var (returnCode, consistencyDateTime, successIndicator) = await GetConsistencyTimestampAsync(conn);

// Assert
Assert.AreEqual(0, returnCode, "Stored procedure should return 0 on success.");
Assert.AreEqual("Y", successIndicator);
Assert.AreEqual(FirstLoadEnd, consistencyDateTime,
"Source A has outstanding rows, so its load window end is the consistency timestamp.");
}
}

// See references for test to code for assistants
// See: Direct_Framework\Stored Procedures\omd.GetConsistencyTimestamp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace IntegrationTests.Tests.StoredProcedureTests;

[TestClass]
public class OmdRunModuleTests : BaseTestContainer

Check warning on line 6 in Direct_Framework.Integration.Tests/Tests/StoredProcedureTests/OmdRunModuleTests.cs

View workflow job for this annotation

GitHub Actions / Integration tests

Because an application's API isn't typically referenced from outside the assembly, types can be made internal (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1515)
{
[TestInitialize]
public async Task TestInitialize()
Expand Down Expand Up @@ -49,5 +49,100 @@
"SELECT COUNT(*) FROM [omd].[EVENT_LOG] WHERE [EVENT_DETAIL] LIKE '%m_DOES_NOT_EXIST%';");

Assert.IsTrue(eventCount > 0, "A failed run of an unknown module code must appear in omd.EVENT_LOG.");

var eventDetail = await conn.ExecuteScalarAsync<string>(
"SELECT TOP 1 [EVENT_DETAIL] FROM [omd].[EVENT_LOG] WHERE [EVENT_DETAIL] LIKE '%m_DOES_NOT_EXIST%' ORDER BY [EVENT_ID] DESC;");
StringAssert.Contains(eventDetail, "is not registered in [omd].[MODULE], so there is nothing to run.",
"The event log must say why the module could not run, not only that no module instance was registered.");

var messageLog = parameters.Get<string>("@MessageLog");
StringAssert.Contains(messageLog, "is not registered in [omd].[MODULE]");
Assert.IsFalse(messageLog.Contains("The executable code retrieved is", StringComparison.Ordinal),
"An unknown module code must be reported before an (empty) executable code is retrieved.");
}

/// <summary>
/// With auto-registration on (the default), an unknown Module Code without a @Query has nothing to
/// run either. It must fail with the same clear reason instead of attempting a registration.
/// </summary>
[TestMethod]
public async Task RunModule_UnknownModuleCodeWithAutoRegistration_ReportsThatItIsNotRegistered()
{
using var conn = new SqlConnection(ContainerManager.DirectConnectionString);

var parameters = new DynamicParameters();
parameters.Add("@ModuleCode", "m_DOES_NOT_EXIST_EITHER");
parameters.Add("@Debug", "N");
parameters.Add("@SuccessIndicator", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: 1);
parameters.Add("@MessageLog", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: -1);

await conn.ExecuteAsync(
"EXEC [omd].[RunModule] @ModuleCode = @ModuleCode, @Debug = @Debug, @SuccessIndicator = @SuccessIndicator OUTPUT, @MessageLog = @MessageLog OUTPUT",
parameters);

Assert.AreEqual("N", parameters.Get<string>("@SuccessIndicator"));
StringAssert.Contains(parameters.Get<string>("@MessageLog"), "is not registered in [omd].[MODULE], so there is nothing to run.");

var registered = await conn.ExecuteScalarAsync<int>(
"SELECT COUNT(*) FROM [omd].[MODULE] WHERE [MODULE_CODE] = N'm_DOES_NOT_EXIST_EITHER';");
Assert.AreEqual(0, registered, "An unknown Module Code without code to run must not be registered.");
}

/// <summary>
/// A Module registered without a target data object carries the 'N/A' marker. After a failed run, the next
/// run rolls back first; that rollback has nothing to delete and must not run a DELETE against a table called
/// 'N/A'. The next run must fail for the same reason as the first one: the code it executes.
/// </summary>
[TestMethod]
public async Task RunModule_RerunAfterFailureWithoutTargetDataObject_FailsOnTheCodeAgain()
{
using var conn = new SqlConnection(ContainerManager.DirectConnectionString);
await conn.ExecuteAsync(
"EXEC [omd].[RegisterModule] @ModuleCode = N'm_FAILS_WITHOUT_TARGET', @ModuleAreaCode = N'STG', @Executable = N'SELECT 1/0';");

for (var run = 1; run <= 2; run++)
{
var parameters = new DynamicParameters();
parameters.Add("@SuccessIndicator", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: 1);
parameters.Add("@MessageLog", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: -1);

await conn.ExecuteAsync(
"EXEC [omd].[RunModule] @ModuleCode = N'm_FAILS_WITHOUT_TARGET', @Query = N'SELECT 1/0', @SuccessIndicator = @SuccessIndicator OUTPUT, @MessageLog = @MessageLog OUTPUT",
parameters);

Assert.AreEqual("N", parameters.Get<string>("@SuccessIndicator"), $"Run {run} executes a division by zero and must fail.");
}

var invalidObjectEvents = await conn.ExecuteScalarAsync<int>(
"SELECT COUNT(*) FROM [omd].[EVENT_LOG] WHERE [EVENT_DETAIL] LIKE N'%Invalid object name%';");
Assert.AreEqual(0, invalidObjectEvents, "The rollback must not address a target data object called 'N/A'.");

var divideByZeroEvents = await conn.ExecuteScalarAsync<int>(
"SELECT COUNT(*) FROM [omd].[EVENT_LOG] WHERE [EVENT_DETAIL] LIKE N'%Divide by zero%';");
Assert.AreEqual(2, divideByZeroEvents, "Both runs must fail on the executed code.");
}

/// <summary>
/// With auto-registration on (the default), an unregistered Module Code with a @Query is registered on the
/// fly in the maintenance area (MAINT), because the area is required and nothing else names one.
/// </summary>
[TestMethod]
public async Task RunModule_UnknownModuleCodeWithQuery_IsAutoRegisteredInTheMaintenanceArea()
{
using var conn = new SqlConnection(ContainerManager.DirectConnectionString);

var parameters = new DynamicParameters();
parameters.Add("@SuccessIndicator", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: 1);
parameters.Add("@MessageLog", dbType: System.Data.DbType.String, direction: System.Data.ParameterDirection.Output, size: -1);

await conn.ExecuteAsync(
"EXEC [omd].[RunModule] @ModuleCode = N'm_AUTO_REGISTERED', @Query = N'SELECT 1', @SuccessIndicator = @SuccessIndicator OUTPUT, @MessageLog = @MessageLog OUTPUT",
parameters);

Assert.AreEqual("Y", parameters.Get<string>("@SuccessIndicator"), parameters.Get<string>("@MessageLog"));

var areaCode = await conn.ExecuteScalarAsync<string>(
"SELECT [AREA_CODE] FROM [omd].[MODULE] WHERE [MODULE_CODE] = N'm_AUTO_REGISTERED';");
Assert.AreEqual("MAINT", areaCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DECLARE @tblMerge TABLE(

INSERT INTO @tblMerge([CODE], [VALUE], [GROUP], [DESCRIPTION], [ACTIVE_INDICATOR])
VALUES
(N'DIRECT_VERSION', N'2.2.4', N'SYSTEM_METADATA',
(N'DIRECT_VERSION', N'2.2.5', N'SYSTEM_METADATA',
N'The current version of the DIRECT Framework and database', 'Y')

,(N'LOG_TO_EVENT_LOG', N'Y', N'SETTINGS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* optionally linked to a Batch Instance, and captures executed code hash.
*
* @package DIRECT Framework
* @version 2.1.0
* @version 2.2.5
* @see https://github.com/data-solution-automation-engine/DIRECT
*
* @param {NVARCHAR(500)} @ModuleCode [in] (required)
Expand Down Expand Up @@ -178,8 +178,10 @@ BEGIN
[omd].[AddLogMessage](DEFAULT, DEFAULT, DEFAULT, @LogMessage, @MessageLog);

DECLARE @RegisterSuccessIndicator CHAR(1);
-- The area is required; an auto-registered Module has no known layer, so it lands in maintenance (MAINT).
EXEC [omd].[RegisterModule]
@ModuleCode = @ModuleCode,
@ModuleAreaCode = N'MAINT',
@Debug = @Debug,
@ModuleId = @ModuleId OUTPUT,
@SuccessIndicator = @RegisterSuccessIndicator OUTPUT,
Expand Down
31 changes: 25 additions & 6 deletions Direct_Framework/Stored Procedures/omd.GetConsistencyTimestamp.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* @procedure [omd].[GetConsistencyTimestamp]
* @description Compute the consistency timestamp across target tables as the minimum end-value of latest successful load windows.
* @description Compute the consistency timestamp across target tables as the minimum end-value of latest successful load windows
* of the sources that still have outstanding rows, or the maximum end-value when no source lags behind.
*
* @package DIRECT Framework
* @version 2.2.0
* @version 2.2.5
* @see https://github.com/data-engine-thinking/DIRECT
*
* @param {NVARCHAR(MAX)} @TableList [in] (required)
Expand All @@ -15,7 +16,7 @@
* @param {NVARCHAR(128)} @SourceModuleInstanceColumn [in] (optional, default='MODULE_INSTANCE_ID')
* Name of the column in the source data objects that holds the module instance id that loaded the row.
* @param {CHAR(1)} @SourceDataLookupIndicator [in] (optional, default='Y')
* 'Y' checks the source data objects for outstanding rows when a logical source group reports no changes.
* 'Y' checks the source data objects of every logical source group for outstanding rows beyond its load window.
* 'N' relies on the control tables only and treats such a group as up to date; use this when the data
* objects live in another engine (external orchestration) and the load windows are maintained explicitly.
* @param {CHAR(1)} @Debug [in] (optional, default='N')
Expand Down Expand Up @@ -451,7 +452,8 @@ WHERE COALESCE(INTERVAL_END_TIMESTAMP_ORDER, 0) = 1
PRINT CHAR(10) + 'Working on ' + @localDataObjectSource + ' with change for logical group change indicator ' + @localChangeForLogicalGroup + ' an local load window end datetime ' + CONVERT(VARCHAR(20), @localIntervalEndDatetime);
END

IF @localChangeForLogicalGroup = 'Y'
-- Without source data lookups, a change in the logical group means it may still be catching up.
IF @localChangeForLogicalGroup = 'Y' AND UPPER(COALESCE(@SourceDataLookupIndicator, 'Y')) <> 'Y'
BEGIN
INSERT INTO @ConsistencyDateTimeTable
VALUES
Expand All @@ -476,8 +478,11 @@ WHERE COALESCE(INTERVAL_END_TIMESTAMP_ORDER, 0) = 1
END
END

-- If the logical group is up to date, e.g. there are no changes then lookups to the sources are required to assert if there are any outstanding rows.
IF @localChangeForLogicalGroup = 'N' AND UPPER(COALESCE(@SourceDataLookupIndicator, 'Y')) = 'Y'
-- Look up the source to assert if there are any outstanding rows, whether or not the latest load window had changes.
-- A change only says that data was loaded, not that the source holds more: right after a load that brought data,
-- each source is typically complete up to its own load window end. Treating such a group as lagging would make
-- the earliest window end win and leave out the data that other sources loaded moments later.
IF UPPER(COALESCE(@SourceDataLookupIndicator, 'Y')) = 'Y'
BEGIN
DECLARE @localSourceMaxDateTime DATETIME2(7);

Expand Down Expand Up @@ -556,6 +561,20 @@ END
FROM
@ConsistencyDateTimeTable
WHERE COALESCE(UP_TO_DATE_INDICATOR, '') = 'N'

-- When no logical group lags behind its source, every target is complete up to its latest load window.
IF @ConsistencyDateTime IS NULL
BEGIN
SELECT
@ConsistencyDateTime = MAX(CONSISTENCY_DATETIME)
FROM
@ConsistencyDateTimeTable

IF @Debug = 'Y'
BEGIN
PRINT 'No logical group has outstanding rows, so the max load window end is used.';
END
END
END TRY

BEGIN CATCH
Expand Down
5 changes: 3 additions & 2 deletions Direct_Framework/Stored Procedures/omd.ModuleEvaluation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @description Determine whether a Module Instance can proceed based on current and prior instance states.
*
* @package DIRECT Framework
* @version 2.2.0
* @version 2.2.5
* @see https://github.com/data-engine-thinking/DIRECT
*
* @param {BIGINT} @ModuleInstanceId [in] (required)
Expand Down Expand Up @@ -427,7 +427,8 @@ BEGIN

DECLARE @LocalAreaCode NVARCHAR(100) = (SELECT omd.GetModuleAreaByModuleId(@ModuleId));

IF @TableCodeSafe <> 'N/A'
-- Compare the raw target: the quoted @TableCodeSafe reads '[N/A]' and never matches the 'no target' marker.
IF TRIM(COALESCE(@TableCode, N'')) NOT IN (N'', N'N/A')
BEGIN
--IF @LocalAreaCode = 'INT'
--SET @SqlStatement = 'DELETE FROM '+@TableCodeSafe+' WHERE (omd_module_instance_id IN '+@ModuleInstanceIdList+') OR (omd_update_module_instance_id IN '+@ModuleInstanceIdList+')';
Expand Down
12 changes: 6 additions & 6 deletions Direct_Framework/Stored Procedures/omd.PrintLog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @description Pretty-print a structured JSON message log to the Messages output pane.
*
* @package DIRECT Framework
* @version 2.1.0
* @version 2.2.5
* @see https://github.com/data-solution-automation-engine/DIRECT
*
* @param {NVARCHAR(MAX)} @MessageLog [in] (required)
Expand Down Expand Up @@ -80,7 +80,7 @@ BEGIN
)

DECLARE
@TableLine NVARCHAR(200) = REPLICATE('-', 170),
@TableLine NVARCHAR(200) = REPLICATE('-', 180),
@PrintSeverity NVARCHAR(100),
@PrintTimestamp NVARCHAR(100),
@PrintKey NVARCHAR(1000),
Expand All @@ -94,7 +94,7 @@ BEGIN
PRINT '| ' +
LEFT('Severity' + SPACE(8), 8) + ' | ' +
LEFT('Timestamp' + SPACE(19), 19) + ' | ' +
LEFT('Key' + SPACE(30), 30) + ' | ' +
LEFT('Key' + SPACE(40), 40) + ' | ' +
LEFT('Message' + SPACE(100), 100) + ' |';
PRINT @TableLine;

Expand All @@ -113,17 +113,17 @@ BEGIN
PRINT '| ' +
LEFT(ISNULL(@PrintSeverity, 'NULL') + SPACE(8), 8) + ' | ' +
LEFT(ISNULL(@PrintTimestamp, 'NULL') + SPACE(19), 19) + ' | ' +
LEFT(ISNULL(@PrintKey, 'NULL') + SPACE(30), 30) + ' | ' +
LEFT(ISNULL(@PrintKey, 'NULL') + SPACE(40), 40) + ' | ' +
LEFT(ISNULL(@PrintMessage, 'NULL') + SPACE(100), 100) + ' |';

IF LEN(@PrintKey) > 30 OR LEN(@PrintMessage) > 100
IF LEN(@PrintKey) > 40 OR LEN(@PrintMessage) > 100
BEGIN
-- Print Formatted Table Contents Line 2 for longer messages
-- For even longer messages, review the contents of the log directly
PRINT '| ' +
SPACE(8) + ' | ' +
SPACE(19) + ' | ' +
LEFT(ISNULL(SUBSTRING(@PrintKey, 31, 30) , 'NULL') + SPACE(30), 30) + ' | ' +
LEFT(ISNULL(SUBSTRING(@PrintKey, 41, 40) , 'NULL') + SPACE(40), 40) + ' | ' +
LEFT(ISNULL(SUBSTRING(@PrintMessage, 101, 100), 'NULL') + SPACE(100), 100) + ' |';
END

Expand Down
Loading
Loading