Not logged in - Login

SQL 2008 Row Constructors

Sample of how to construct rows of data using SQL 2008.

/*

CREATE TABLE Employees (
employee_nbr INT PRIMARY KEY,
employee_name VARCHAR(35));

*/

-- Insert data using row constructors 
INSERT INTO Employees (employee_nbr, employee_name)
VALUES (1, 'Jim Smith')
, (2, 'Joe Doe')
, (3, 'Greg Brown')
, (4, 'Donna Ford');

SELECT employee_nbr, employee_name FROM Employees;

-- Inline table expression
SELECT employee_nbr, employee_name
FROM (VALUES (1, 'Jim Smith')
, (2, 'Joe Doe')
, (3, 'Greg Brown')
, (4, 'Donna Ford')
) AS E(employee_nbr, employee_name);

/*

DROP TABLE Employees;

*/