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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -