views:

21

answers:

1

How would I add a column to a Select and have that column be of a specific type.

For example Select Company, City, Dues, 0 As NewColumn1, 123.12 As NewColumn2 But I want NewColumn1 to be of type bit, and NewColumn2 to be of type Real

Oh, I'm using SQL Server 2005.

+3  A: 

You can use CAST

Select  Company, 
     City, 
     Dues, 
     CAST(0 AS BIT) As NewColumn1, 
     CAST(123.12 AS REAL As NewColumn2 
FROM    @Table

Have a look at CAST and CONVERT (Transact-SQL) .

astander