Reputation: 3308
In Sql
, if I want to fetch all columns from a table then I would write select * from <table name>
. However let say there is a column called XYZ
and type is numeric
. However I want to fetch all columns but change that XYZ
column to sting
, then how should one proceed?
Any help will be highly appreciated.
Upvotes: 2
Views: 3178
Reputation: 8887
I don't think there is a way to do it without either specifying all the columns or duplicating the one you want to convert.
SELECT *, CAST(XYZ as varchar) as XYZ_String
FROM <table>
Upvotes: 0
Reputation: 2421
Select the other columns individually, and CAST(xyz AS NVARCHAR)
SELECT foo, bar, CAST(xyz AS NVARCHAR)
FROM myTable
Upvotes: 2