Solved

Syntax to Insert Many Rows to One

Posted on 2008-10-15
6
209 Views
Last Modified: 2012-05-05
I'm trying to select many rows of data and insert them to on row separated by spaces example:

Table1
Debtor   Invoice
1               10
1               12
1               16
2                 4
5               20

I want to select all invoice numbers for Debtor 1 which are 10,12,16 and Insert them into my Note Table.

Note
Debtor      Note
1                10 12 16

Since I have so many different Debtor's that I'm dealing with I have a cursor set up, but I don't know how to set all of those invoice numbers to 1 Variable?
0
Comment
Question by:N R
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 22726514
Search for an udagg that concatenates your rows
0
 
LVL 11

Author Comment

by:N R
ID: 22731938
udagg?
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 22732237
Used Defined Aggregate... you can create your own aggregate using .net
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 11

Author Comment

by:N R
ID: 22734127
yeah, if I knew .net
0
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 500 total points
ID: 22759277
Ups, there isn't other solution buddy
0
 
LVL 11

Author Closing Comment

by:N R
ID: 31506509
Ok, thanks.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question