Search notes:

SQL Server: create test data with the values clause

The values(…) clause is handy to quickly create a bit of test data without creating a table.
The following example tests a left join:
select
   en.num,
   en.txt,
   ge.txt
from (
  values
    (   1, 'one'  ),
    (   2, 'two'  ),
    (   3, 'three'),
    (   4, 'four' )
) en (num,  txt   )    left join
( values
    (   1, 'eins' ),
    (   2, 'zwei' ),
    (   4, 'vier' ),
    (   5, 'fünf' )
) ge (num,  txt   )  on en.num = ge.num;
Github repository about-MSSQL, path: /sql/select/values/left-join.sql

See also

Mimicking Oracle's greatest and least functions with the values clause
select

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758207261, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQL-Server/sql/select/values/index(60): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78