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.
| Author |
Topic |
|
ferrethouse
Constraint Violating Yak Guru
352 Posts |
Posted - 2009-08-12 : 18:42:56
|
| I know the "MERGE" function below doesn't exist but is there someway to accomplish this without a stored proc?select MERGE(CourseTitle,"|") from Courses where Certificate = 1 Group by CertificateI want one record returned that looks like this...Course1|Course2|Course3 |
|
|
ferrethouse
Constraint Violating Yak Guru
352 Posts |
Posted - 2009-08-13 : 00:15:04
|
Ok. I went ahead and did a stored procedure. I would like for the table name, where clause, and select field to be variables passed in but I can't get it to work like that. Is it possible? Here is my code so far...SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE sp_Merge @searchFor varchar(100)AS BEGINDECLARE @MergedItem varchar(1000)DECLARE @TempString varchar(100) DECLARE c1 CURSOR READ_ONLYFORSELECT FirstNameFROM Person.Person where LastName = @searchForOPEN c1FETCH NEXT FROM c1INTO @MergedItemWHILE @@FETCH_STATUS = 0BEGIN FETCH NEXT FROM c1 INTO @TempString SET @MergedItem = @MergedItem + '|' + @TempString ENDSELECT @MergedItemCLOSE c1DEALLOCATE c1 ENDGO |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-08-13 : 00:43:49
|
| there is no merge function in the MSSQL server r u using MS SQL serverif u want in sql server try to use funciton or XML PATH() see in books online for details |
 |
|
|
|
|
|