Viewing 15 posts - 151 through 165 (of 3,957 total)
I think the following will walk through FK relationships starting with a parent down through the affected tables.
DECLARE @Parent_Table SYSNAME = 'YourParentTable';
WITH TraverseTableHierarchy AS
(
-- Using the...
April 8, 2015 at 8:10 pm
I believe that this is also an option:
WITH SampleData(CustomerID, VisitDate) AS(
SELECT *
FROM (VALUES(908,CAST('2012-07-28 00:00:00.000' AS DATETIME)),
...
April 8, 2015 at 7:29 pm
jbrentbbutler (4/8/2015)
April 8, 2015 at 7:14 pm
Just for fun, here's another way using the SQL 2012 LEAD function:
DECLARE @Interval INT = 30
,@StartDT DATETIME =...
April 8, 2015 at 7:08 pm
kat35601 (4/8/2015)
WITH orders
AS --...
April 8, 2015 at 5:56 pm
ScottPletcher (4/8/2015)
SELECT cust_id,
...
April 8, 2015 at 5:52 pm
DennisPost (4/8/2015)
I've made that mistake before and seen others make it. It can be tricky to detect.
A colleague told me of a nifty trick today.
When releasing a trigger...
April 8, 2015 at 5:49 pm
jbrentbbutler (4/8/2015)
The may sound somewhat...
April 8, 2015 at 5:48 pm
Luis Cazares (4/8/2015)
After a quick speed test, I got the following execution times after 10 executions for one million rows.
-----------------------------------------------------------------------------------------
|Version | 1...
April 8, 2015 at 5:35 pm
GilaMonster (4/8/2015)
dwain.c (4/7/2015)
dwain.c (4/7/2015)
-- Some nitwit posting under the moniker of Dwain.C with a big fish for an avatar
-- gave me...
April 8, 2015 at 6:53 am
Excuse my Homer Simpson moment there! Doh! :w00t:
SELECT cust_id
,Avg_days_between_orders=DATEDIFF(day, MIN(order_date), MAX(order_date))/(COUNT(*)-1.)
FROM @orders
GROUP BY cust_id
HAVING COUNT(*) > 1;
Edit: Added divide by zero protection (HAVING).
April 8, 2015 at 5:48 am
Jim-S (4/8/2015)
Hi Dwain,No, I'm not aware. I assumed it was pretty much two slightly different methods to achieve the same result.
Alan has given you the more general form that...
April 8, 2015 at 1:48 am
pandeharsh (4/7/2015)
Very good article.
I read the article,
I didn't read the whole discussion that is going on.
I have...
April 8, 2015 at 12:00 am
Luis! So rare to see you posting a question I had to try to help out.
SELECT Cg.Fiid,
--Original Formula
SUBSTRING( CONVERT( varchar, Cg.Fiid...
April 7, 2015 at 7:45 pm
Alan.B (4/7/2015)
The article is very 2012-centric but discusses how to calculate a median in 2008 as...
April 7, 2015 at 7:04 pm
Viewing 15 posts - 151 through 165 (of 3,957 total)