Best Practice – SQL Script

Hi,

This blog post is about one small best practice that can save lot of time in the long run if you are working with SQL Server Management Studio. 

Many people who involved in Dynamics NAV does not have a very close relationship with SQL Server Management Studio even though back-end of NAV is totally based on SQL DB. 

Even during that very little usage of SQL Server Management Studio, many people (including me) use wizards to do things because it’s more easy and error free most of the time. 

Just like below, few clicks and we are almost there.. 


If we making backup (as an example) of same database for 10 times, then that mean we need to go through the same process over and over 10 times. 

Is there way we can do all those in one simple click? 

This blog post is about that. How about we create a small script in other word SQL Query which will do the same process for us. 

If you are not an expert in  SQL then you can use wizard to build your query. Do all the steps you usually do and then stop just before you press OK. 

Click on Script button and save it on a file or open in a new query window. 

If you open up in a new query window, your query will look like this and you can change the parameters as you want and just press execute. it will do the job for you.
 
Beauty of this method is that you do not have to go through wizard to get your task done, you can just do that with a click of a button. Think about time you going to save in long run. 

Other advantage is if you are doing a time consuming process then SQL Management Studio will show you the progress of your process in text format. 


I should give credit and thankful to SQL expert, my colleague Tomasz Szypilo who pushed me to use SQL scripts. 

Thank you for reading and hope you learned something from the blog post. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?