Viewing 15 posts - 1,216 through 1,230 (of 1,244 total)
ScottPletcher (5/15/2015)
Never use BETWEEN on dates or datetimes;
Out of curiosity, why do you say this?
I could see it it you were talking about DATETIME data types only, simply...
May 15, 2015 at 2:39 pm
It depends... CAST is typically the preferred syntax being that it's an ansi standard... But, sometimes it's necessary, when working with different date/time data types to use the CONVERT function...
May 15, 2015 at 10:38 am
The reason it doesn't work in either of your original versions is because they are both attempting to concatenate a date datatype to a varchar data type... The two data...
May 14, 2015 at 10:45 pm
If keeping those rows is important... This doesn't seem to beat it up too bad...
IF OBJECT_ID('tempdb..#address') IS NOT NULL
DROP TABLE #address;
CREATE TABLE #address (
address_id INT,
addr1 CHAR(30),
addr2 CHAR(30),
...
May 14, 2015 at 8:55 pm
If the PO Numbers are all the same length, the "Shift + Alt" block typing trick works well too...
May 14, 2015 at 8:35 pm
Phil Parkin (5/14/2015)
Jason A. Long (5/14/2015)
That test was done using SQL Server 2014 Dev Edition. (Local instantaneous running on a laptop)Local instantaneous? That's fast!
WOW!!! I really am a big dumb...
May 14, 2015 at 12:32 pm
I don't recall recording any specific time measurements. I was more interested in verifying that the execution plan was changing based on the existence of index (and that the index...
May 14, 2015 at 10:12 am
That test was done using SQL Server 2014 Dev Edition. (Local instantaneous running on a laptop)
May 14, 2015 at 8:05 am
Phil Parkin (5/13/2015)
tom.w.brannon (5/13/2015)
May 13, 2015 at 8:13 pm
Luis beat me too it but I took the time to write it so I'm posting it... 😉
SELECT
a.Id,
a.Category,
MAX(a.CountID) AS OverallTotal,
SUM(a.CountCat) OVER (PARTITION BY a.Id, a.Category ORDER BY a.Date) AS...
May 13, 2015 at 2:58 pm
Thanks for the info Tom. Sounds like Phil's solution has the edge. I've never used the INTERSECT operator in anything before, so it looks like I've got some homework of...
May 13, 2015 at 12:34 pm
A tally table is simply a simple table that contains a single column of indexed integers.
Jeff Moden has a great article on the topic... The "Numbers" or "Tally" Table: What...
May 13, 2015 at 11:36 am
I can also make Jason's answer work, again by adding A to the OVER (ORDER BY ) clauses. One disadvantage of Jason's method for me is that I believe I...
May 13, 2015 at 11:26 am
Here's a slightly different approach...
IF OBJECT_ID('tempdb..#temp') IS NOT NULL
DROP TABLE #temp
GO
CREATE TABLE #temp (
A CHAR(1) NOT NULL,
B CHAR(1) NULL,
DTE DATE
)
INSERT #temp (A,B,DTE) VALUES
('1','1','2015-01-01'),
('1','1','2015-01-02'),
('1','1','2015-01-03'),
('2','1','2015-01-04'),
('1','1','2015-01-05'),
('1',NULL,'2015-01-06'),
('1',NULL,'2015-01-07'),
('2','1','2015-01-08'),
('2','1','2015-01-09'),
('2','2','2015-01-10')
;WITH BinVals AS (
SELECT
t.A,
t.B,
t.DTE,
CAST(t.A AS...
May 13, 2015 at 7:33 am
Viewing 15 posts - 1,216 through 1,230 (of 1,244 total)