Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:48:53+00:00 2026-06-05T12:48:53+00:00

I have a table that has list of stored procedures. I am using a

  • 0

I have a table that has list of stored procedures.

I am using a cursor to then loop through and call and capture the result of each stored procedure (they all return 0 or 1).

So I have:

DECLARE @PROC_ID INT,
        @PROC_NAME VARCHAR(50)

SELECT *
INTO #MY_PROCS
FROM TABLE_PROCS

DECLARE MY_CURSOR CURSOR FOR
SELECT PROC_ID, PROC_NAME
FROM TABLE_PROCS

OPEN MY_CURSOR
FETCH NEXT FROM MY_CURSOR INTO @PROC_ID, @PROC_NAME

WHILE @@FETCH_STATUS = 0
BEGIN
  SELECT @PROC_RESULT = .......

  UPDATE #MY_PROCS SET PROC_RESULT = @PROC_RESULT WHERE PROC_ID = @PROC_ID
END

CLOSE MY_CURSOR
DEALLOCATE MY_CURSOR

DROP TABLE #MY_PROCS

I was reading on cursors, and read I should be setting it as READ ONLY and NO LOCK if possible.

Also, should I be using a table variable instead of a temp table?

Is it possible to do this w/o a cursor?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:48:54+00:00Added an answer on June 5, 2026 at 12:48 pm

    The most efficient cursor is going to be, at least in all of my testing:

    DECLARE MY_CURSOR CURSOR 
      LOCAL STATIC READ_ONLY FORWARD_ONLY
    FOR ...
    

    Now, it’s impossible for us to know if you can do this without a cursor. You’ve conveniently left out the only information we could have used to tell you that. It seems you are calling a procedure for each call, but you can’t be doing that with SELECT. And then you update a table with the result, but you drop the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table (volunteers_2009) that has all the volunteers stored within, then I
I have a table articles that has a column company which has list of
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I have a table that has three different date columns, so I set each
I have one table that has sales records and another table that has additional
I have a table that has records with a structure similar to this.. ID
i have a table that has event name and event date. if i want
I have a table that has a certain numeric column called Score . I
I have a table that has two columns: CommunityID PersonID And A People table
I have a table that has a column that has the cost of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.