Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL
Expertise: Advanced
Jul 27, 2004



Application Security Testing: An Integral Part of DevOps

Retrieve a Concatenated String from One Column of a Table Without Using the Cursor

Sometimes, you need to retrieve a concatenated string from one column of a table without using the cursor. To do this, you can use string aggregation. Here's how:
  1. Create & fill the table using this script:
    Create Table Cust(CustID int,CustName varchar(20))
    Insert into Cust Values(1,'Rohit')
    Insert into Cust Values(2,'Amit')
    Insert into Cust Values(3,'Sumit')
    Insert into Cust Values(3,'Punit')
  2. Execute this script:
    Declare @Names Varchar(2000)
    Select @Names=Isnull(@Names+','+CustName,CustName)
    From Cust
    Select @Names
  3. You will get this result:
    (1 row(s) affected)
Rohit K. Gupta
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date