I’m not sure how to explain this probably, so I’ll use an example.
I have to store (etc.) some users ID in a single value/column in my SQL Server table, so one value could look like this “4231 3271 3722 7432 4831 3192 “. of course this can be stored as a text, char, nchar, nvarchar and som on. But which is the best? if I have to only store integers(and something to separate them)?
So what is the best way to store multiple integer values inside a single SQL Server cell?
And you don’t have to post me any alternative ways to do this, as this is just an example, and it is the only right way to do this, even if I have to use varchar 🙂
I know you asked us NOT to provide alternate ways of doing this, but here goes:
Normalize!!!
Basically, you create another table with a minimum of 2 columns (UserId and the primary key of the table you described above). This way, you can have any number of User IDs for a single record in this table. You also have the value of placing only ONE User ID in a single column.
Now… If you want to do it the way you described anyway, here is what you can do:
You cannot put multiple integers in a single column and still use the datatype int. You will have to use a text type of some kind (varchar, nvarchar, etc). You should have a common, easy to read delimiter (if they are all integers, then a space or comma will work just fine).
Doing this will cause you problems down the road, and I really encourage you to do it with normalization.