Viewing 15 posts - 886 through 900 (of 3,957 total)
j.heidrich (1/21/2014)
I tried the two different approaches from dwain.c with my sample table with 100k nvarchar(50) strings. On my machine with Win 8 64, SQL Server...
January 21, 2014 at 2:55 am
OK, so the purists will argue that LAG is overkill, and for them I offer this instead:
WITH SampleData AS
(
SELECT code=CAST('12333345566689333' AS NVARCHAR(4000))
UNION...
January 21, 2014 at 12:01 am
Just to be different, and seeing as how we are in the SQL 2012 forum which allows me to use LAG, I will offer this:
WITH SampleData AS
(
...
January 20, 2014 at 11:38 pm
So you've posted DDL which is a good start:
vignesh.ms (1/17/2014)
this is the sample table
create table #sample
(
Productid varchar(10),
purchasedate datetime,
customerid varchar(100)
);
And expected output in the pretty table you posted. ...
January 20, 2014 at 5:47 pm
pietlinden (1/20/2014)
http://www.manning.com/nielsen/SampleChapter5.pdfFrom SQL Server Deep Dives. I think I need to buy this book... <g>
There is also this article...
http://sqlmag.com/sql-server-2012/solving-gaps-and-islands-enhanced-window-functions
using LAG/LEAD. definitely worth a read!
LAG/LEAD, while interesting, are...
January 20, 2014 at 5:43 pm
rcnewcomb 53012 (1/20/2014)
January 20, 2014 at 5:20 pm
First of all, thanks to all for reading the article and providing feedback.
I have to agree with Charles in that error handling in SPs can be a bit tedious and...
January 20, 2014 at 5:18 pm
I agree that you've done some very thorough testing here. Excellent work!
Dohsan (1/17/2014)
Dwain
Ándre, Ándre, Luís And O'Brien Had A Low-Budget 3D Printer In Washington D.C.
I wasn't sure how you...
January 17, 2014 at 5:22 pm
I'm sure that this can be improved upon but it was fun while it lasted.
WITH DupItems AS
(
SELECT WONum, ItemCnt=MAX(ItemCnt)
FROM
...
January 17, 2014 at 1:12 am
Perhaps something like this might help?
CREATE FUNCTION [dbo].[ProperCase]
(
@MyStr ...
January 16, 2014 at 11:44 pm
Jeff Moden (1/16/2014)
dwain.c (1/16/2014)
January 16, 2014 at 8:57 pm
I'm curious if there's any danger to doing something like this:
DECLARE @sql VARCHAR(MAX) =
(
SELECT 'DROP TABLE ' + STUFF(
(
...
January 16, 2014 at 6:17 pm
My cat Grumpy will not be pleased that you left him out. 😀
January 16, 2014 at 6:07 pm
Why can't you just add up the 7 days and show that as the Total?
Or do you need to update the Total column in the table?
It would be nice if...
January 16, 2014 at 5:56 pm
I must say, I love the technique Jeff! Very simple, straightforward and clean with good performance. Nothing more straightforward comes immediately to mind (issues noted above aside).
Normally I...
January 16, 2014 at 5:52 pm
Viewing 15 posts - 886 through 900 (of 3,957 total)