I've run across multiple situations in the last few months where legacy sql SP's are returning a single table made up mostly of redundant information.
Example:
Select CustomerID, CustomerEmail, CustomerAddress, InventoryLineItem, ShipQty from ...
Returns:
55 [email protected] 723 StreetName InvLineItem#1 45
55 [email protected] 723 StreetName InvLineItem#2 42
55 [email protected] 723 StreetName InvLineItem#3 1
55 [email protected] 723 StreetName InvLineItem#4 5
55 [email protected] 723 StreetName InvLineItem#5 200
55 [email protected] 723 StreetName InvLineItem#6 7045
(first 3 fields never change)
Since I'm the only developer on the project, I've started breaking this into two select statements. (I work on the receiving .NET code as well)
select CustomerID, CustomerEmail, CustomerAddress from ....
Returns: 55 [email protected] 723 Streetname <-- 1 record
select InventoryLineItem, ShipQty from .... Returns:
LineItem#1 45
LineItem#2 42
LineItem#3 1
etc.
Obviously the resulting Dataset in .NET is smaller, but it really bugs me to have sometimes 10 fields in a select statement that are always under all circumstances exactly the same. Some of the queries may even return 10's of thousands of records.
I feel like I'm doing the right thing here, but then again I'm no SQL pro.
Are there any reasons for me to avoid this practice?
Thanks in advance for your time.