Forum Replies Created

Viewing 15 posts - 1,711 through 1,725 (of 6,036 total)

  • RE: the use of CTEs

    erics44 (1/7/2016)


    You spoilt a good thread boys!

    Define "spoilt".

    It's all the matter of preferences, you know.

  • RE: the use of CTEs

    Jason A. Long (1/6/2016)


    But you were 11 mins too slow... 😛

    Sorry, was having lunch, and did not refresh the page before hitting "Add Reply".

    Did not even bother checking email notifications...

    Shame...

  • RE: the use of CTEs

    ALTER FUNCTION [dbo].[DelimitedSplit8K_NoCTE]

    --===== Define I/O parameters

    (@pString VARCHAR(8000), @pDelimiter CHAR(1))

    --WARNING!!! DO NOT USE MAX DATA-TYPES HERE! IT WILL KILL PERFORMANCE!

    RETURNS TABLE AS

    ...

  • RE: the use of CTEs

    Complete version, including non-CTE on-fly Tally table:

    DECLARE @pString VARCHAR(8000), @pDelimiter CHAR(1)

    SET @pString = 'aaaa,,ccc,d,'

    SET @pDelimiter = ','

    SELECT ItemNumber = ROW_NUMBER() OVER(ORDER BY cteLen.N1),

    ...

  • RE: the use of CTEs

    Lynn Pettis (1/6/2016)


    Unfortunately you failed to recreate the function as originally coded. You are relying on the existence of a tally table in the database. The original DelimitedSplit8K...

  • RE: the use of CTEs

    Luis Cazares (1/6/2016)


    I'll just want some help from those who prefer subqueries over CTEs to transform one of our favorites functions.

    Here you go:

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE FUNCTION [dbo].[DelimitedSplit8K_NoCTE]

    --===== Define...

  • RE: the use of CTEs

    Luis Cazares (1/6/2016)


    I'll just want some help from those who prefer subqueries over CTEs to transform one of our favorites functions.

    You know, people been splitting delimited lists for many years...

  • RE: the use of CTEs

    Lynn Pettis (1/6/2016)


    Same could be said if you populate temporary tables with the results of a complex query and then use that table in another query. You have to...

  • RE: the use of CTEs

    GilaMonster (1/6/2016)


    No, and that's not what Lynn said.

    Subqueries and CTEs are both part of a larger statement. Compilation is at the batch level, each statement in a batch gets compiled....

  • RE: the use of CTEs

    erics44 (1/6/2016)


    and even if you have a senior developer, everyone writes code that they go back to later and think, what was I thinking when I wrote that pile of...

  • RE: the use of CTEs

    Hugo Kornelis (1/6/2016)


    In theory it is also possible that the optimizer decides to first get the results of the CTE, store them in a worktable (called a Spool in the...

  • RE: the use of CTEs

    Lynn Pettis (1/6/2016)


    I find CTEs help when writing complex queries. They allow you to build up a query in steps, finding and isolating the data you need to complete...

  • RE: the use of CTEs

    jaime.simancas 27970 (1/6/2016)


    but CTEs have their place in making these "Sets" easier to read..

    Very questionable. Very.

    CTE's break the structure of Structured Query Language, moving part of FROM effectively out of...

  • RE: the use of CTEs

    Hugo Kornelis (1/6/2016)


    A CTE allows you to define a complex subquery once and refer to it multiple times in the same query without repeating the code. Technically possible before CTE,...

  • RE: the use of CTEs

    GilaMonster (1/6/2016)


    Sergiy (1/5/2016)


    try to explain why CTE construction must be prefixed with ";" - there is no such requirement for any other language construction.

    THROW - Previous statement must be ;...

Viewing 15 posts - 1,711 through 1,725 (of 6,036 total)