SET @XmlFilename = 'JCA_RB_SP-20170531_152713.txt'
SELECT @IndexOfDash = CHARINDEX('-', @XmlFilename)
SELECT @BatchName = LEFT(@XmlFilename, CHARINDEX('-', @XmlFilename) - 1)
SELECT @BatchDateStringRaw = SUBSTRING(@XmlFilename, CHARINDEX('-', @XmlFilename) + 1, 15)
SELECT @BatchDateString = SUBSTRING(@BatchDateStringRaw, 1, 4) + '-' + SUBSTRING(@BatchDateStringRaw, 5, 2) + '-' + SUBSTRING(@BatchDateStringRaw, 7, 2)
+ ' ' + SUBSTRING(@BatchDateStringRaw, 10, 2) + ':' + SUBSTRING(@BatchDateStringRaw, 12, 2) + ':' + SUBSTRING(@BatchDateStringRaw, 14, 2)
SELECT
[@XmlFilename] = @XmlFilename,
[@IndexOfDash] = @IndexOfDash,
[@BatchName] = @BatchName,
[@BatchDateStringRaw] = @BatchDateStringRaw,
[@BatchDateString] = @BatchDateString,
CAST(@BatchDateString AS datetime)
,CAST(CAST(@BatchDateString AS datetime2) AS varchar(30))
,CAST(CAST(CAST(@BatchDateString AS datetime2) AS varchar(50)) AS datetime2)
Comments
Post a Comment