| Author |
Topic |
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-04-04 : 12:10:24
|
| I am trying to find an efficient way to incorporate adding money to existing products.I use temp tables to pull all the information together, as I thought of adding a 'flag' column, but a 'flag' column wouldn't work in this situation.So, I thought of building a quick table that contains the product id's, part numbers, and money. Then, if the product id exists in this table, it will add a certain amount (the money column) to the existing price that comes from the final temp table.I just don't know how to add an if exists() to an already existing query. If you would like me to post the select part of the query so far, I can do that (i didn't yet, it's rather big). |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-04 : 13:51:58
|
something likeIF EXISTS(SELECT 1 FROM Table WHERE ProductID=@ProductID AND PartNumber=@PartNo) UPDATE Table SET Money=@money WHERE ProductID=@ProductID AND PartNumber=@PartNoELSE INSERT INTO Table(ProductID, PartNumber, Money) VALUES (@ProductID,@PartNo,@money) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-04-04 : 15:58:54
|
| Thanks, I just did a little modified version of this and it works great. |
 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-04-05 : 00:27:27
|
quote: Originally posted by detlion1643 Thanks, I just did a little modified version of this and it works great.
Can you show us? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-05 : 05:13:09
|
quote: Originally posted by detlion1643 Thanks, I just did a little modified version of this and it works great.
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-05 : 05:34:14
|
quote: Originally posted by raky
quote: Originally posted by visakh16
quote: Originally posted by detlion1643 Thanks, I just did a little modified version of this and it works great.
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Visakh can you respond to this posthttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=142470
You've already opened a new thread for it. Then why hijacking other threads? Please keep in mind that we can see all the currently active threads------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-04-05 : 08:29:16
|
quote: Originally posted by visakh16
quote: Originally posted by raky
quote: Originally posted by visakh16
quote: Originally posted by detlion1643 Thanks, I just did a little modified version of this and it works great.
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Visakh can you respond to this posthttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=142470
You've already opened a new thread for it. Then why hijacking other threads? Please keep in mind that we can see all the currently active threads------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
don't feel bad.I always consider You as an one of the experts in this forum. So in order to bring this thread to your notice, i did like that.My intension is not to hijack other threads. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-05 : 09:49:12
|
quote: Originally posted by raky
quote: Originally posted by visakh16
quote: Originally posted by raky
quote: Originally posted by visakh16
quote: Originally posted by detlion1643 Thanks, I just did a little modified version of this and it works great.
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Visakh can you respond to this posthttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=142470
You've already opened a new thread for it. Then why hijacking other threads? Please keep in mind that we can see all the currently active threads------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
don't feel bad.I always consider You as an one of the experts in this forum. So in order to bring this thread to your notice, i did like that.My intension is not to hijack other threads.
No problem for me But its not nice to hijack somebody else's thread to cross post what you're raised already. I usually look at all active threads and reply whenever I can. In your case, I don't have much idea on problem and thats why I didn't reply.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|