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
unable to open internal url using VPN
How to extract Numbers from a text string ?
Asterisk: Detect incoming call
DT_WSTR dropping value before decimal point in SSIS
how to implement the screen which can be in form of grid lines in swings
from X and Y cordites
weird effects using ROUND() on REALs in TSQL
the database connection in in asp.net
The name on the security certificate is invalid or does not match the name of the site
Combine Sheets in Workbook