troubleshooting Question

How to run a few Selects

Avatar of jaymz69
jaymz69 asked on
Microsoft SQL Server 2008
3 Comments1 Solution205 ViewsLast Modified:
Is it possible or a better way to run this in SQL Server 2008?

This code is from my Visual Fox Pro program
but now I need to convert into SQL Server 2008 r2


SELECT ohco, ohloc, ohord_;
		FROM oohead, ooline;
		WHERE (ohco=1 AND ohloc=50 AND olico=2 AND oliloc=42);
		AND ohco=olco AND ohloc=olloc AND ohord_=olord_ and ohrel_=olrel_;
		GROUP BY ohord_ INTO CURSOR cOrders50 readwrite
		
		SELECT ohco, ohloc, ohord_;
		FROM oohead, ooline;
		WHERE (ohco=1 AND ohloc=60 AND olico=2 AND oliloc=42);
		AND ohco=olco AND ohloc=olloc AND ohord_=olord_ and ohrel_=olrel_;
		GROUP BY ohord_ INTO CURSOR cOrders60 readwrite
		
		SELECT ohco, ohloc, ohord_;
		FROM oohead, ooline;
		WHERE (ohco=2 AND ohloc=42 AND olico=1 AND oliloc=60);
		AND ohco=olco AND ohloc=olloc AND ohord_=olord_ and ohrel_=olrel_;
		GROUP BY ohord_ INTO CURSOR cOrders42 readwrite
		
*-- Union all the cursors together for one
		SELECT * FROM cOrders50 UNION SELECT * FROM cOrders60 UNION SELECT * FROM cOrders42 into cursor cAllOrders readwrite
	
*-- Count to email results		
		Count To m.COUNT

		If m.COUNT>0
-- DO Email.prg
ASKER CERTIFIED SOLUTION
Faiga Diegel
Sr Database Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros