I have a string in a table that I need to extract parts of into variables so I can make another string. I have been looking at STRING_SPLIT but can't make it do what I need.
My string
@path = 'C:\Working\Imaging\Migration\2017\3\1\7\5187990.TIF'
Basically I need to make a new variable, @CreationDate from @path. In this this instance, @CreationDate = 2017-3-1 7:00:00
I was trying to at least set the @year, @month....variables but that is where I am getting stuck making this code more efficient
This is what I got so far but it only sets the @year
SQL
declare@pathvarchar(max)declare@yearintdeclare@monthintdeclare@dayintdeclare@hourintset@path='C:\Working\Imaging\Migration\2017\3\1\7\5187990.TIF';withsplit_pathas(selectrow_number()over(orderby(select1))asid,valuefromstring_split(@path,'\'))select@year=...