| Author |
Topic |
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2005-06-28 : 07:30:31
|
| Hi,In query analyser I get an eror when writing the follwoing line:declare curPhoneBookFeed cursor forif (@CompanyCode = 'A') begin select field1, field2, field3 from tblA endelse if (@CompanyCode = 'B') begin select field1, field2, field3 from tblB endThe error is:Incorrect syntax near the keyword 'if'.Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-28 : 07:38:29
|
| Can you post the entire code you used?MadhivananFailing to plan is Planning to fail |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-06-28 : 07:41:36
|
Try if (@CompanyCode = 'A')begindeclare curPhoneBookFeed cursor forselect field1, field2, field3 from tblAendelse if (@CompanyCode = 'B')begindeclare curPhoneBookFeed cursor forselect field1, field2, field3 from tblBend AndyBeauty is in the eyes of the beerholder |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-06-28 : 08:37:22
|
how bout:kill curPhoneBookFeed cursor Corey Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now." |
 |
|
|
AndyB13
Aged Yak Warrior
583 Posts |
Posted - 2005-06-28 : 08:42:27
|
Yep scrub my answer i'm with Corey on this one Beauty is in the eyes of the beerholder |
 |
|
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2005-06-28 : 09:20:51
|
| where do you usekill curPhoneBookFeed cursor in the following sql pleaseif (@CompanyCode = 'A')begindeclare curPhoneBookFeed cursor forselect field1, field2, field3 from tblAendelse if (@CompanyCode = 'B')begindeclare curPhoneBookFeed cursor forselect field1, field2, field3 from tblBend |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-06-28 : 09:25:45
|
kill curPhoneBookFeed cursor means don't use a cursor... its rarely the best option! and if you must:declare curPhoneBookFeed cursor forselect field1, field2, field3 from tblA Where @CompanyCode = 'A'Union Allselect field1, field2, field3 from tblB Where @CompanyCode = 'B'EDIT: should work... but I've never used a cursor (intentionally)Corey Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now." |
 |
|
|
Crito
Starting Member
40 Posts |
Posted - 2005-06-28 : 12:52:33
|
| don't use begin and end if there's only one statement in between, it confuses the !@#$% out of the parser.----------------------------------Gun for hire, have horse, will travel. |
 |
|
|
|