by ZenoArrow · 10y ago · 0 comments
Just one thing...
"Common Table Expressions (also: CTE, also referred to as subquery factoring, e.g. in Oracle) are the only way to declare variables in SQL (apart from the obscure WINDOW clause that only PostgreSQL and Sybase SQL Anywhere know)."
Can't say anything about other vendors, but in T-SQL (a.k.a. MS SQL) creating variables is easily done via the DECLARE keyword, e.g. DECLARE @x INT = 4; . You can create a number of structures this way, including temporary tables (there are few different types of temporary tables, but the ones specified with DECLARE are specific to the scope in which they were defined in).
Does the DECLARE keyword (or something similar) not exist within any of the SQL standards?
DECLARE @temptable TABLE (id INT, fulldescription NVARCHAR(MAX));