Programming

SQL Server: temporary tables and constraint names

Local temporary tables are isolated in the scope of current session regardless its name. It means that #temp_table in the session 1 is not the same that #temp_table in the session 2. However, the names of constraints are stored in the metadata of tempdb and can produce duplicate name errors.

SQL: generate random character string

Collection of methods to generate random string in a single SQL statement

M1: Recursive string concatenation

On SQL Server the method is limited by 100 characters owing to the recursion level limitation. The method has the performance issues when using in loops/joins because the table always have 100 rows generated every time.

Types of joins in SQL (cheatsheet for beginners)

This article is used in my book "Programming with databases".

Better to see once than to hear a hundred times. This small article explains what are the different kinds of joins in SQL.

At the first time you should take into account that SQL is a declarative 4th generation language. So the best way to use it (especially for beginners) is to write the query and let SQL optimizer do its job. That means thinking in set-oriented terms and avoiding sub-queries.

Let's take two example tables: Companies and Contacts.

Bit-packed structure (record) in Free Pascal and Delphi

Here is the code explaining some methods to pack bit accessing logic in your program.

program project1;
 
type
  TRec1 = packed record // Doesn't pack at all
    b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16: boolean;
  end;
 
  TRec2 = bitpacked record // Free Pascal specific
    b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16: boolean;
  end;
 
  TRecByte = (b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16);
  TRecBytes = set of TRecByte;
var
  r1: TRec1;
  r2: TRec2;
  s1: TRecBytes;

Interface implementations and multiple inheritance in C++

Multiple inheritance of interfaces which are pure abstract classes indeed is not a problem until you need to use the interface implementation in other classes.

Suppose there are two interfaces, the implementation of which will be used in other classes.

Pages

Subscribe to RSS - Programming