Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HELP!! How to concatenate string from single row

Author  Topic 

rollypolly
Starting Member

2 Posts

Posted - 2011-03-21 : 04:52:48
Hello All,

I have a table with local and national ids in them, where the local one changes the national one is always the same ....
Mr John Smith might have 2 entries in the table with two different local ids but with one national id, i want to pick the national id and concatenate the local id into a single field to match the national id. e.g.
Name Local_id National_id
J.Smith 1 5Q
J.Smith 2 5Q

what I want to do is something like this:
Name Local_id National_id
J.Smith 1,2 5Q

Many thanks in advance for your help

Rolly Polly

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-21 : 04:56:29
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254
http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/rowset-string-concatenation-which-method-is-best.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-03-21 : 21:27:35
Please read any book on RDBMS and spend some time on the part about First Normal Form (1NF). It will keep you from asking bad questions again.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page
   

- Advertisement -