Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 convert nvarchar column to date column format

Author  Topic 

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2012-06-12 : 12:09:05
Hi,

In SQL Server 2008, I have an nvarchar column with dates formatted in dd/mm/yyyy. There are lots of rows.

I want to convert the 'nvarchar' column to a 'date' type column.

How can i do this and obviously keep the row data correct.

Thanks...

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-12 : 12:38:16
convert(datetime,mycol,103)


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2012-06-12 : 12:52:49
Hi,

Thanks for reply. But what I want to do the actual column data type to a 'date' format...so update the table so the column is a 'date' type.

Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-12 : 13:12:14
Add a new column, update with the data then delete the old. You can then rename the new column if you wish.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2012-06-12 : 13:28:16

cheers that'll work!!!
Go to Top of Page
   

- Advertisement -