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 |
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-08-25 : 16:52:45
|
| Hi guys,I have my_table which has columns :col1= sequence(identity) col2= name ( A,B & C only)col3= Action (X and Y only)Also note that I have 6 stored Procs ready for each case for col2 and col3possible combination for col2, col3 are :A X ..sp1B X ..sp2C X ..sp3A Y ..sp4B Y ..sp5C Y ..sp6 now I want to write a query which starts processing according to the sequence(col1)so It will process sequence = 1 first, now if col2 = B and col3 = Y then it should execute SP3I want to add all 6 cases but according to the sequencenow for sequence 2, if col2 = C and col3 = Y then it should execute SProc 6..I know its not very difficult. Please Help ! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-26 : 00:09:09
|
| not sure whether this is a good approach but i would certainly recommend moving all logic to same sp. the current method would require a cursor which does a row by row processing then a series of check for each row and call a sp. You would be doing this all inside same sp in set bnased manner------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-08-26 : 14:54:10
|
| Thanks vishakh:But the sequence here plays very important role. I have sequenced the data according to very complex business logic. If data is not processed according to the sequence, the whole conditions would fail.also I cant run SP1 first for all data and so on..So it has to be with cursors. also, I have possible 6 cases only. Inside the same SP would make run SP1 for all data and then sp2 and so on but again, I need to run it by the sequence that I already have. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-27 : 04:45:37
|
| why not do all this check inside same sp. pass the values sequentially and inside sp check each and apply appropriate logic. I certainly feel like you're over complicating things unless i see some sample data to illustrate the problem.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|