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 |
|
ssnaik84
Starting Member
15 Posts |
Posted - 2008-02-07 : 04:16:13
|
Hi All,I wanna display all values of one column, separated by comma (',').But problem is I need to display it with other columns.I hav done it as follows:DECLARE @temp nvarchar(4000)SET @temp=''SELECT DISTINCT M.Id_Message ,@temp = @temp + ',' + STO.FirstName + N' ' + STO.LastName ,M.SentDate , ML.MessageLevel , M.MessageSubject , M.[Message] FROM [Message] AS M INNER JOIN MessageLevel AS ML ON M.Id_MessageLevel = ML.Id_MessageLevel INNER JOIN MessageStaff AS MS ON M.Id_Message = MS.Id_Message INNER JOIN Staff AS STO ON MS.Id_Staff = STO.Id_Staff INNER JOIN Staff AS SBY ON M.CreatedBy = SBY.Id_Staff WHERE M.Id_Message = 1I got error as:"A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations."I donot want to make two separate select stmts.Thanks in adv.  |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
|
|
|
|
|