Skip to content

Commit ccaefdf

Browse files
Cleaning up horrible writing
Just the top portion. No time right now to clean it up as much as it deserves.
1 parent de913f2 commit ccaefdf

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
# MySQLCLRFunctions
2-
Free SQLCLR functions tested on SQL Server 2019
2+
## Free SQLCLR functions tested on SQL Server 2019
33

4-
Simple stuff to avoid spending $500 for a two year license (https://sqlsharp.com/full/)
5-
It hasn't been updated in 2 years, so not very cool.
6-
I use UNSAFE assemblies, because me likey.
7-
Their names are a bit taxing. I call things StartsWith rather than SQL#.string_Is_A_BEGINNIN_WITH
8-
Less parameters. These are annoying to have to fill out. Rather, do it the old fashion way: Make a new function!
9-
CompareThese(a,b)
10-
BestOf3(a,b,3)
11-
Or make an agg.
12-
Pass everything NVARCHAR(MAX) for now. Speed isn't the main problem. The main problem is that SQL Server functions are severely lacking.
4+
These are simple functions I've written in order to avoid spending $500 for a two year license (https://sqlsharp.com/full/) of SQL#. For one, the product hasn't been updated in 2 years, and that's not very cool for a pay product.
135

14-
If it's possible to think of a logical algorithm that can easily be described, then it's worth being a function.
6+
FYI, warning, buyer beware on my stuff: I use UNSAFE assemblies, because half the reason to use SQLCLR is to get to functions that are not in SQL Server already, which is where the safe stuff is.
157

16-
For instance, AnyOneOfTheseIsInThose, or something like that. If have a set. Are any of these items in this other list?
8+
Another bug I have with SQL# is that their names are overly precious. They will name a function SQL#.string_Is_BEGINNING_WITH whereas I call it StartsWith, which is not coincidentally the same as the C# method. I try to align my names with C# when the functionality aligns. Less to remember.
179

18-
To pass in lists, I just use delimited strings.
10+
I also have less arguments on functions than SQL#. SQL Server does not support optional arguments on functions, and so these are annoying to have to fill out. Also, I forget what they are supposed to be, and I don't recall their documentation telling me if using DEFAULT will work.
11+
Rather than every possible argument under the sun, I do it the old fashion way: I make a new function.
12+
For example, hypothetically, I would do this:
13+
> CompareThese(a,b)
14+
> BestOf3(a,b,3)
15+
> BestOf4(a,b,c,d)
16+
> Or make an agg or a TVF.
1917
20-
Structure or class organization:
18+
For reduced maintenance, I pass everything NVARCHAR(MAX). Speed is not my main problem. The main problem is that SQL Server functions are severely lacking and new functions are added every third decade. STRING_AGG is great, but a SQLCLR function can go back to at least 2012.
19+
20+
If it's possible to think of a logical algorithm that can easily be described and understood, and there's no confusion about what to expect in the output, then it's worth being a function.
21+
22+
For instance, I have a function called AnyOneOfTheseIsInThose, or something like that. It is for when I to know if there is a non-empty intersection of a list of values that I don't want to stuff into tables. It answers the simple question: Are any of these items in this other list?
23+
24+
To pass in lists, I use delimited strings, but I usually have an argument for the separating string. SPLIT_STRING from Microsoft, and most home-grown SQLCLR splitters seem to think all splitting is based on single characters. I support the string for the cases that come up.
25+
26+
## Structure or class organization, namespaces in other words:
2127
<li>
2228
Adaptors - Converts something to something else as an electronic power adaptor would. It's not a transformation, and it's reversible.
2329
</li>
@@ -70,13 +76,13 @@ Structure or class organization:
7076
<li>
7177
StringTransform - Actual change being made, new information by structural abruption.
7278
</li>
73-
79+
<br/>
7480
My favorites have to be Matches, Ping, StartsWith, EndsWith, AnyOfTheseeAreAnyOfThose, HowMany, LeftOf, LeftOfNth, LeftOfNth, IndexOfLast
7581
Also GetFirstName, Pieces, RTrimChar.
7682

7783
I have a bunch somewhere, and I need to add more.
7884

79-
Some ideas:
85+
<h1>Some ideas:</h1>
8086
- Better captures
8187
- Escape for multi-level dynamic SQL generation
8288
- A UNIX cut command for fixed-width
@@ -88,7 +94,7 @@ Some ideas:
8894
- Some default formatters, like LogFileTimeStamp = "YYYYmmDDhh24missffffff" or some such. So I don't have to remember.
8995

9096
- Possibly push SQL work down? Like a TRUNCATE TABLE that pre-strips FKs, truncates, reloads, and tries to add the FKs back.
91-
- Unix to/from for Active Directory columns
97+
- Unix to/from for Active Directory columns.
9298
- Natural language extraction of patterned speech.
9399

94100

0 commit comments

Comments
 (0)