Home > OS >  How to add a value to a pseudo table in SQL Server
How to add a value to a pseudo table in SQL Server

Time:05-24

I have a list from a query:

SELECT *
FROM Orders.Order ID

This returns:

OrderID
10255
10267
10275
10278
10298

I want to add 11245 to this data, temporarily, not to the original table. Does anyone know how to do this? Thanks

CodePudding user response:

You can do this with the UNION ALL operator, like so:

SELECT *
FROM Orders.Order ID
UNION ALL
SELECT 11245

UNION will also work, but in case the new value also exists in the original result set, you will only see that value appearing once in the final result set.

  • Related