Category: SQL
-
Common Table Expressions (WITH)
Recently, I have been using WITH queries a lot, my favorite, and I don’t know why I did not use it more often. Here is a nice video about CTEs: Resource: https://mauridb.medium.com/ctes-views-or-temp-tables-acf85acf89e6
-
IIF and CHOOSE: Logical functions in SQL Server
IIF IIF is a function available after SQL 2012 version. It returns one of two values depending on a boolean expression. An example: CHOOSE CHOOSE is for getting a value at an index from a list. (unlike arrays, it is not zero-based ) It can be used with column values.
-
SQL and sending emails with Powershell
Run SQL Command Invoke commands in a script file and save the output in a text file Invoke sql script and write the results into CSV file. Invoke sql script and write the results into JSON file. Invoke a script and pass in variable values from a string Send Mail A scenario: Retrieve data from…
-
Simple self-join with LINQ and SQL
Let’s say we have a table in which we store the various test results of a persons. PersonId TestId Result 1 TOEFL 5 1 IELTS 10 2 TOEFL 10 2 IELTS 6 3 TOEFL 2 4 IELTS 4 And assuming that it has been queried and stored in a list of objects. (This is a…
-
Reports for Redmine
After some requests I have received, I will share some of the SQL commands that I used for creating reports for Redmine. You need to change projectIDs, journelIDs etc. Here they are: 1 – Approximate Solution Time Current Project Analysis 3. Status of an Assignee Change assignee id for your project. Thanks a lot to…
-
Why Brackets in SQL queries with SQL Server
It’s been long time since I worked with SQL Server last time. I have been working with Oracle and there are differences for sure. This one is simple. The brackets are required if you use keywords or special chars in the column names or identifiers. You could name a column [First Name] (with a space)–but…