I have a stored procedure where I want to select ‘TransType = ‘100” at certain times of the day and then run the same procedure to run for ‘TransType !=’100’ at other times during the day.
This stored procedure is getting called by our external provider service which sends these transactions for creating GL/billing records according to the transaction type
The stored procedure looks something like this:
CREATE Stored Procedure InsertTransactions
INSERT INTO @t
SELECT TOP 50 D.[Id], D.CallId
FROM Transactions D WITH (NOLOCK)
LEFT OUTER JOIN TransactionsProcessed T WITH (NOLOCK) ON D.[Id] = T.[Id]
WHERE T.ProcessDate IS NULL
AND DatePart(mi,GetDate() - D.CreationDate) > 1
AND D.TransType='100'
;
INSERT INTO TransactionsProcessed
(
[Id],
CallId
)
(
SELECT [ID],CallId FROM @t
)
I want to add the filter D.TransType = 100
at 5am till 10am and then I want to run the same stored procedure for the filter ‘D.TransType !=’100”
What is the best way to achieve this? Should I create a reference table which stored hours in it and then the filter value updates automatically by checking this reference table ? But can’t think of how this reference table should be structured..
Sorry if I am not making much sense here. Please ask me questions if it is not clear
I am expecting the stored procedure to refer to the lookup table (which I will be creating) and then filter the records according to the hour of the day. If it is 5am till 10am, then apply filter TransType = ‘100’. Otherwise, if it is 10am to 3pm the apply the filter in the stored proc as TransType !=’100′
I am not sure if this is even possible…
user25935915 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1