开发者

Storing Multi Choice Field into in SQL Server 2008

I'm writing an app in .NET, and using a dropdown checkbox.

I'm not sure what the best practice is for storing this info in the db.

Currently I'm writing back a comma delimited string to an SP in SQL Server 2008 ie "apple, banana, pear", storing this in a nvarchar(MAX) and then splitting this in the SP into another table holding the ID and the Type ie

ID Type

17 apple

17 banana

17 开发者_运维技巧 pear

Is this overkill, or the correct approach?


The important thing is to keep the database normalized. You're doing exactly that, so I'd say your approach is fine.

Passing a comma-separated string to a stored procedure is okay too. You could refine it with tables parameters or multiple procedure calls, but those have a significant overhead in development time and performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜