background preloader

SQL Development

Facebook Twitter

Compile sql server online. Untitled. The unprepared From my background as an accountant and controller I had by nature a good feeling for numbers.


This helped me to understand, how to structure data. A couple of years ago when I started to work in a startup, I usually grabbed data directly from source systems to support our cause to tackle financial issues and finding process deficits. Over time the queries grew in sizes and run-time got longer. When the run-time was not any more satisfying and our excel sheets with tons of formulas and recalculations broke, the need arose to build something more reliable. First, I created queries and jobs which persisted data in advance. My first objects had no indexes. Time passed and processing time was growing again. Lessons learned: Don’t create too many indexes. Proper Indexing My next adventure was about clean data. Sometimes my Dimensions, Facts or Stage tables would create cartesian products (duplicates). The confidence in my data grew, because any error would alert me.

Untitled. After the last Index blog post here another technical issue I recently thought to have solved.


At least maybe for the next year until I find another solution. As you know I dropped all indexes of my data warehouse and therefore also unique constrains on my tables. The application should make sure that everything is fine. But I have a regular report which checks, if the constrains are still intact. SQL Indexing and Tuning e-Book for developers: Use The Index, Luke covers Oracle, MySQL, PostgreSQL, SQL Server, ... How to Return Query Results as a Comma Separated List in SQL Server – STRING_AGG() Starting with SQL Server 2017, you can now make your query results appear as a list.

How to Return Query Results as a Comma Separated List in SQL Server – STRING_AGG()

This means you can have your result set appear as a comma-separated list, a space-separated list, or whatever separator you choose to use. While it’s true that you could achieve this same effect prior to SQL Server 2017, it was a bit fiddly. Transact-SQL now has the STRING_AGG() function, which concatenates the values of string expressions and places separator values between them. This works in much the same way to MySQL’s GROUP_CONCAT() function. This article provides examples that demonstrate the T-SQL STRING_AGG() function. Sample Data First, here’s some sample data. SELECT TaskId, TaskName FROM Tasks; Result: Azure SQL Database Managed Instance Overview. PL/SQL & SQL Coding Guidelines.

Oracle and SQL Server – Conditions In WHERE Clause vs. JOIN Clause – Why And When It Matters? Must Read! This post is about the various types of JOIN’s and how the conditions affect the results when placed in the JOIN clause versus the WHERE clause.

Oracle and SQL Server – Conditions In WHERE Clause vs. JOIN Clause – Why And When It Matters? Must Read!

Database programmers use OUTER JOINS in their job day in and day out. There are certain “gotchas” that you need to watch out for. One not only has to have a good understanding of when and how to use them but test extensively for various data conditions to make sure they produce the right results. If you are not familiar with OUTER joins, I recommend this article from CodeProject by C. L Moffatt that does a great job of explaining and doing a visual representation of the same.

ANSI vs Non-ANSI: The article below applies to both SQL Server and Oracle. In SQL Server, the non-ANSI syntax for outer joins is either the “*=” or the “=*” operator and in Oracle the equivalent operators are “ (+)=” and “=(+)”. In Oracle, besides the fact that non-ANSI standard for the outer join is deprecated, the exact features supported is also different. Employees:

Software vorausschauend entwickeln. Wartet man lang genug, wird jeder Code Legacy.

Software vorausschauend entwickeln

Folglich stellt sich die Frage, wie er sich so schreiben lässt, dass er langfristig wartbar bleibt. Einer der wichtigsten Faktoren ist die Verständlichkeit. Ein geflügeltes Wort unter Entwicklern besagt, dass schwer verständlicher Code ein erstrebenswertes Ziel sei – schließlich werde so deutlich, wie schwer es war, ihn zu schreiben. Da Entwickler allerdings häufig in die Lage kommen, mit "fremdem" Code arbeiten zu müssen, sollte das Streben nach hoher Verständlichkeit im eigenen Interesse liegen.

Der US-amerikanische Informatiker Donald E. Allzu oft scheitert der Vorsatz an (zumeist zeitlichen) Vorgaben des Kunden oder des Vorgesetzten. Die Aufgabenstellung verstehen Zunächst gilt es, das eigentliche Problem zu verstehen und zu dessen Kern vorzudringen. Genügt es, das Format zu kontrollieren oder ist die IBAN auch inhaltlich zu prüfen? Empathie für den Anwender. SQL Formatting. Sql coding standard sqlserver. Calculate the Sum of Salaries in an Employee Tree. In previous articles, I’ve discussed the treatment of specialized structures in SQL Server 2005 called graphs and trees.

Calculate the Sum of Salaries in an Employee Tree

Graphs are data structures that represent relationships between pairs of nodes. A tree is a graph that has a single root node, and you can reach each node in the tree structure by following only one path. An example of a tree is an employee organizational chart, which has many employees but only one CEO, and each employee has only one management chain. Introduction to Hierarchical Query using a Recursive CTE – A Primer. This blog post is inspired from SQL Queries Joes 2 Pros: SQL Query Techniques For Microsoft SQL Server 2008 – SQL Exam Prep Series 70-433 – Volume 2.

Introduction to Hierarchical Query using a Recursive CTE – A Primer

[Amazon] | [Flipkart] | [Kindle] | [IndiaPlaza] What is a Common Table Expression (CTE) A CTE can be thought of as a temporary result set and are similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. A CTE is generally considered to be more readable than a derived table and does not require the extra effort of declaring a Temp Table while providing the same benefits to the user.