June 2

Stored Procedure to Calculate Expressions

0  comments

I was reading the section Character Functions in the Chapter 2 of the book Querying Microsoft SQL Server 2012 and pretty soon I get bored of trying individually the various functions on strings available in T-SQL.

Then, I challenged myself to write a stored procedure (this is my first one) to evaluate an arithmetic expression with parenthesis and show the individual steps of the calculation. I wanted something generic but I added some restrictions to it after seeing how crazy is to implement a split function in T-SQL.

This is the stored procedure. I know, it is crazy and I am sure there are much better way of doing it. Remember that my goal was to just get confidence with the T-SQL functions on strings. Anyway, I am happy to receive feedback on it and see different way of implementing this behaviour.

This is the result of the execution.

It was fun 🙂


Tags


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Subscribe to our newsletter now!

Get instant access to the Master C# 9 webinar to learn all the new exciting C# 9 features quickly.
Get regular videos and news on C# and .NET and offers on products and services to master C#.

We will collect, use and protect your data in accordance with our Privacy Policy.

>