Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have so many long database so i used seq_no in commas separate using more then one sequence store in single column but now i want all sequence in a single column so i confused how to create this sql result for this.

For ex.

SR_NO   SEQ_NO
  1     1839073,
  2     1850097,1850098,
  3     1850099,1850100,1850110    

I got like this resule

SEQ_NO 
1839073
1850097
1850098
1850099
1850100
1850110


Thanks.!

[edit]SHOUTING removed, Code block fixed- OriginalGriff[/edit]
Posted
Updated 21-Apr-15 1:56am
v2
Comments
OriginalGriff 21-Apr-15 7:57am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
John C Rayan 21-Apr-15 8:13am    
Check the solution below. I agree with OriginalGriff one hundred percent.

1 solution

The best suggestion is "don't".
Always store values as the most appropriate type: which means that numbers get stored in numeric columns, dates in DATETIME columns, and so on.

And when it comes to sequences of numbers, storing them as comma separated values is nice and simple to do for the initial insert, but quickly becomes a major PITA to do anything useful with. As you are starting to see! Now imagine that you need to change "1850100" to "1850275" later on - and think what a difficult, clumsy and generally awkward job it is.

Instead, change your DB to use a second table which correlates a sequence number to a SR_NO and use SQL to retrieve them. It's a little more difficult to set up initially, but it will save you a serious amount of time later.

But if you think must keep a very bad database design then this: Converting comma separated data in a column to rows for selection[^] will show you how to do this task - and you might change your mind! :laugh:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900