Hi
I need help to write/modify a SP/script.
I have:
ALTER PROCEDURE [dbo].[test]
@Book varchar(8)
AS
set nocount on;
SELECT
Jobs.Number FJJobNo,
Jobs.UnitNo FJUnitNo,
Movs.Via FMVia,
Movs.DepDate,
Movs.DepLocation,
Movs.UnitNo FMUnitNo,
JobsMovs.MovNumber FJMMoNo,
MovsStatus.Status,
[Log].Event as LogEvent,
[Log].[Key] as LogKey
FROM
((([Log] WITH(READUNCOMMITTED)
INNER JOIN JobsMovs WITH(READUNCOMMITTED)
ON JobsMovs.MovNumber=[Log].[Key])
INNER JOIN Jobs WITH(READUNCOMMITTED)
ON Jobs.Number =JobsMovs.JobNumber)
INNER JOIN Movs WITH(READUNCOMMITTED)
ON JobsMovs.MovementNumber= Movs.Number)
INNER JOIN MovsStatus WITH(READUNCOMMITTED)
ON MovsStatus.MovNumber=Movs.Number
WHERE
@Book=Jobs.Comp
AND (year(Jobs.RepDate))>=2011
AND Jobs.Via IN ('Air','Sea')
AND Movs.Via IN ('Air','Sea')
AND MovsStatus.Status='C'
I have a report (Crystal Report) based on this, grouped by JobsMovs.MovNumber. In the report I hide all the records who have logevent in (doc1 print, doc2 print, doc3 print) for a JobsMovs.MovNumber. I write in the formula @docprint: if LogEvent in (‘doc1 print’, ‘doc2 print’, ‘doc3 print’) then 1 else 0, and I suppress the section Sum ({@doc print}, {JobsMovs.MovNumber })>=1. (doc1, doc2, doc3 are basically the same document, but in time, received another name in the table)
The report is working fine, but it’s slow.
I wonder if it’s possible to write in the stored procedure/script all this or there is a better solution to accomplish this.
I need help to write/modify a SP/script.
I have:
ALTER PROCEDURE [dbo].[test]
@Book varchar(8)
AS
set nocount on;
SELECT
Jobs.Number FJJobNo,
Jobs.UnitNo FJUnitNo,
Movs.Via FMVia,
Movs.DepDate,
Movs.DepLocation,
Movs.UnitNo FMUnitNo,
JobsMovs.MovNumber FJMMoNo,
MovsStatus.Status,
[Log].Event as LogEvent,
[Log].[Key] as LogKey
FROM
((([Log] WITH(READUNCOMMITTED)
INNER JOIN JobsMovs WITH(READUNCOMMITTED)
ON JobsMovs.MovNumber=[Log].[Key])
INNER JOIN Jobs WITH(READUNCOMMITTED)
ON Jobs.Number =JobsMovs.JobNumber)
INNER JOIN Movs WITH(READUNCOMMITTED)
ON JobsMovs.MovementNumber= Movs.Number)
INNER JOIN MovsStatus WITH(READUNCOMMITTED)
ON MovsStatus.MovNumber=Movs.Number
WHERE
@Book=Jobs.Comp
AND (year(Jobs.RepDate))>=2011
AND Jobs.Via IN ('Air','Sea')
AND Movs.Via IN ('Air','Sea')
AND MovsStatus.Status='C'
I have a report (Crystal Report) based on this, grouped by JobsMovs.MovNumber. In the report I hide all the records who have logevent in (doc1 print, doc2 print, doc3 print) for a JobsMovs.MovNumber. I write in the formula @docprint: if LogEvent in (‘doc1 print’, ‘doc2 print’, ‘doc3 print’) then 1 else 0, and I suppress the section Sum ({@doc print}, {JobsMovs.MovNumber })>=1. (doc1, doc2, doc3 are basically the same document, but in time, received another name in the table)
The report is working fine, but it’s slow.
I wonder if it’s possible to write in the stored procedure/script all this or there is a better solution to accomplish this.