>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