本文介绍了分离单列值并将其显示在单独的列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 是否可以在单个选择语句中执行此操作。 例如 CREATE TABLE dbo.Table1 ( Col1 CHAR ( 1 ), Col2 CHAR ( 1 ), Col3 CHAR ( 1 ), Col4 VARCHAR ( 50 )) GO INSERT INTO dbo.Table1 VALUES (' A',' B',' C',' 100,28784, 3'),(' C',' D',' E' ,' 200,30,400,8999') GO SELECT * FROM dbo 。表格1; GO 输出应该是这样的...它应该在单个选择语句中。 b $ b Col1 Col2 Col3 Val1 VAl2 Val3 Val4 Val5 ABC 100 28784 3 null null CDE 200 30 400 8999 null 解决方案 您需要将col3的文本拆分为多个列。在这里你会找到一个解决方案: http://blog.sqlauthority.com/2010/02/10/sqlauthority-news-converting-a-delimited-string-of-values-into-columns/ [ ^ Can it is possible to do this in single select statement.for ExampleCREATE TABLE dbo.Table1( Col1 CHAR(1), Col2 CHAR(1), Col3 CHAR(1), Col4 VARCHAR(50))GOINSERT INTO dbo.Table1 VALUES ('A','B','C','100,28784,3'),('C','D','E','200,30,400,8999')GOSELECT * FROM dbo.Table1;GOOutput should like this...It should be in single select statement.Col1 Col2 Col3 Val1 VAl2 Val3 Val4 Val5A B C 100 28784 3 null nullC D E 200 30 400 8999 null 解决方案 You need to split text of col3 into many columns. Here you''ll find a solution: http://blog.sqlauthority.com/2010/02/10/sqlauthority-news-converting-a-delimited-string-of-values-into-columns/[^] 这篇关于分离单列值并将其显示在单独的列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 19:09