Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=green]--set up sample data
[/color][COLOR=blue]create[/color] [COLOR=blue]table[/color] users (IDuser [COLOR=blue]int[/color], [COLOR=blue]Name[/color] [COLOR=blue]varchar[/color](10))
[COLOR=blue]create[/color] [COLOR=blue]table[/color] skills (IDuser [COLOR=blue]int[/color], Skill [COLOR=blue]varchar[/color](10))
[COLOR=blue]insert[/color] users
[COLOR=blue]select[/color] 1, [COLOR=red]'John'[/color]
union all [COLOR=blue]select[/color] 2, [COLOR=red]'Peter'[/color]
union all [COLOR=blue]select[/color] 3, [COLOR=red]'Josh'[/color]
[COLOR=blue]insert[/color] skills
[COLOR=blue]select[/color] 1, [COLOR=red]'typist'[/color]
union all [COLOR=blue]select[/color] 1, [COLOR=red]'acct'[/color]
union all [COLOR=blue]select[/color] 2, [COLOR=red]'sniper'[/color]
union all [COLOR=blue]select[/color] 3, [COLOR=red]'driver'[/color]
union all [COLOR=blue]select[/color] 3, [COLOR=red]'guard'[/color]
[COLOR=blue]go[/color]
[COLOR=green]--create user defined function
[/color][COLOR=blue]create[/color] [COLOR=#FF00FF]function[/color] concatSkills(@id [COLOR=blue]int[/color])
returns [COLOR=blue]varchar[/color](1000)
[COLOR=blue]as[/color]
[COLOR=blue]begin[/color]
[COLOR=blue]declare[/color] @skills1 [COLOR=blue]varchar[/color](1000)
[COLOR=blue]select[/color] @skills1 = [COLOR=#FF00FF]coalesce[/color](@skills1 + [COLOR=red]','[/color], [COLOR=red]''[/color]) + skill
[COLOR=blue]from[/color] skills [COLOR=blue]where[/color] iduser = @id
[COLOR=blue]return[/color] @skills1
[COLOR=blue]end[/color]
[COLOR=blue]go[/color]
[COLOR=green]--use function to get your desired result
[/color][COLOR=blue]select[/color] IDuser
, [COLOR=blue]Name[/color]
, dbo.concatSkills(IDuser)
[COLOR=blue]from[/color] users
[COLOR=green]--clean up
[/color][COLOR=blue]drop[/color] [COLOR=blue]table[/color] users
[COLOR=blue]drop[/color] [COLOR=blue]table[/color] skills
[COLOR=blue]drop[/color] [COLOR=#FF00FF]function[/color] concatSkills