LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

As per the documentation: FROM (Transact-SQL): The keyword OUTER is marked as optional (enclosed in square brackets). In this specific case, whether you specify OUTER or not makes no difference. Note that while the other elements of the join clause is also marked as optional, leaving them out will make a difference. For instance, the … Read more

What is a stored procedure?

Stored procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most familiar with SQL Server I will use that as my samples. … Read more

Case in Select Statement

I have an SQL statement that has a CASE from SELECT and I just can’t get it right. Can you guys show me an example of CASE where the cases are the conditions and the results are from the cases. For example: where the results show

Selecting COUNT(*) with DISTINCT

Count all the DISTINCT program names by program type and push number DISTINCT COUNT(*) will return a row for each unique count. What you want is COUNT(DISTINCT <expression>): evaluates expression for each row in a group and returns the number of unique, non-null values.

What is an MDF file? [closed]

SQL Server databases use two files – an MDF file, known as the primary database file, which contains the schema and data, and a LDF file, which contains the logs. See wikipedia. A database may also use secondary database file, which normally uses a .ndf extension. As John S. indicates, these file extensions are purely convention … Read more