1

I have a cell that contains an array of characters seperated by commas i.e. "1,2,3,4,5" My question is, is it possible to remove a particular element of the array such as if I wanted to remove "1" then the cell would then become "2,3,4,5" or remove "3" and it becomes "1,2,4,5" I want to perform this task within SQL either as a function or a stored procedure, any help is much appreciated.

1
  • That is really bad database design. If you have the ability to do so, you should move away from storing multiple values in the same column ASAP. Commented Sep 29, 2011 at 15:59

1 Answer 1

2

Sure, it'd just be some basic string REPLACE() calls: http://msdn.microsoft.com/en-us/library/ms186862.aspx

However, since you have to manipulate individual bits of this data field separately from the rest of the field, it's a good candidate for getting normalized into its own child table.

Sign up to request clarification or add additional context in comments.

1 Comment

I strongly recommend getting this column into it's own table. For oh-so-many-reasons (ability to index usefully, ease of use, referential constraints...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.