Skip to content

Conversation

@srutzky
Copy link
Contributor

@srutzky srutzky commented Jan 16, 2018

  1. Added relevant function links to See also sections. "Relevant" is based on a general operation, such as: converting the value between types, modifying the contents of the string, taking sections of the string, finding something within the string, generating strings, determine a character value or create a character from a value, etc. The idea is to increase the chances that people can find something helpful that they might not have known the name of.

  2. As much as possible made See also sections consistent with actual functions listed first, then generic function list pages, etc after.

  3. Changed link title encoding where necessary to be consistent such that ( and ) are HTML-encoded as ( and ), respectively (instead of as just parenthesis).

  4. Added STRING_AGG to Aggregate Functions page (new as of SQL Server 2017). It is a valid aggregate function and behaves consistently with the definition on that page as the two tests below show: a) it works in a HAVING clause, and b) it ignores NULLs.

    SELECT tmp.[ID], STRING_AGG(tmp.[name], '~')
    FROM  (VALUES (1, 'a'), (2, 'gg'), (1, 'b'), (2, 'hh'), (3, 'zzz')) tmp (ID, [name])
    GROUP BY tmp.[ID]
    HAVING STRING_AGG(tmp.[name], '~') = 'hh~gg';

    returns:

    2	hh~gg
    

    And:

    SELECT tmp.[ID], STRING_AGG(tmp.[name], '~')
    FROM  (VALUES (1, 'a'), (2, 'zzz'), (1, 'b'), (2, NULL), (2, 'gg')) tmp (ID, [name])
    GROUP BY tmp.[ID];

    returns:

    1	b~a
    2	gg~zzz
    

It's a valid aggregate function as the two tests below show: it works in a HAVING clause, and it ignores NULLs.

SELECT tmp.[ID], STRING_AGG(tmp.[name], '~')
FROM  (VALUES (1, 'a'), (2, 'gg'), (1, 'b'), (2, 'hh'), (3, 'zzz')) tmp (ID, [name])
GROUP BY tmp.[ID]
HAVING STRING_AGG(tmp.[name], '~') = 'hh~gg';
-- 2	hh~gg


SELECT tmp.[ID], STRING_AGG(tmp.[name], '~')
FROM  (VALUES (1, 'a'), (2, 'zzz'), (1, 'b'), (2, NULL), (2, 'gg')) tmp (ID, [name])
GROUP BY tmp.[ID];
-- 1	b~a
-- 2	gg~zzz
@PRMerger3
Copy link
Contributor

@srutzky : Thanks for your contribution to the SQL documentation! The author, @edmacauley, has been notified to review your proposed change.

@edmacauley
Copy link
Contributor

Thanks for these changes, @srutzky #sign-off

@PRMerger20
Copy link
Contributor

Only the author, @edmaca, can sign off on this pull request.

@edmacauley
Copy link
Contributor

@craigg-msft can you merge?

@craigg-msft
Copy link
Contributor

Thank you @srutzky and @edmacauley

@craigg-msft craigg-msft merged commit 3391111 into MicrosoftDocs:live Jan 17, 2018
@srutzky
Copy link
Contributor Author

srutzky commented Jan 18, 2018

@edmacauley and @craigg-msft : you are welcome.

@srutzky srutzky deleted the SRutzky-ImproveSeeAlso branch January 18, 2018 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants