Skip to main content

Writing A Good Query

When it comes to reading code no body will like to read a wall of text specially in programming. Some of the best practices to make query code readable, as well as easier to understand, is to follow clean formatting rules throughout your SQL query. Some good practices to write a good query is: 

- Use comments to describe what SQL does. If you’re modifying existing SQL, add the author’s name, the date, describe the modifications, and avoid questions. Don’t overdo it and comment on the obvious

- Put each major SQL statement on a new line

- Use CamelCase capitalization and do not separate name parts with underscores: TableName, instead of Table_name, or use lower case and underscores to separate name parts: table_name

- Set standard abbreviations for frequently used objects, such as tbl for tables, or sp for stored procedures

- Use single quotation for characters, strings, binary and Unicode –

- Use indenting to align wrapped long lines

- Use parentheses in complex mathematical expressions

It is also important to use line breaks to improve readability, as well as separating lines of codes that execute certain tasks as different code blocks. 


sources: 

http://solutioncenter.apexsql.com/sql-formatting-standards-capitalization-indentation-comments-parenthesis/

Comments

Popular posts from this blog

Your Online Life, Permanent As a Tattoo

View TED Talk Link Watching this TED talk titled “Your Online Life, Permanent As a tattoo” talks about how the use of social media can be the same as having a personal tattoo. Juan Enriquez, the main speaker, begins the presentation by using visual pictures of what tattoos can represent in a person's life. Using pictures, he shows the audience that tattoos can be beautiful, intriguing, intimate and also builds humor by stating that they can be mistakes. After showing the audience these different types of tattoos, he starts to question them about what if social sites and services were to become personal tattoos. At this point he begins to add more information on how the way we express ourselves on  social media can impact and create our  “Electronic Tattoo”. Juan states how difficult it is to get away from our electronic tattoos, since forms of technology, like facial recognition are getting better and better at recognizing people's faces. He adds up that if someone

Why I am at MATC

Hello! My name is Noel Dominguez, I am 20 years old and I am currently enrolled in the IT mobile application developer program at MATC.  I am at MATC because since I was little I had a passion for technology. I  was always seen as the “techie” guy from my family. I always liked taking old electronics apart just to see how things worked from the inside and ever since I was introduced to computers my love for technology grew even greater. While at high school that part of me only got stronger, my passion led me on a iphone repairing business that involved the tweaking of iphones internally(jailbreak) and externally. After graduating high school I devoted my time and developed a game based on a twitter trend. I managed to publish this game on iOS, Google and Amazon app stores within a few months, not to mention achieving this with not one clue on how to code. I am currently in my second semester in the IT mobile apps developer program, not only because technology has been a part of my

Modular Programming

Modular programming is the practice of breaking down a program's functionality into independent interchangeable modules. Each of these modules have everything necessary to execute only that aspect of the desired functionality, in the case they are needed.  Modular programming is important because it creates a structure that keeps the code organized and easier to maintain. For example, if you had to change an object used throughout a program, with modular programming you would only have to find the module where the character was coded. Compared to not having modularization, if you wanted to accomplish this you would be required to read the code line by line having to find and edit that character everywhere it was used. Programming languages like C#, java, and C have this implemented by having different methods or identifiers. Once that is created then you are able to use those methods elsewhere in your code, which also saves time by not having to re-write the method all over ag