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 |
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2011-01-06 : 08:48:16
|
Could any of you SQL Guru's help me out with the below logic?I am trying to code a conditional SQL statement, basically if/else.if product_id is not null select * from product where product_id = 1234 and service_id != 5678else select * from service where serivce_symbol = 'xxx' and service_id != 5678 |
|
Kristen
Test
22859 Posts |
Posted - 2011-01-06 : 09:24:06
|
"if product_id is not null"product_id has to be a variable / expression - like @product_idother than that it looks fine |
 |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2011-01-06 : 09:32:48
|
Can I avoid using a variable for product_id?Can it be done using case or exist statements? |
 |
|
Kristen
Test
22859 Posts |
Posted - 2011-01-06 : 09:59:24
|
Well product_id is a column - so you have to tell it what table / row you are talking about! otherwise it doesn't make sense.Explaining what you want to have happen will help |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
|
|