I’m basically looking to do something like this:
SELECT MYCOLUMN AS 'MYALIAS' VARCHAR(500)
FROM MYTABLE
What I’m doing is this:
SELECT COLUMN1 AS 'TEXT',
COLUMN 2 AS 'VALUE'
FROM MYTABLE
COLUMN2 is an INT column, however I need to append a string value with UNION as an “Other” selection. Is there a way to return that column as VARCHAR instead without actually building the table beforehand and using INSERT INTO with a CONVERT()? If not, no big deal, I was just looking to see if there was a slick way of doing it.
You can always cast the column to another type:
The approach you have (
AS 'TEXT') only defines an alias – a different name – for the columns – it does not influence the data type in any way.