Viewing 15 posts - 991 through 1,005 (of 3,957 total)
pietlinden (12/22/2013)
First off, thanks for taking the time to crank that out... Of course, it'll take me a while to figure it out!!!
...
In your example, the ID column is analogous...
December 22, 2013 at 11:14 pm
ndiro (12/21/2013)
select A.[Product Id] as ProductId,
'-' as SubProductId,
(
select exp(sum(log(quantity))) from product_table B
where isprimary = 0
and patindex(ltrim(rtrim(A.[Product Id]))+'.%',B.[Product Id]) > 0
) as Value
from product_table A
where
A.isPrimary =...
December 22, 2013 at 9:15 pm
You can try this:
CREATE TABLE #Data
(
ID INT
,N INT
,Flag INT
);
CREATE INDEX i1 ON #Data (ID, N);
CREATE...
December 22, 2013 at 5:21 pm
I'm not sure I'm getting the full meaning of your business rules, this being a Sat morning and me having a hangover. However...
Looking at the code that I provided,...
December 20, 2013 at 9:48 pm
Unfortunately I don't think you're going to be able to do it within the FUNCTION because of the error it is throwing but there is no reason you can't do...
December 19, 2013 at 11:30 pm
Note that if you want Quantity on the line with the SubProduct to be zero, just change this line:
VALUES(a.[Product Id], SubProduct, NULL), (a.[Product Id], NULL, b.TotalQty)
To...
December 19, 2013 at 9:55 pm
There are only 3 ways I can think of in SQL to get a running product. A recursive CTE, a CURSOR (gag me! :-P) and the Quirky Update (QU)....
December 19, 2013 at 7:00 pm
Sean Lange (12/19/2013)
December 19, 2013 at 5:57 pm
Sean Lange (12/19/2013)
December 19, 2013 at 5:18 pm
Jeff Moden (12/18/2013)
December 18, 2013 at 11:07 pm
Jeff Moden (12/18/2013)
December 18, 2013 at 11:03 pm
A very easy way to do this is with a pattern-based string splitter:
WITH SampleData (TestStr) AS
(
SELECT '01-08-087-0101W5'
)
SELECT *, DesiredResult=CAST(Item AS INT)
FROM SampleData
CROSS APPLY dbo.PatternSplitCM(TestStr, '[0-9]')
WHERE [Matched]=1;
The...
December 18, 2013 at 5:01 pm
Ed Wagner (12/16/2013)
The next thing we see will be Dwain saying he has snow ...
I wouldn't hold my breath. The last time I saw snow was in Toronto a...
December 16, 2013 at 8:25 pm
robert.l.craig (12/16/2013)
WITH Table1 (ID, Val) AS
(
SELECT prefix, cost
UNION ALL SELECT prefix, cost
UNION ALL SELECT...
December 16, 2013 at 6:29 pm
robert.l.craig (12/16/2013)
OK, the second query I don't quite understand. It looks like I would have to hand code each ID.
Are you perhaps confusing the sample data I set up in...
December 16, 2013 at 5:42 pm
Viewing 15 posts - 991 through 1,005 (of 3,957 total)