Posts

Showing posts from March, 2021

All about prepared statements. When to use them to go faster!

Image
Hello friends, Are you ready to learn about prepared statements ?  If you are a software developer you will have noticed that a T-SQL statement (a Query) can be prepared. Who knows exactly what that means? If I prepare a query then it runs faster? Today we will answer to all these questions and give some examples. We are interested in using them when they make us go faster! READY? A bit of theory, key concepts! Not only Microsoft SQL Server support prepared statement. Prepared statements is infact a feature of many DMBS like Oracle, DB2, MySQL and PostgreSQL. The main idea is to split the execution of a statement in two parts. During the first part called preparation the T-SQL will be parsed, analyzed and optimized. During the last part called execution parameters will be binded and the command will be executed. When is this feature useful? This feature is useful when the same command must be executed many times . There are unfortunately some limitations to consider. Some Limitatio...

Why does my transaction log growth? simple and clear!

Image
Howdy people! Ready for another post?  I'm sure someone will have reported this to you:   "Hey we have a problem! we have a database whose transaction file has grown and is now taking up several gigabytes!" Today we will see why it happens But i warn you! In order to understand completely the continuous you need to read this post: The WRITE AHEAD LOGGING mechanism   You need infact to learn how data are passed from the log to the data file. The post of today can be considered as a continuation of it. Go! Hey, the transaction log of my database is growing! A little basic concept Each database consists of two o more physical files.  One or more files with mdf file extension are called data file because it contains data.  One file with ldf file extension that's called transaction log file . This transaction log file contain data not yet committed For example, if start a transaction and then i run an insert, before the commit, data are stored in transaction log (ldf...

Use Notebook feature to produce professional data report and ...impress your boss

Image
Hello friends,  Welcome back to this new post.   I was thinking. The same job is now done in a different way. I can wear more casual attire, but surely not seeing students' faces live during classes makes it less easy to teach them. If, on the other hand, I have to concentrate, I prefer to be alone in my studio and carve out moments in which to share work with my team. Rember, it is important to communicate. It's important to team up! This is the summary of concept of smartworking as I understand it. But it does not matter, because everything advances and often there is no choice. As usually enjoy the reading!      Impress your boss with a professional report  Let me tell you, Scripts done with the SQL Server Management Studio are old! I am sure you have thousands SQL Server Scripts and it is not easy to keep in order all that materials. For these reason today we talk about the notebook feature of which we already talked about here How to upgrade the SQL ...

COALESCE and IIF functions, the CASE statement and a secret at the end of the post

Image
Hi Friends, March has arrived, spring is coming and i am writing this post after a sunny thuesday. Not bad at all! Just a good coffee and it is time for our basic post of today! We will talk about the COALESCE and IIF functions and the CASE statement.  Maybe someone has never used them or ...doesn't know the secret at the end of the post! Hey don't cheat, don't scroll down! please! COALESCE The function coalesce return the first not null parameter from the left For example: SELECT COALESCE (NULL,1,3) return 1 SELECT COALESCE (‘A’,’B’,’C’) return ‘A’   I like this function because it accepts a variable number of parameters as input. Few functions do this.. In all honesty I would like other functions that behave this way, for example the MAX and MIN... COALESCE, IIF or CASE? There are other ways to get the same result as the following query: Select coalesce (g.qttgiai,g.qttimpi,g.qttmani) from products g   I can use for examp...