Viewing 15 posts - 1,441 through 1,455 (of 3,957 total)
PiMané (9/23/2013)
dwain.c (9/23/2013)
As Jeff said, NM=Nice Method (?).Except I think that P.[Path] should be p.Order_val in the recursive leg of your CTE.
Yes, had to change it to work...
September 23, 2013 at 3:29 am
hunchback (9/22/2013)
WITH C1 AS (
SELECT
Id, IdRoot, Name, Position,
CAST(ROW_NUMBER() OVER(ORDER...
September 23, 2013 at 3:22 am
Charlottecb (9/23/2013)
Hi dwain.c,Yep that works for me - I'll scale up my data to see how it performs against the other solutions.
Many thanks for responding.:-D
You are welcome and thanks for...
September 23, 2013 at 2:58 am
Something like this perhaps?
WITH SampleData ([Key], Col1, Col2) AS (
SELECT 1, 'ABC', 'DEF'
UNION ALL SELECT 2, 'GFI', 'XYZ')
SELECT Col1=MAX(CASE WHEN [Key]=Key1 THEN...
September 23, 2013 at 2:56 am
The parsing isn't so bad if you use a pattern splitter function and all of your constrains are like this IN type.
WITH CheckConstraint ([definition]) AS (
select...
September 23, 2013 at 2:37 am
Does this work for your case?
WITH Orders AS
(
SELECT *
,rn=ROW_NUMBER() OVER (PARTITION BY CustomerID ORDER BY OrderID DESC)
...
September 23, 2013 at 2:13 am
I agree that passing in a subquery for the TYPEd table instead of having to predefine the table would be nice but as you have ascertained, SQL doesn't support it...
September 22, 2013 at 7:07 pm
Not sure but perhaps this is a simpler approach?
CREATE TABLE #tTable(
sk int NOT NULL IDENTITY UNIQUE CLUSTERED,
CID INT,
CDate DATETIME,
Dept VARCHAR(10)
);
INSERT INTO #tTable(CID, CDate, Dept)
VALUES
(111,'2012-10-05 00:00:00.000','A'),
(111,'2012-10-18 00:00:00.000','C'),
(111,'2012-11-01 00:00:00.000','B'),
(111,'2012-11-01...
September 22, 2013 at 6:56 pm
Lynn Pettis (9/21/2013)
hisakimatama (9/21/2013)
Lynn Pettis (9/21/2013)
September 22, 2013 at 6:31 pm
Don Cureton (9/19/2013)
I seem to remember getting an error without a partition statement
ROW_NUMBER() does not require a PARTITION clause.
Some of the other window aggregates, e.g., MAX(xx), MIN(xx), AVG(xx), do.
September 19, 2013 at 11:38 pm
kevin 32621 (9/19/2013)
Thanks Dwain that worked great. Now on to the next thing to bang my head against the wall for! 😀Kevin
You need what I have, which is a vibration...
September 19, 2013 at 9:29 pm
kevin 32621 (9/19/2013)
September 19, 2013 at 8:30 pm
Do you mean something like this?
WITH SampleData (MyDate, StartTime, EndTime) AS (
SELECT '2013-09-20 08:20', '09:00', '11:00'
UNION ALL SELECT '2013-09-20 09:20', '09:00', '11:00'
...
September 19, 2013 at 8:17 pm
I agree with MM that simply knowing PATINDEX, CHARINDEX and SUBSTRING and playing around a bit, you should be able to construct a working solution.
Another alternative if you are inclined...
September 19, 2013 at 8:10 pm
A little DDL and sample data would have helped, but in this case it was easy enough to generate.
DECLARE @Contacts TABLE
(
ContactID INT IDENTITY PRIMARY...
September 19, 2013 at 7:53 pm
Viewing 15 posts - 1,441 through 1,455 (of 3,957 total)