Do you know how to script database objects from a script?

Why yes? With this script it’s easy as ABC. Just fill in the list of items you want scripted and off you go. This way you can script any stored procedure, view, function or anything else that resides in the sys.sql_modules table.

There is a small piece of code that will loop through the definition if it’s longer than 4000 characters long. The PRINT statement will only print the first 4000 characters of a (n)varchar variable. To work around this, we split off 4000 characters, then find the last carriage return and throw away the remainder of the string. This way we don’t get any nasty splits on the screen. Then we print that string and we subtract the length of that string from the original string, and we go again.

Do you know how to check a phone number?

Of course I do! Here’s a little nifty function you can use or expand for your own needs. This was made for Dutch mobile phone numbers but can be easily tweaked for any other type of phone number.

The way this works is as follows.

First we split the string into a table of single characters. We then filter the ones that aren’t numeric. We use the like function because isnumeric would not filter anything that is used to represent a number like ‘-‘ or ‘+’ in the phone numbers. Finally we concatenate with the xml-trick. Then, we select the part of the resulting string that matches our pattern.

Change the pattern to suit your country’s phone number style – or you can just do the check and return a boolean to indicate it’s actually a valid phone number or not.

How can I use JSON in T-SQL to maintain configurations

Do you know how I can easily perform an 11-test (Elfproef)

The elfproef is a Dutch validation check that was used for bank account numbers before the introduction of IBAN and is still used for BSN (National identifier) and payment references in bank transaction. Here’s a sweet inline table valued function that will yield instant results. 1 million iterations of this take up almost no cpu time so it’s very fast.

The first part checks if the supplied value is numeric. If it is , we work with the supplied value, otherwise we work with the value 1 which will never yield a valid BSN. We cannot work with if/then constructs because we are working with an inline table function.

I used a JSON array for configuration because it makes the code easier to read. If you want to know how an elfproef works, here’s an explanation in Dutch: https://nl.wikipedia.org/wiki/Elfproef

Example usage: select BSN from Personen as PRS WHERE dbo.tvf_CheckElfProef(PRS.BSN) = 0

I need a script that will search all objects in a database for text or a combination of keywords

Oh, and I need a way to present it to my boss in an easy-to-use-excel-format.

Well, this code will search all your databases for the text combinations you provide and return the views that contain the keywords. You can easily modify this to include stored procedures or functions and you can extend the search combinations and what it says as a response to certain keywords being found.

Do you know how to fix the NFC and wireless charging not working on my Google Pixel4?

Recently, the wireless charging on my Google Pixel4 stopped working. I blamed the wireless charging pad but it wasn’t until I travelled back to Europe and wanted to use my wireless payments that I noticed the NFC was also not working.

It now turns out it’s due to the back of the phone being slightly detached from the rest of the phone. It’s hardly noticeable, especially since I always keep it in a silicone case but removing the phone from the case revealed the right side (when the phone screen is away from you) to have a slight gap that I can run my nail through. Pressing down on the back immediately fixed the problem and at least the wireless charging is working once again. I hope adjusting the case will hold the back down hard enough. Other reports have users opening the phone, bending the pins and then trying to glue the back to the phone … for now, things are working again by just pushing it back down. Otherwise I will try duct tape.

I need a dashboard for my SQL Agent JOBS that run SSIS Packages

I hear you. Here is a script in T-SQL that will fetch all the jobs (including the ones that are currently running) and displays a dashboard for each step. It will also display the last message SSIS generated (last error message in case of failure, or last message in case of a successful run).

How do I solve “illegal characters in path” in my Octopus deploy?

You won’t believe this, but the reason why I got this was a weird trailing backslash. I failed to find where it came from and after HOURS of searching, I found out it was because I had entered a variable in the process step and accidentally type ENTER before the variable. So it was essentially a CRLF followed by the variable name. For some reason, that caused the illegal character. Guess it was trying to insert the CRLF in the path … Well, check your variable listings in your steps to see if you have any leading or trailing enters …

I need a way to view the results of my SSIS packages (as a recordset)

This code was written while we were migrating a bunch of SSIS packages to a new SQL Server version. It will show you the latest results for each package run. If a package ended in an error state, it will show the latest error that was generated.

You can toggle the code to show only packages in error state, and you can toggle the running packages on/off. Running packages can be included because otherwise, running packages do not show up in this list.