Click here to Skip to main content
15,911,786 members
Home / Discussions / Database
   

Database

 
QuestionXML Related Pin
NICE TO MEET29-Sep-06 1:20
NICE TO MEET29-Sep-06 1:20 
AnswerRe: XML Related Pin
AskSharp1-Oct-06 12:08
AskSharp1-Oct-06 12:08 
QuestionGenerating SQL Table and Insert statements Pin
Brendan Vogt29-Sep-06 0:55
Brendan Vogt29-Sep-06 0:55 
AnswerRe: Generating SQL Table and Insert statements Pin
zhengdong jin29-Sep-06 20:00
zhengdong jin29-Sep-06 20:00 
QuestionRe: Generating SQL Table and Insert statements Pin
Brendan Vogt2-Oct-06 19:37
Brendan Vogt2-Oct-06 19:37 
QuestionConcatenate several records into one Pin
Steven J Jowett28-Sep-06 23:13
Steven J Jowett28-Sep-06 23:13 
AnswerRe: Concatenate several records into one Pin
zhengdong jin28-Sep-06 23:40
zhengdong jin28-Sep-06 23:40 
AnswerRe: Concatenate several records into one Pin
Steven J Jowett6-Oct-06 4:26
Steven J Jowett6-Oct-06 4:26 
MY finalized function, if anyone is interested :-


<br />
set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
GO<br />
CREATE FUNCTION [dbo].[ConcatNotes](@TicketId BigInt) <br />
RETURNS NVarChar(4000)<br />
AS<br />
BEGIN<br />
<br />
	-- Declare the return variable here<br />
	DECLARE @Narrative NvarChar(4000)<br />
	DECLARE @Notes NVarChar(2000)<br />
	DECLARE notes_cursor CURSOR FOR SELECT [Text] FROM Notes WHERE TicketId = @TicketId ORDER BY NoteId ASC<br />
	OPEN notes_cursor<br />
	FETCH NEXT FROM notes_cursor INTO @Notes<br />
	SET @Narrative = ''<br />
	WHILE @@FETCH_STATUS = 0<br />
		BEGIN<br />
			IF LEN(@Narrative) > 0<br />
				BEGIN<br />
					SET @Narrative = @Narrative + ' ¦ '<br />
				END<br />
			SET @Narrative = @Narrative + @Notes<br />
			FETCH NEXT FROM notes_cursor INTO @Notes		<br />
		END<br />
<br />
	CLOSE notes_cursor<br />
	DEALLOCATE notes_cursor<br />
	-- Return the result of the function<br />
	RETURN LTRIM(@Narrative)<br />
END<br />
<br />


Then in my SELECT statement

SELECT TicketId, ConcatNotes(TicketId) AS Narrative FROM Tickets

Thanks to Zhengdong Jin for pointing me in the right direction

Steve Jowett
Questionauto increment Pin
amaneet28-Sep-06 19:43
amaneet28-Sep-06 19:43 
AnswerRe: auto increment Pin
Chris Buckett28-Sep-06 23:28
Chris Buckett28-Sep-06 23:28 
Questionauto generation of primary keys Pin
lakshmi_sri28-Sep-06 17:14
lakshmi_sri28-Sep-06 17:14 
AnswerRe: auto generation of primary keys Pin
Chris Buckett28-Sep-06 23:30
Chris Buckett28-Sep-06 23:30 
QuestionWHich is more optimal?? Pin
happyheartcs27-Sep-06 23:40
happyheartcs27-Sep-06 23:40 
Questionpb connecting to remote sql server Pin
rama charan27-Sep-06 21:04
rama charan27-Sep-06 21:04 
AnswerRe: pb connecting to remote sql server Pin
Rob Graham28-Sep-06 4:57
Rob Graham28-Sep-06 4:57 
GeneralRe: pb connecting to remote sql server Pin
rama charan3-Oct-06 19:29
rama charan3-Oct-06 19:29 
QuestionBuinding in DataGridView Pin
nesaraja27-Sep-06 19:08
nesaraja27-Sep-06 19:08 
AnswerRe: Buinding in DataGridView Pin
just3ala227-Sep-06 22:39
just3ala227-Sep-06 22:39 
Questiondatabse problem Pin
With_problem27-Sep-06 18:55
With_problem27-Sep-06 18:55 
QuestionGrouping events that fall within x days of other events? Pin
T-Smooth27-Sep-06 16:34
T-Smooth27-Sep-06 16:34 
QuestionHow to Select the last N records based on date? Pin
shapper27-Sep-06 15:42
shapper27-Sep-06 15:42 
AnswerRe: How to Select the last N records based on date? Pin
nguyenvhn27-Sep-06 16:00
nguyenvhn27-Sep-06 16:00 
GeneralRe: How to Select the last N records based on date? Pin
shapper27-Sep-06 16:52
shapper27-Sep-06 16:52 
GeneralRe: How to Select the last N records based on date? Pin
nguyenvhn28-Sep-06 0:23
nguyenvhn28-Sep-06 0:23 
QuestionSQL Server Reporting Services ReportViewer Pin
catmom27-Sep-06 11:46
catmom27-Sep-06 11:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.