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 |
|
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2009-07-27 : 03:56:24
|
| Hiwhen order is added table 1ordeno, recordid111 1table 2recordid serviceid service1 1 a1 2 bfrom above table i want output asorderno recordid service required 111 1 a,b,ci tried the queryDeclare @ServiceRequiredIDs varchar(50)SELECT STUFF((SELECT ',' +cast(x.[ServiceRequiredID] as varchar(10) )FROM RS_RecordDetails AS x WHERE x.[ServiceRequiredID] = a.[ServiceRequiredID] FOR XML PATH('')), 1, 1, '') as ser From RS_RecordDetails awhere OrderNo='111'print @ServiceRequiredIDsselect * from RS_RecordDetails where OrderNo='111'but its not printing exact outputPls tell me wts going wrong with the query |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-27 : 04:01:17
|
| Hi Try this....DECLARE @VAR VARCHAR(MAx)SELECT @VAR = ISNULL(@VAR+',','')+COLUMN_NAME FROM TABLE_NAME WHERE ORDERNO='111'SELECT @VAR-------------------------R.. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|
|