I have two tables in SQL Server 2012
Table1
UserID | Name |
---|---|
1 | Joe |
2 | Mary |
Table2
UserID | Permission |
---|---|
1 | P15 |
2 | P5 |
2 | P330 |
Each user can have between 1 and 8 Permissions.
I need to create a view that will give me the UserID with 8 permission entries with any unused entries containing null values i.e. The order of the entries does not matter.
UserID | Permit1 | Permit2 | Permit3 | Permit4 | Permit5 | Permit6 | Permit7 | Permit8 |
---|---|---|---|---|---|---|---|---|
1 | P15 | Null | Null | Null | Null | Null | Null | Null |
2 | P5 | P330 | Null | Null | Null | Null | Null | Null |
This has me stumped, I don't even know where to start?