Viewing 15 posts - 46 through 60 (of 7,602 total)
(1) If you have a lot of dbs, make the $IDENTITY column a primary key in the table, so you have a seek instead of a scan
(2) DBCC CHECKDB can...
December 21, 2024 at 8:09 am
And, that is the correct method for moving dbs to a new drive.
December 17, 2024 at 7:34 pm
IF you're on SQL 2022, you can add "IGNORE NULLS" to the LAG function.
Otherwise you can use an OUTER APPLY with a SELECT TOP (1). For example:
SELECT...
December 16, 2024 at 3:31 pm
First, you need to correct the query to use the alias in the UPDATE, not the original table name. Other things to consider if still having problems:
(1) How large is...
December 11, 2024 at 6:51 pm
AFTER UPDATE is the more current syntax, so I would go with that.
I would also (1) take advantage of the UPDATE() function and (2) allow the trigger to properly set...
December 9, 2024 at 3:42 pm
It depends. You'd need to look at the available indexes and whether SQL uses them for the query. So, look at the query plan and see what it "tells" you. ...
December 9, 2024 at 3:21 pm
To reduce space usage in that db, you can specify SORT_IN_TEMPDB = ON in the index create.
Also, to save time, pre-allocate additional log space, if needed. If you must get...
December 9, 2024 at 3:18 pm
The CostKeyDeletes tables should be clustered on CostKey, not on ID. It's best for it to match the original table's key. You can keep the ID, if you want, just...
December 6, 2024 at 7:19 pm
The SELECT INTOs will hold locks. Those might be causing issues.
One good way to avoid that is to an initial SELECT TOP (0) ... INTO to create the table, then...
December 2, 2024 at 6:41 pm
Wow, that's exceptional. I've never been at a place that had, say an "order" table vs. an "orders" table.
November 29, 2024 at 5:42 am
I wasn't sure StatusDate included a time. If it's just a date, it's not safe to ORDER BY it.
November 27, 2024 at 3:04 pm
I believe the more common, and better, naming for tables is plural. I can't think of a major relational dbms that uses singular system table names.
For example: sys.objects (SQL Server),...
November 27, 2024 at 2:52 pm
Yep, definitely remove ID. The key to a "relationship" table should be the relationship keys, NOT an ID column.
November 26, 2024 at 10:09 pm
;WITH ctePrevPrStatus AS (
SELECT *, LAG(PrStatus) OVER(PARTITION BY PrID ORDER BY StatusID) AS PrPrevStatus
FROM dbo.tblPresentationStatus
)
SELECT *
FROM ctePrevPrStatus
WHERE
...
November 26, 2024 at 7:26 pm
Viewing 15 posts - 46 through 60 (of 7,602 total)