简体   繁体   中英

How do I set a column to return a value in a select statement

So if i do a statement such as

Select column1, column2
from dbo.table

How would i return column1 as the actual data and column2 as a fixed value, if i wanted to have column 2 to always show the same value.Im building an output file and need to put in some predefined results.

Column1         Column2
-------         -------
dog             A
cat             A
bird            A

thanks a lot

You would then select a constant value:

Select column1, 'A' as column2
from dbo.table

select a constant value :

SELECT t.Column1, 'A' AS Column2
FROM dbo.table t

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM