.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Dividing a comma delimited string

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :Sql Server

Hi guys,

I am fairly new to TSQL and need some urgent help on this.

I have a column in a table made up of a string that has data as follows:


I would like to break the long string into different words and then store them in separate columns, so I should have

Column 1: COSTS

Column 2: LEVEL

Column 3: GRADE

Column 4: ITEM

Can someone please help me out with this, taking into consideration the fact that I am a newbie to TSQL.


Thank you

View Complete Post

More Related Resource Links

Matching every third word in a comma delimited string.


Hello all,

I have to write a .NET program that accepts a string of comma delimited values.  I want to write a regular expression to accept every third value (starting with the sixth).  I have a regex to skip the first three values and return groups of three:


Now I need something to skip the first two words within each group.  Any suggestions?

Thanks in advance

Convert comma delimited record to string array


Is there any efficient way to convert a comma delimited record with quotes to string array?

Say, "Peter","Pan",123,"Hello, is it ok",Test
str[0] = "Peter"
str[1] = "Pan"
str[2] = 123
str[3] = "Hello, is it ok"
str[4] = "Test"

That is comma within quotes are not treated as delimited


Comma-Delimited Output

One of the common tasks performed when retrieving data from a SQL Server database is returning the result as a comma-delimited output instead of a result set. This task can be performed by using a CURSOR selecting the column to be concatenated together. Each row returned by the CURSOR is then concatenated together into a variable separating each one by a comma.

Comma in viewstate string

Hi, I'm running into following error: "The viewstate is invalid for this page and might be corrupted." "Invalid character in base64 string." Only with IE 8.0.  Firefox works fine. The persisted view state is "/wEPDwULLTE2OTU5NzE1MjYPZBYCAgMPZBYCAgEPZBYCAgMPZBYCZg9kFgQCBQ8WAh4FVmFsdWUFCGRpc2FibGVkZAIHDxYCHwAFCGRpc2FibGVkZGSt4I2szqsXGPwfecanpFW+cIZNhQ==,/wEPDwULLTE2OTU5NzE1MjYPZBYCAgMPZBYCAgEPZBYCAgMPZBYCZg9kFgQCBQ8WAh4FVmFsdWUFCGRpc2FibGVkZAIHDxYCHwAFCGRpc2FibGVkZGSt4I2szqsXGPwfecanpFW+cIZNhQ==" i.e. two identical parts separated by a comma. I'm using a form with both jQuery and UpdatePanel. I've inspected the __VIEWSTATE hidden field before the post __doPostBack and  $I.System.InvokePageMethod.  In both cases the viewstate does NOT contain the comma. Any ideas where the field gets doubled up with the comma inserted? Or how to fix.   Thanks,   D

Replace the string after comma starts in MS SQL


Hi All

Could you anybody help me, How to replace the remaining String after the Comma Starts Using SQL Query.  Below is the data

"MediaRights, MediaRightsLink, MediaRightsCompanies, MediaRightsTypes"

EvtBids 1
MediaRights, MediaRightsLink, MediaRightsCompanies, MediaRightsTypes 1
MediaRightsLink 8
SponsorRights, SponsorRightsLink, SponsorRightsBrands, SponsorRightsTypes 3
SponsorRights, SponsorRightsLink, SponsorRightsCompany, SponsorRightsCompanyTypes 1

Comma delimited procedure Help!


I need some help. This is going to be confusing so bare with me please!

I have a linked server and from what I read you cannot bring over multi-valued items.  And one of the items I need has up to three values for the same variable.  So I have objectClass listed three times on the server I am linked to with three different values for objectClass.

-objectClass | hi

-objectClass| hello 


In the linked server data store objectClass is a list of schemas and in my SQL(2008) DB I just made a table names objectClasses with the data type NAME which is a nvarchar(MAX).  I have an LDAP query that grabs all the NAMES from the objectClass table on the linked server I'm connected to. and then inserts them into that table which was 700 records.

I created another table called Groups, and it has a column named objectClass which I made an nvarchar(MAX).  I need a stored procedure, (was looking at one that used the Comma delimited list) that loops through the linked server data store and put the three objectClass values in a string of some sort and then I can insert that one set of values into the Groups table.

I must do this through SQL, not .NET.

Anyone have an idea to help me out! Thanks!


Comma delimited list in table column


Hi, does anyone know how this can be done?


I have a table which has a varchar column with a delimited list of values seperated by columns.

eg.  24234234,123123,12312312,12312312,1231231


I need to be able to search this table finding all rows where an input number matches any of the numbers in the delimited list.


And ideas?








Specifying a comma separated string as a parameter value in BIDS


Hi, I have a problem that is driving me mad.  I am trying to create a report in BIDS that pulls data from oracle database and generates the report of call it sales by month.  What I'm attempting to do is to create a parameter in BIDS and force a comma separated value into it and then pass that value into SQL statement for an oracle dataset in other words.

BIDS:  Parameter @QTR Paramater label QTR1  Paramter value ('01','02','03')

           Parameter @Year Parameter label Year Parameter value 2010

Oracle side: select * from ....

where year=:Year and

month in :QTR

Whenever I try to run it like that the report generates but it's blank.  Replacing value in QTR parameter with a single non quoted value like 01 generates report perfectly fine.  Could anyone shed some light as to how properly specify comma delimited strings to be used in :in: statements. 

Replacing last comma in string with different character


Hi i have a string, and i want to replace the last comma with something else. For instance this is my string;

"Monday, December 6, 9:00 PM"

How do i replace that last comma so it can look like this;

"Monday, December 6 2010 9:00 PM"

Can it be done? Delimited String Splitter TVF with Automatic Delimiter Recognition


The request for T-SQL scripts answers located in the following thread:


This thread is not for scripts, it is for discussion.


Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM

Delimited String Splitter Function with Unknown Delimiter/Rule


I am looking for the best T-SQL solution. Hints are just given for problem statement, they should not be used hard-wired in the solution algorithm. Spaces can be trimmed right & left, reduced to single space in middle. It can be assumed that the following ranges are distinquished [a-z], [A-Z], [0-9].  Lookup table support can be added as last resort.

Good luck and thanks.

DECLARE @Delimited TABLE (String nvarchar(256))

INSERT @Delimited VALUES                           

Comma Quote Delimited



How do i output the results from SQL table to comma quote delimited text file.

For example i should get columns in flat file destination as


How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Connestion string create any database server

This links important to how to create connection string to any data base sever.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

Built-in Functions - String Functions

String functions let you extract various portions of character strings, change the case of strings, concatenate and reverse strings and perform many other types of manipulations. All built-in string functions are deterministic with the exception of CHARINDEX and PATINDEX

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend