how to convert text to date in sql server 2008? -
I have a table in which text field [nvarchar (10)]
how to convert this field To date?
When I try to change the field in design mode - I get this:
Unable to modify table.
Is there a question that can be run for me?
Thank you in advance
You can follow these steps:
- Create a new date time column, faucet
- update that
- Drop your original column
- Apply To not accept tap, rename and adjust your column
Try this sample:
create table # sample (field ad text Varchar (10) not tap); # Include in sample values ('2009-01-24'); Add optional table # sample field AsDate date time tap Update # sample SET FieldAsDate = CONVERT (DATETIME, FieldAsText) SELECT * FROM #Sample ALTER TABLE #Sample drop columns Fildaestekst Aelvr table # Sample option columns field AsDate datetime NULL Go Select # sample * < / Code>
Comments
Post a Comment