Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««5152535455

Tally OH! An Improved SQL 8K “CSV Splitter” Function Expand / Collapse
Author
Message
Posted Wednesday, February 27, 2013 2:30 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:10 AM
Points: 1,289, Visits: 3,858
ChrisM@Work (2/27/2013)

...

About once a week, mate. Now I'm an old git I can blame it on declining memory. When I was a sprightly youngster it was more embarrassing.


I know what you mean, at least you are in a "safe place" here

It's worse when you make the silly mistakes in front of a client, insisting something is wrong or right when it patently isn't


MM




Post #1424408
Posted Wednesday, February 27, 2013 3:28 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:51 AM
Points: 5,608, Visits: 10,970
mister.magoo (2/27/2013)
ChrisM@Work (2/27/2013)

...

About once a week, mate. Now I'm an old git I can blame it on declining memory. When I was a sprightly youngster it was more embarrassing.


I know what you mean, at least you are in a "safe place" here

It's worse when you make the silly mistakes in front of a client, insisting something is wrong or right when it patently isn't


I know of at least one other old git who will be cackling his face off reading these posts


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1424436
Posted Wednesday, February 27, 2013 3:30 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:01 PM
Points: 10,989, Visits: 10,531
ChrisM@Work (2/27/2013)
I know of at least one other old git who will be cackling his face off reading these posts

Oi!




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1424438
Posted Wednesday, February 27, 2013 3:34 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:51 AM
Points: 5,608, Visits: 10,970
Paul White (2/27/2013)
ChrisM@Work (2/27/2013)
I know of at least one other old git who will be cackling his face off reading these posts

Oi!


Heh I didn't mean you specifically Paul, though you do have some history of spotting my embarrassing coding faux pas
Anyway, isn't it past your bedtime?


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1424441
Posted Wednesday, February 27, 2013 3:43 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:01 PM
Points: 10,989, Visits: 10,531
ChrisM@Work (2/27/2013)
Anyway, isn't it past your bedtime?

We can no longer be friends




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1424445
Posted Wednesday, February 27, 2013 3:51 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:51 AM
Points: 5,608, Visits: 10,970
Paul White (2/27/2013)
ChrisM@Work (2/27/2013)
Anyway, isn't it past your bedtime?

We can no longer be friends


Slippers are in the post


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1424449
Posted Wednesday, February 27, 2013 5:40 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:51 PM
Points: 32,906, Visits: 26,789
ChrisM@Work (2/27/2013)
mister.magoo (2/27/2013)
ChrisM@Work (2/27/2013)

...

About once a week, mate. Now I'm an old git I can blame it on declining memory. When I was a sprightly youngster it was more embarrassing.


I know what you mean, at least you are in a "safe place" here

It's worse when you make the silly mistakes in front of a client, insisting something is wrong or right when it patently isn't


I know of at least one other old git who will be cackling his face off reading these posts


Heh... nah... I've BIN there myself.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1424476
Posted Wednesday, March 13, 2013 9:29 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 1:03 PM
Points: 4, Visits: 30
Is there a reason that you mention subtracting the length of the final string from 8000 like so
ISNULL(NULLIF(CHARINDEX(@pDelimiter, @pString, s.N1), 0), 8000) - s.N1

and then in the final code you have
 ISNULL(NULLIF(CHARINDEX(@pDelimiter,@pString,s.N1),0)-s.N1,8000)

I just wanted to make sure I'm understanding the code correctly. It looks like it runs the same either way...
Post #1430722
Posted Monday, March 18, 2013 2:46 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 6:41 AM
Points: 124, Visits: 470
Did I miss something? I didn't have the patience to go over all 54 pages of replies. Initially when the code for the cteTally was changed to be faster it used a

SELECT 0 UNION ALL
...

However in the final function it unions with 1 instead of 0. I tried both versions in the final function and they bot work actually.



Don't just give the hungry man a fish, teach him how to catch it as well.

the sqlist

Post #1432347
« Prev Topic | Next Topic »

Add to briefcase «««5152535455

Permissions Expand / Collapse