Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it possible to embed some logic inside the SQL CASE?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01338925
Message ID:
01338949
Views:
12
This message has been marked as a message which has helped to the initial question of the thread.
>>
>>Maybe there is a way to combine them, but that is NOT the way.
>>Could you send me a link to see the queries?
>
>Had hard time finding this thread :)
>
>Here it is http://forums.asp.net/t/1305210.aspx

That IS terrible programing!
That guy hard coded some warehouse in its SP.
No optional parameters no nothing.
What if I want to get values for ALL warehouses? That SP didn't work at all.
And he/she always hope that the table will have ONLY one record in table for some condition.
Maybe that is true BUT that is only HOPE! :-)


So:
1. Covert First SP to Function lets it have a different name than original SP
2. Create a new SP named exactly as the first one that have only;
SELECT dbo.TheFunction(@ProjectCodem, @Sku)
That is needed so not to have anything changed in the FrontEnd.
3. Use that function in the second SP:
SELECT DISTINCT SM.sku_id, SM.sku_description, SM.unit_price,
                SM.product_type, ST.description,
                SM.product_group, SM.warehouse_id,
                dbo.TheFunction(right parameters here) AS SomeName
FROM       sku_master SM
INNER JOIN sku_alias SA on SM.sku_id = SA.sku_id 
INNER JOINsku_types ST on SM.product_type = ST.Item_Type
WHERE SA.sku_group = @SkuGroup AND
      SM.destroy_status = 'ACTIVE' AND
      SM.sku_status = 'ACTIVE'
ORDER BY SM.sku_id ASC
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform