Tikoetikoe
Tikoetikoe

Reputation: 13

SQL Server, Calling stored procedure per column with specific field value

I have a table BounceStatistics with the columns: Email_Address,Bounces,Status,Week,Year

i have a stored procedure named GetStatus with the following parametersEmail_address,Week,Year. The procedure fills the status column of the BounceStatistics table collected out of another set of tables.

My Question: How do i run the stored procedure for each record in BounceStatistics where the value is currently null? (i read that i should avoid loops but i think its the only way)

I would love to learn better practises as well, so any tips on what i should do in the future instead of what i show right now would be welcome.

Upvotes: 0

Views: 143

Answers (1)

Gidil
Gidil

Reputation: 4137

It looks like the SP was written specifically to update (or insert?) a single row.
This in itself is problematic.

Think about rewriting it as a function and calling it as part of an UPDATE statement.

And yes, loops should be avoided (and usual can be avoided) ;-)

Upvotes: 1

Related Questions