troubleshooting Question

Looping

Avatar of Stevie Zakhour
Stevie Zakhour asked on
Microsoft SQL ServerSQL* loop
8 Comments1 Solution74 ViewsLast Modified:
Hi Guys

I have a MS SQL table called Scoreboard, it currently has 9 rows. See below

Snip20200205_19.png
I put together a query that reads from the table Scoreboard, see below. I want to run this query 9 times until it has read all 9 rows. How do I do this?

DECLARE @LeaderboardName		varchar		(20)
DECLARE @LeaderboardNameFull	varchar		(20) 
DECLARE @PlayerCount			varchar		(20)
DECLARE @PlayerName				varchar		(20)
DECLARE @Score					nvarchar	(20)
DECLARE @ZombiesKilled			varchar		(15)
DECLARE @Accuracy				varchar		(50)
DECLARE @DamageTaken			varchar		(20)
DECLARE @Deaths					varchar		(50)

Select	 @LeaderboardName        = LeaderboardName		from #Temp		
Select   @LeaderboardNameFull	 = LeaderboardNameFull	from #Temp		
Select   @PlayerCount	 = PlayerCount					from #Temp		
Select	 @PlayerName	 = PlayerName					from #Temp		
Select	 @Score	         = Score						from #Temp			
Select	 @ZombiesKilled	 = ZombiesKilled				from #Temp		
Select   @Accuracy	     = Accuracy						from #Temp				
Select	 @DamageTaken	 = DamageTaken					from #Temp		
Select  @Deaths			 = Deaths						from #Temp			


EXEC [Freak_APITest2]  @LeaderboardName, @LeaderboardNameFull,@PlayerCount, @PlayerName, @Score,@ZombiesKilled,@Accuracy,@DamageTaken,@Deaths

Any help is greatly appreciated.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 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 8 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