tsql - Convert Varchar into Time in SQL Server -
how convert time format " 10:02:22 pm " sql server datetime format.
i have column of such data. imported column csv file , want convert datetime format can able use date time functions.
i want able insert column table correct datetime format.
you don't need convert it. implicit cast occurs when use
insert othertable select ....., timeasvarchar, ... csvtable
if time data (leading space or not) parseable string, query work beautifully. if however, there possibility of bad or blank data cannot converted time, test first
insert othertable select ....., case when isdate(timeasvarchar)=1 timeasvarchar end, ... csvtable
else null
implied left out.
Comments
Post a Comment