0

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.

Alex
  • 2,081
  • 14
  • 49
  • 76

1 Answers1

3

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) .

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284