Microsoft
Software
Hardware
Network
Question : cast or convert varchar to int and datetime
have two tables test and test2
test has two columns updated from csv file
sequence (nvarchar 50)
date (varchar 50)
then I need to update to test2 as this table is selected by a cube (third party report server) set up as int and datetime
sequence (int)
date (datetime)
have used the following scripts and all have failed
insert into test2
select convert (int, sequence),
convert (datetime, date) from test
Results
Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
then tried
insert into test2
select cast (sequence as int),
cast (date as datetime) from test
Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
then tried
insert into test2
select
convert ((int), sequence),
CONVERT(DATETIME, CONVERT(VARCHAR(MAX), [date], 101), 101)
from
test
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '('.
insert into test2
select
convert(int, sequence),
CONVERT((DATETIME), [date], 101)
from
test
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '('.
Answer : cast or convert varchar to int and datetime
there is also "FULL" and "CROSS" joins
Random Solutions
Three workstations down! Need help joing to Domain!
another basic rearrangement
Can I have Code Created to Automate Input in Word & Excel?
Is it possible to databind within the UI from a background thread?
Black Screen on Windows Server 2008 R2
Arc Serve 12.5
Why stops NVIDIA GEFORCE 5500 the signal on S-VHS (S-VIDEO) output after WINDOWS starts?
outlook 2007 is not working with brand new sbs 2008 migrated server
QoS configuration
Change /etc/init.d boot order Ubuntu 9.10