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 |
|
ri16
Yak Posting Veteran
64 Posts |
Posted - 2008-02-13 : 11:39:18
|
| indx Title plateno-------------------------------0 Wallet 07-52450 Palletbox 07-52480 Juicecup 07-5251(3 row(s) affected)indx Title plateno----------- ------------------ 1 Boxcup 36511 Boxcup 034SPO1 Boxcup 034NO1 Boxcup 8301 Boxcup ABO1 Boxcup INO1 Boxcup ED871 Boxcup TY891 Boxcup IU8(9 row(s) affected)i have to use these 2select statements ouput and create one procedure if indx=0 then ...and if indx=1 then....how do i create procedure? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-13 : 11:43:27
|
| [code]CREATE PROCEDURE YourProc@Indx intASif @indx=0begin..............code hereendif @indx=1begin..............code hereendgo[/code] |
 |
|
|
ri16
Yak Posting Veteran
64 Posts |
Posted - 2008-02-13 : 12:00:28
|
| thanks for ur reply..but its not simple..actually, i forgot to mention that indx and title is in one table and plateno is in one functionCREATE PROCEDURE myprocASBEGIN SELECT distinctt.indx, t.title, case when t.indx = 0 then dt.plateno when t.indx = 1 then dt.plateno end as plateno FROM titleindxtab tright outer join funcDtitle('') dton t.indx=1where indx=t.indxand dt.plateno is not null endbut insteada of getting 12rows as output..i m getting 900rows.. |
 |
|
|
ri16
Yak Posting Veteran
64 Posts |
Posted - 2008-02-13 : 12:07:35
|
| SELECT 0 as indx,Title as dTitle, plateno from funcDtitle('')where num in ('P','he1r','pu14')and Topnum in ('PG','THM')and Aucnum in ('47c', '145p')and not Snum in ('EA','LPTC') SELECT 1 as indx, 'Care Cent' as dTitle,platenofrom funcDtitle('') where num in ('P','he1r','pu14')and Topnum in ('PG','THM')and Aucnum in ('47c', '145p')and Snum in ('EA','LPTC') these r 2select statements which i have andi have to use in sproc..but i don't have to use where clause values..in sproc..can u help me now?thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-13 : 12:09:19
|
| Sorry but you have explain this more,giving table structures,some sample data and also tell what function does. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-14 : 04:24:40
|
| TryCREATE PROCEDURE myproc(@indx int)ASBEGINSELECT distinctt.indx, t.title, dt.plateno end as platenoFROM titleindxtab tright outer join funcDtitle('') dton t.indx=1where t.indx=@indxand dt.plateno is not null ENDMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|