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 |
|
ramdas
Posting Yak Master
181 Posts |
Posted - 2003-01-08 : 17:17:42
|
| Hi Folks,I have query which returns a list of ID's which are not present in a master lookup table. I want to be able report the missing ID's in the following format:Assume I get results Like234125I want to return a string like "The iD's 23,4,12,5 are missing...", In short I want to be able to concatenate the missing ID's, how would I achieve this in SQL.ByeRamdas NarayananSQL Server DBA |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-01-08 : 17:51:56
|
| I *think* it will take a stored procedure to get this done.DECLARE @mystring varchar (8000)SET @mystring = NULLselect @mystring = IsNull(@mystring + ', ' + ID, ID)FROM MyTableWHERE give your condition hereThe string could be returned as a recordset withSELECT @mystringbut I'd rather return it as an output parameter. If you need help with OUTPUT parameters, there are some good papers on this website. Use the search option on the home page for 'output parameter'.HTHSam |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-01-08 : 19:44:12
|
| My SQL Wish #323:A CONCAT() aggregate function.....- Jeff |
 |
|
|
|
|
|