是否可以从数据库的表中选择行,并添加数据库中不存在的预定义行?
SELECT Name
FROM [dbo].[TableFoo] -> returns Names (Name1, Name2, Name3)
我希望它另外返回预定义值'NameNotInDatabase':
SELECT Name
FROM [dbo].[TableFoo] + some tsql -> returns Names (Name1, Name2, Name3, NameNotInDatabase)
答案 0 :(得分:3)
您要寻找UNION ALL
吗?
SELECT Name
FROM [dbo].[TableFoo]
UNION ALL
SELECT 'NameNotInDatabase';