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:
01338955
Views:
9
>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
>
I'll let him know :)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform