且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用逗号分隔值来构建一个包含多个列的表?

更新时间:2023-01-20 08:48:51

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[^]