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 |
|
efeller
Starting Member
2 Posts |
Posted - 2004-09-18 : 15:39:37
|
| I used the following code when I used MS Access database and it worked fine. I have upgraded to SQL Server and I am very very new to all of this but the following code will not work. Anyone can help? discountfee=.65 mySQL12="SELECT searchfee AS 'OrderTotal', 'OrderTotal'*'"&discountfee&"' AS 'AmountOfDiscount', 'TotalOrder'-'AmountOfDiscount' AS FinalFee FROM tbl_o_search_code WHERE searchcodeid=8"Thanks for any help in advance.Eric F. |
|
|
aiken
Aged Yak Warrior
525 Posts |
Posted - 2004-09-18 : 16:57:38
|
| Remove the single quotes. SQL server thinks you're trying to subtract the text value 'AmountOfDiscount' from the text value 'TotalOrder', and thinks you're strange. You also won't be able to return a computed column based on another computed column (I think).Try:mySQL12="SELECT searchfee AS OrderTotal,searchfee*" & discountfee & " AS AmountOfDiscount, searchfee-(searchfee*" & discountfee & ") as FinalFee FROM tbl_o_search_code WHERE searchcodeid=8"Although, really, it seems like all you really need is "select searchfee from tbl_o_search_code where searchcodeid=8", since all of the rest is just having SQL server do math that the app could easily do. Cheers-b |
 |
|
|
efeller
Starting Member
2 Posts |
Posted - 2004-09-18 : 17:11:40
|
| Thank you for your reply. Actually I had thought about what you said about only needing to get the value from the table and then let the math take place separately and although it is something so simple, I didn't think about it right away - but you are correct!!! I was making things more complicated than they really were, haha - thank you so much for responding and clarifying this for me!!!Eric |
 |
|
|
|
|
|