Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Display rows without duplication

Author  Topic 

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2007-04-28 : 05:33:31
i am trying to display the results but not have the order id display on 2nd line

USE NORTHWIND
DECLARE @OrderId int
DECLARE @Orders TABLE (
OrderId int,
ProductId int,
ItemTotal money
)

DECLARE CaracasOrders CURSOR FAST_FORWARD READ_ONLY
FOR SELECT OrderID FROM Orders WITH (NOLOCK) WHERE ShipCity = 'Caracas'

OPEN CaracasOrders
FETCH NEXT FROM CaracasOrders INTO @OrderId

WHILE (@@FETCH_STATUS = 0)
BEGIN
INSERT INTO @Orders
SELECT @OrderId, ProductId, (Quantity * UnitPrice) As ItemTotal FROM [Order Details] WHERE OrderID = @OrderID

FETCH NEXT FROM CaracasOrders INTO @OrderId
END

CLOSE CaracasOrders
DEALLOCATE CaracasOrders

SELECT * FROM @Orders


10268 29 990.0000
10268 72 111.2000
10785 10 310.0000
10785 75 77.5000

so i get this
10268 29 990.0000
72 111.2000
10785 10 310.0000
75 77.5000

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-28 : 05:37:19
Why don't you do this in your front end ? It is much easier.


KH

Go to Top of Page

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2007-04-28 : 06:14:19
The front end is not ready so i was going to be emailing the results to a user.

I did the same thing using northwind as an example.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-28 : 10:10:19
How are you emailing the results?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -