Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
iam this my table
VB
name     family
a         b
c         d
e         f


i want insert into table
XML
<pre lang="HTML">
fullname
ab,cd,ef

</pre>


iam need query for this table
iam use this query but return table
SQL
INSERT @Temp
		    SELECT   FTeacherName + ' ' + FTeacherFamily
					FROM [dbo].[VDB_Teacher] 
							WHERE FCourseExeID=@idcoursexe
	 
		RETURN 
Posted

1 solution

SQL
DECLARE @teachers varchar(MAX)
SET @teachers = ''

SELECT @teachers = @teachers + RTRIM(FTeacherName) + ' ' + RTRIM(FTeacherFamily)
FROM [dbo].[VDB_Teacher]
WHERE FCouseExeID=@idcourseexe

--Remove the last comma
SELECT LEFT(@teachers , LEN(@teachers ) - 1)



That should give you a single field returned from the stored procedure, and will be just

'ab,cd,ef'

(based on http://stackoverflow.com/questions/180032/how-can-i-combine-multiple-rows-into-a-comma-delimited-list-in-sql-server-2005[^])
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900