01/12 / 2016,02 / 12 / 2016,03 / 12/2016
在SQL中,我在单个记录或单个单元格中有这三个日期,但我希望将第一个日期设为from date
,将最后一个日期设为end date
。
我需要任何语法。有人可以帮助我吗?
答案 0 :(得分:0)
如果所有值的数据结构相同,则可以尝试如下
DECLARE @val AS TABLE (val NVARCHAR(max))
INSERT INTO @val
SELECT'01/12/2016, 02/12/2016, 03/12/2016'
SELECT *FROM @val
SELECT CAST (LEFT(val,10) AS DATE) AS startdate , CAST (RIGHT(val,10) AS DATE) AS enddate FROM @val