here is my problem i have one table in which values (heaLth management system,INC.,SUMTOTAL management,INC.,) while i am executing procedure it is taking string one name as two seperated strings.So my requirement is to take them as singel string heaLth management
systemINC.,SUMTOTAL managementINC.,). For every string name end with comma but not with in the middle of the string.how to write a query for this one.suggest me int MS SQL
in my store procedure i am sending comma seperated names.but while executing procedure (heaLth management system,INC.,SUMTOTAL management,INC.,) it have to take name as string like heaLth management system,INC., but in my case heaLth management system
is one string ,INC., is coming as another string.For every name comma must be there but not in the middle of the name (i.e heaLth management system,INC., )
mohan111
Member
46 Points
132 Posts
update comma seperated two string values into one string in ms sql
Jul 11, 2012 01:46 PM|LINK
here is my problem i have one table in which values (heaLth management system,INC.,SUMTOTAL management,INC.,) while i am executing procedure it is taking string one name as two seperated strings.So my requirement is to take them as singel string heaLth management systemINC.,SUMTOTAL managementINC.,). For every string name end with comma but not with in the middle of the string.how to write a query for this one.suggest me int MS SQL
thanks in advance
alvingeorge
Participant
925 Points
203 Posts
Re: update comma seperated two string values into one string in ms sql
Jul 11, 2012 01:49 PM|LINK
can you please provide more details
It is not clear what you want to achieve.
HO w you data stored in database , is it separate clumns?
mohan111
Member
46 Points
132 Posts
Re: update comma seperated two string values into one string in ms sql
Jul 11, 2012 01:58 PM|LINK
in my store procedure i am sending comma seperated names.but while executing procedure (heaLth management system,INC.,SUMTOTAL management,INC.,) it have to take name as string like heaLth management system,INC., but in my case heaLth management system is one string ,INC., is coming as another string.For every name comma must be there but not in the middle of the name (i.e heaLth management system,INC., )
Allen Li - M...
Star
10411 Points
1196 Posts
Re: update comma seperated two string values into one string in ms sql
Jul 16, 2012 12:13 AM|LINK
Hi, please refer to the following method:
string str = @"heaLth management system,INC.,SUMTOTAL management,INC.,"; string[] arr = str.Split(','); string str1 = ""; // str2 is the string you want string str2 = ""; foreach (var item in arr) { str1 += item; if (item.Contains('.')) { str2 += str1 + ","; str1 = ""; } }If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework