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
SPFile, PFile and Init
550 5.7.1 Unable to relay for
[email protected]
Speech Error Message -- WTF?
Installing SSRS 2005 on Windows Server 2008 R2
What's wrong in the followin sql server 2000 query
regarding installation of macromedia dreamweaver 8.0
SQL non clustered index
Forefront TMG 2010: Open all ports between 2 TMG servers
Access - Automated Email messages
SCOM 2007 R2 Dashboard creation / manipulation