如何使用逗号分隔值来构建一个包含多个列的表? [英] How do I build a table with multiple columns from a string with commas seperating the values?

查看:61
本文介绍了如何使用逗号分隔值来构建一个包含多个列的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我在C#中创建一个控制台应用程序,我需要提高它的速度,我正在将一些代码转换为Ms SQL 2014中的存储过程。我正在创建一个包含所有需要的值的列表。表。我看到有一个可以在逗号上拆分的拆分函数,但这对于具有单个列的表来说似乎很有用。我的表需要至少有5列(SSN,帐号,收入,名字,姓氏)。我的字符串看起来像这样。 (432-45-4545,23456,$ 34,000,George,Bush,444-00-6565,45633,$ 25,000,Bill,Clinton ......)我需要这个表(temp)用它来查询一个永久表对于匹配SSN的值。

该字符串也将具有动态长度。可能需要表为5千行或2万。我有一些MS Sql的基本知识,但这种方式在我的头上,我无法在任何地方找到一个例子。我主要是一个perl,c ++和c#程序员而不是数据库人。

解决方案

34,000,George,Bush,444-00-6565,45633,


25,000,比尔,克林顿......)我需要这个表(temp)用它来查询永久表中与SSN匹配的值。

字符串将也是动态长度。可能需要表为5千行或2万。我有一些MS Sql的基本知识,但这种方式在我的头上,我无法在任何地方找到一个例子。我主要是perl,c ++和c#程序员而不是数据库人。


你需要做多次拆分



和我在本文中已经清楚地解释了,请看看这个



http://www.streetrat.in/Articles/Content/Iterate-a -string-and-do-various-operations-and-convert-a-string-into-a Datatable114.aspx?RatHistory = 114 [ ^ ]

Hi. I am creating a console application in C#, I need to increase the speed of it and I am converting some of the code to a stored procedure in Ms SQL 2014. I am creating a list with all of the values that need to be in the table. I see that there is a split function that I could split on the commas, but that only seems useful for a table with a single column. My table needs to have at least 5 columns(SSN, Account Number, Earnings, FirstName, LastName). My string looks like this. ( 432-45-4545, 23456, $34,000, George, Bush, 444-00-6565,45633, $25,000, Bill, Clinton......) I need this table(temp) to use it to query a permanent table for values matching SSN.
The string will also be of dynamic length. Might need table to be 5 thousand rows or 20 thousand. I have some basic knowledge of MS Sql but this way is above my head and I can't find a example anywhere. I am mainly a perl, c++ and c# programmer not a database person.

解决方案

34,000, George, Bush, 444-00-6565,45633,


25,000, Bill, Clinton......) I need this table(temp) to use it to query a permanent table for values matching SSN.
The string will also be of dynamic length. Might need table to be 5 thousand rows or 20 thousand. I have some basic knowledge of MS Sql but this way is above my head and I can't find a example anywhere. I am mainly a perl, c++ and c# programmer not a database person.


you need to do multiple split

and i have explained it clearly in this article please have a look at this

http://www.streetrat.in/Articles/Content/Iterate-a-string-and-do-various-operations-and-convert-a-string-into-a-Datatable114.aspx?RatHistory=114[^]


这篇关于如何使用逗号分隔值来构建一个包含多个列的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆