Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sriv
Starting Member
11 Posts |
Posted - 2009-04-06 : 14:22:06
|
| Hi All, I have a table which looks like this:AutoNumber Note1 C2 D3 E4 F5 G6 AIs there a stored procedure of function someone can suggest that would create patterns based on input of Autonumber.For example, "123 234 456" should generate "CDE DEF FGA". This is for a music application which helps generate practice sequences for piano students.Thank you. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-04-06 : 14:30:22
|
| Why not just pass the actual notes, instead of numeric values that represent the notes? |
 |
|
|
sriv
Starting Member
11 Posts |
Posted - 2009-04-06 : 15:00:59
|
| Hi, Thanks for the reply. The sequence is generated based on pattern algorithms. For eg, Play consecutive notes, Play notes in sequence: first note then fourth then third then second, play each note 3 times etc etc. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-04-06 : 16:40:09
|
| OK, that make sense. Will you get IDs that are 2 or more digits in length? If so that will complicate the sequence, i.e. 11 vs. 2 sequential 1's. |
 |
|
|
sriv
Starting Member
11 Posts |
Posted - 2009-04-06 : 16:52:01
|
| There can be a max of 8 notes in this particular case , so no, there wont be any double digits. Thanks. |
 |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
Posted - 2009-04-07 : 04:16:08
|
| create proc sc_convertAutoNumbers( @str varchar(100))asbegin;with cte as( select 1 as Number union all select Number + 1 from cte where Number < len(@str))select isnull(Note,substring(@str,C.Number,1)) as Note into #temp from cte cleft outer join AutoNumbers A on substring(@str,C.Number,1) = A.AutoNumberselect replace( (select ',' + Note from #temp for xml path('')) ,',','')end |
 |
|
|
sriv
Starting Member
11 Posts |
Posted - 2009-04-07 : 10:29:18
|
| This is excellent. Thank you very much. |
 |
|
|
|
|
|
|
|