【发布时间】:2017-04-02 11:42:46
【问题描述】:
我想返回 SQL Server 上由斜线分解的每个字符串的日期。
我的数据库表:
id | date | col1 | col2 | col3 | col4
---+------------+-------------+-----------+-------+------------
1 | 2017-04-02 | /txt1/txt2 | | |
2 | 2017-04-03 | | /txt1/txt4| |
3 | 2017-04-04 | |/txt2/txt3 | |
4 | 2017-04-05 | |/txt4 | |/txt5/txt6
想要的结果:
2017-04-02 txt1
2017-04-02 txt2
2017-04-03 txt1
2017-04-03 txt4
2017-04-04 txt2
2017-04-04 txt3
2017-04-05 txt4
2017-04-05 txt5
2017-04-05 txt6
谢谢 皮埃尔
【问题讨论】:
-
那么,您为什么不与我们分享您迄今为止的尝试?
-
阅读Is storing a delimited list in a database column really that bad?,您会在其中看到为什么这个问题的答案是绝对是的!
-
@ZoharPeled 可能是这种情况,尽管 OP 不负责数据库的设计。
-
@GiorgosAltanis 是的,这是可能的。即使操作人员没有计划数据库并且无法更改结构,这仍然是需要知道的。
-
@ZoharPeled 我同意 100%
标签: sql sql-server explode