Viewing 15 posts - 1,861 through 1,875 (of 7,608 total)
As stated, we really need a query plan. But this is always true: instead of "(select count(...) ...) > 0" you can just do an EXISTS check. You don't really...
February 24, 2021 at 3:24 pm
If you can count on the values being the same length and/or there are only a very limited number of length variations, you could just SUBSTRING the data from the...
February 24, 2021 at 3:19 pm
Most people won't know the trick of of embedding a SELECT N=0 UNION ALL to make the "-1" calculation unnecessary.
I do know that trick, and have used it myself,...
February 22, 2021 at 11:49 pm
Here's an alternative method, just for the heck of it:
SELECT
begin_time, end_time,
LEFT(end_time, ISNULL(NULLIF(LEN(end_time) - 2, -1), 0)) * 60...
February 22, 2021 at 5:56 pm
SUM(Revenue) OVER( PARTITION BY Region, Year, Month )
February 22, 2021 at 4:59 pm
Oops, seems not to be the case. You just need to set max mem. Maybe I'm remembering from an earlier version of SQL?!
February 19, 2021 at 7:44 pm
Jo,
As I researched, SQL locks pages in memory so with SQL max memory set at 480 GB,
I thought SQL only locked SQL pages in memory if the max and...
February 19, 2021 at 7:25 pm
If you do create a tally table, page compress it at 100 fillfactor. That will save significantly on the overhead of reading the table. And, since that table is static,...
February 19, 2021 at 7:22 pm
In SQL Server, the CASE WHEN/THEN results are scalar (single) values only: keywords, operators, etc. are not allowed. Thus, you need something more like below.
Edit: That said, the expressions within...
February 19, 2021 at 7:05 pm
SQL works based on tables. By definition, a SQL Server table must have a name.
To look at my own version of this:
SELECT * FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) AS numbers(number)
The VALUES clause is...
February 19, 2021 at 3:57 pm
Nvm, OOPS, I posted this same code earlier.
February 18, 2021 at 10:16 pm
SET ANSI_NULLS ON;
SET QUOTED_IDENTIFIER ON;
GO
ALTER FUNCTION [DP].[GetYears] ( @StartYear AS INT )
RETURNS TABLE
AS
RETURN
WITH
tally10 AS (
SELECT * FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) AS numbers(number)
),
tally1000 AS (
...
February 18, 2021 at 9:31 pm
You can change the default file locations when installing SQL Server. You can also move the system databases later if you want to.
I have always found this to...
February 18, 2021 at 8:20 pm
After the 30 days, move them to some type of historical table. Personally I would never permanently delete such data. Compress it to the max and it will take very...
February 18, 2021 at 8:18 pm
DECLARE @StartYear SMALLINT = 2017;
SELECT DATETIMEFROMPARTS(@StartYear + number, 1, 1, 0, 0, 0, 0) AS StartDate,
@StartYear +...
February 18, 2021 at 8:15 pm
Viewing 15 posts - 1,861 through 1,875 (of 7,608 total)