Link to home
Create AccountLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

SQL Server Function

Hey folks...I've been trying to figure this out for days...

In on table I have a column with a series of id's passed in all in one column.  A 3 digit number followed by a space. There can be any number or combo of these strings in col2
Example
col1         col2
(info)       111 222 123 345 999

in another table I have two columns where each id is a 3 digit #
colID         AmnName
111          Suite
222          Pool
123          Fine Dining

I need to be able to do a select so that I get
col1        col2
(info)      Suite,   Pool, Fine Dining    
Avatar of chapmandew
chapmandew
Flag of United States of America image

I believe angelll has a really good function for doing something like this....
Avatar of Larry Brister

ASKER

Do you have a link to it?  he supplied me an answer but it's not returning what I want and I have no follow-up from him.
I posted  a link to this thread to him....I dont' have a link to it or I would post it for you.  Its a neat little function that takes params and pivots them to a column list.  Id write it for you right now, but since he already has it you can just use his.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
dbo.ParmsToList, that is the one.  :)
angelIII:
Maybe I'm just having a bad day...I create the function and
I'm getting
Msg 208, Level 16, State 1, Line 2
Invalid object name 't2'.

use databasename
go
select t1.resort,dbo.TranslateAmenities(t1.amenities)
from dbo.tblSpecials t1
>Maybe I'm just having a bad day.
no. but you did not specify any table names, so I named them t1 and t2, just fill in what you need.
angelIII:

As always...thank you VERY much.
angelIII:
You must be one of the very best exoerts.  Thanks a ton.