简体   繁体   中英

converting nvarchar(50) to datetime

I am using SQL Server 2005 and am trying to match in a Dimension table the date field with data:

2012-01-06 00:00:00.000 as a datetime to a staging table with data that comes in as a nvarchar(50) 2012-01-06 15:53:12.040 for example. I have tried all of the converts and casts that I can find on the searches but am getting an "Arithmetic overflow error converting expression to data type datetime." error message.

I have updated all of the time values manually in the staging table to have 00:00:00.000 time stamps but still the problem is there.

Can anyone help please?

Are you just trying to change the data type of the entire column?

If so, try this

ALTER TABLE table_name
ALTER COLUMN column_name datetime

More info .

If you are trying to just modify for a query, you can try this:

 SELECT convert (...look at link below for options... )

Look here for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM