Add support Row Constructor (or Table-Valued Constructor) as Derived Table
SELECT *
FROM (VALUES (1, 3), (1, 5)) AS T(A, B)
Result:
A B
1 3
1 5
Row Constructor (or Table-Valued Constructor) as Source in a MERGE Statement
MERGE Currency AS Target
USING (VALUES ('USD', 'U.S. Dollar'),
('EUR', 'Euro'),
('CAD', 'Canadian Dollar'),
('JPY', 'Japanese Yen'))
AS Source ( CurrencyCode, CurrencyName )
ON Target.CurrencyCode = Source.CurrencyCode
WHEN MATCHED THEN
UPDATE SET CurrencyName = Source.CurrencyName
WHEN NOT MATCHED THEN
INSERT ( CurrencyCode, CurrencyName )
VALUES ( Source.CurrencyCode, Source.CurrencyName )
Modified by: @sim1984
description: Add support derivative tables on the basis of values of constants
SELECT \*
FROM \(VALUES \(1, 3\), \(1, 5\)\) AS T\(A, B\)
Result:
A B
1 3
1 5
=\>
Add support Row Constructor \(or Table\-Valued Constructor\) as Derived Table
SELECT \*
FROM \(VALUES \(1, 3\), \(1, 5\)\) AS T\(A, B\)
Result:
A B
1 3
1 5
summary: Derivative tables on the basis of values of constants =\> Row Constructor \(or Table\-Valued Constructor\) as Derived Table
Modified by: @sim1984
description: Add support Row Constructor \(or Table\-Valued Constructor\) as Derived Table
SELECT \*
FROM \(VALUES \(1, 3\), \(1, 5\)\) AS T\(A, B\)
Result:
A B
1 3
1 5
=\>
Add support Row Constructor \(or Table\-Valued Constructor\) as Derived Table
SELECT \*
FROM \(VALUES \(1, 3\), \(1, 5\)\) AS T\(A, B\)
Result:
A B
1 3
1 5
Row Constructor \(or Table\-Valued Constructor\) as Source in a MERGE Statement
MERGE Currency AS Target
USING \(VALUES \('USD', 'U\.S\. Dollar'\),
\('EUR', 'Euro'\),
\('CAD', 'Canadian Dollar'\),
\('JPY', 'Japanese Yen'\)\)
AS Source \( CurrencyCode, CurrencyName \)
ON Target\.CurrencyCode = Source\.CurrencyCode
WHEN MATCHED THEN
UPDATE SET CurrencyName = Source\.CurrencyName
WHEN NOT MATCHED THEN
INSERT \( CurrencyCode, CurrencyName \)
VALUES \( Source\.CurrencyCode, Source\.CurrencyName \)
Submitted by: @sim1984
Votes: 4
Add support Row Constructor (or Table-Valued Constructor) as Derived Table
SELECT * FROM (VALUES (1, 3), (1, 5)) AS T(A, B)
Result: A B 1 3 1 5
Row Constructor (or Table-Valued Constructor) as Source in a MERGE Statement
MERGE Currency AS Target USING (VALUES ('USD', 'U.S. Dollar'), ('EUR', 'Euro'), ('CAD', 'Canadian Dollar'), ('JPY', 'Japanese Yen')) AS Source ( CurrencyCode, CurrencyName ) ON Target.CurrencyCode = Source.CurrencyCode WHEN MATCHED THEN UPDATE SET CurrencyName = Source.CurrencyName WHEN NOT MATCHED THEN INSERT ( CurrencyCode, CurrencyName ) VALUES ( Source.CurrencyCode, Source.CurrencyName )