Hot answers tagged type-conversion
It is ugly, but you can try: SELECT a, b::text FROM unnest(ARRAY[(1,'hello'), (3,'world')]) AS t(a integer, b unknown); This way the type defined in AS matches the output of unnest(), which you can cast to your needs in the SELECT list. You can try this in a small SQLFiddle.
You can do this without generating a warning by creating a type and casting the records to it: create type t as (a integer, b varchar(255)); select * from unnest(array[(1,'hello'), (3,'world')]::t); ┌───┬───────┐ │ a │ b │ ├───┼───────┤ │ 1 │ hello │ │ 3 │ world │ └───┴───────┘ tested on 9.4 and 9.3 (SQLFiddle here)
As you mention you string value format is in 21/11/2105 then you can try following one Alter table table name alter column column name datetime NULL ( null is optional if you want to allow null value to your field). Note that if the column contain string value like "abc" (other than date format value) then it will show error as conversion fail.
As you probably have already found out, dates should be stored as dates and not as their human readable representation (varchar). In order to convert from string to date, you have to use the conversion functions available in your version of SQL Server (which seems to be 2014 if it is the same as Management Studio). In this case, you can use the PARSE ...
Should do it: SELECT a, b FROM unnest(ARRAY[(1,varchar 'hello'), (3,varchar 'world')]) AS t(a integer, b varchar(255));
Only top voted, non community-wiki answers of a minimum length are eligible