Viewing 15 posts - 1,036 through 1,050 (of 7,608 total)
SET ANSI_NULLS ON;
SET QUOTED_IDENTIFIER ON;
GO
CREATE TRIGGER tblTriggerAuditRecord
ON dbo.tblOrders
AFTER INSERT, UPDATE
AS
SET NOCOUNT ON;
INSERT INTO dbo.tblOrdersAudit
( OrderID, OrderApprovalDateTime, OrderStatus, /*...,*/ UpdatedBy, UpdatedOn )
SELECT i.OrderID, i.OrderApprovalDateTime, i.OrderStatus,...
January 20, 2022 at 6:10 pm
The most flexible way is to use CROSS APPLY:
SELECT d.ID, ca1.Amt, ca1.AmtReason
FROM #data d
CROSS APPLY (
SELECT TOP (1) Amt, AmtReason
...
January 20, 2022 at 6:04 pm
Read uncommitted (RU) simply doesn't take out some locks, allowing for reads as data gets changed. This can result in incorrect data, missing or duplicate data. Honestly, a scary...
January 20, 2022 at 5:47 pm
You could probably use TRIGGER_NESTLEVEL to do that.
I tend to use session context values instead, set via sys.sp_set_session_context and SESSION_CONTEXT(N'<key_name>'). If you want more info on this method, let me...
January 20, 2022 at 5:32 pm
Do you have an index on table_a that covers the UPDATE query? That could help prevent some contention.
You could also try to "help" SQL by explicitly "telling" SQL about the...
January 20, 2022 at 5:15 pm
I agree with Steve.
Also, wouldn't you want the MIN() time for the LogOn?
January 20, 2022 at 5:09 pm
The customer would have an identifying customer number and account number, and the ATM would have an identifying ATM number.
Therefore, the transaction would broadly only need to capture cust#, acct#,...
January 20, 2022 at 5:07 pm
That join is not needed.
are the data changes made by a trigger included in the transaction, so that they are rolled back if the INSERT or UPDATE on the table...
January 20, 2022 at 5:01 pm
The first big difference is that the second command is not valid, and thus won't run and therefore won't do anything.
January 17, 2022 at 4:29 pm
Instead of using a CASE expression (as you were trying) - or stacked OR's: WHERE @mDepth > iif(@tDepth = 0, -1, @tDepth)
Consider: @mDepth >= 0 is equivalent to @mDepth...
January 14, 2022 at 8:12 pm
The values go into the variables at the top.
You'll note that I declared the variables first, then SET them all together. I personally think it's much more confusing to mix...
January 14, 2022 at 8:10 pm
Verify that variable @CopyFromUser includes a valid value.
Add a PRINT statement in the script. Existing code:
...
From dbo.Operator
Where Operator_Ref = @CopyFromUser
SET @rowcount = @@ROWCOUNT
...
so that you can verify how many INSERTs...
January 14, 2022 at 6:07 pm
CASE is an expression not a statement. That means that the result of WHEN or THEN must be a single value. No operators (>,>=, etc.) and no keywords can be...
January 14, 2022 at 5:03 pm
I executed the script on an instance with 100s of dbs and it worked fine. Of course I got the "No insertions made..." message since I didn't have dbs named...
January 14, 2022 at 4:45 pm
I presume you want to know why, when running under the DP300User1 context, the SP works but the query on it's own does not.
When a SP is created by...
January 13, 2022 at 9:35 pm
Viewing 15 posts - 1,036 through 1,050 (of 7,608 total)