i pass parameter as productid, i check in productrelated table whether this product related product are there or not if it is no开发者_StackOverflow社区t there i want to check sample productid in departmentreplated table if it is not there i find the department of the productid and find the that productid related department product..
Plz help me how to write the store procedure.... which logic i want to use....
help me writing procedure.... reply as soon as ... thanks...
I guess you really want an answer on this and tried your best to formulate the question.
The way you describe it you need to do that with a SELECT statement that does a LEFT JOIN. I cannot help you with the store procedure on SQL-SERVER but I guess you can figure out the rest once you have the SELECT.
SELECT ISNULL(p.someValue, d.someValue)
FROM DepartmentRelatedTable d
LEFT JOIN ProductRelatedTable p on (d.ProductId = p.ProductId)
WHERE d.ProductId = <some id here>
You maybe need to do a FULL JOIN instead of a LEFT JOIN because. I could not fully understand the data model you are using.
精彩评论