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
Time picker for access
blocking ip ranges on cisco asa 5500
Ajax not returning value to DIV
RDLC and syntax help needed
Sorting an Excel worksheet with header row in powershell
How Do I Generate An MS Word (.doc) File On The Fly Using PHP
Sorting options for data contained in the footer
latebinding Windows Script Host Object
vb insert space
Another way of coding this