Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将列分隔字段更改为同一列中的输入SQL_Sql_Sql Server_String_Split - Fatal编程技术网

将列分隔字段更改为同一列中的输入SQL

将列分隔字段更改为同一列中的输入SQL,sql,sql-server,string,split,Sql,Sql Server,String,Split,我正在列出几家公司的产品清单,稍后将在地图上显示。 因此,每一列都在一列中填入一家公司,而另一列中的所有产品都由 +-----------+--------------+ | Company | Products | +-----------+--------------+ | 1 | a; b; c; d | +-----------+--------------+ 预期成果: +-----------+--------------+ | Company

我正在列出几家公司的产品清单,稍后将在地图上显示。 因此,每一列都在一列中填入一家公司,而另一列中的所有产品都由

+-----------+--------------+
|  Company  |   Products   |
+-----------+--------------+
|     1     |  a; b; c; d  |
+-----------+--------------+
预期成果:

+-----------+--------------+
|  Company  |   Products   |
+-----------+--------------+
|     1     |  a           |
|           |  b           |
|           |  c           |
|           |  d           |
+-----------+--------------+
有什么方法可以实现这一点吗?

在SQL Server(至少是最新版本)中,您可以使用
string\u split()


是否要更改当前值;用于\n?在当前的预期结果中,似乎所有产品仍在同一单元格中,如果没有,请进行更改。指定您正在使用的dbms预期结果确实仍在同一单元格中。我正在研究SQL“SQL”是一种查询语言,而不是数据库产品。每个关系数据库都是一个“SQL数据库”。因此,请让我们知道您使用的是哪种DBMS产品。博士后?神谕火鸟?DB2?SQL Server?正在使用的SQL Server
select t.*, ltrim(s.value) as product
from t cross apply
     string_split(t.products, ';') s