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

  • SEARCH
  • Home
  • 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 8463487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:28:05+00:00 2026-06-10T14:28:05+00:00

I have a table that contain memberId’s but they do not run concurrently. How

  • 0

I have a table that contain memberId’s but they do not run concurrently.

How must I loop through them?

I have this:

 select mm.memberid, mm.aspnetuserid, mm.email
 into #MemberIdsToDelete
   from membership.members as mm 
   left join aspnet_membership as asp
     on mm.aspnetuserid=asp.userid 
   left join trade.tradesmen as tr 
     on tr.memberid=mm.memberid  
   where asp.isapproved = 0 and tr.ImportDPN IS NOT NULL and tr.importDPN <> ''
   order by mm.memberid

 ALTER TABLE #MemberIdsToDelete ADD id int NOT NULL AUTO_INCREMENT

 DECLARE @MaxRownum int
 SET @MaxRownum = (SELECT MAX(id) FROM MemberIdsToDelete)

WHILE @Iter <= @MaxRownum
 -- do things
 SET @Iter = @Iter + 1
END  

The above is not correct, I get error on the alter table line obviously:
Incorrect syntax near ‘AUTO_INCREMENT’

  • 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-10T14:28:06+00:00Added an answer on June 10, 2026 at 2:28 pm

    You can use cursors to loop through table, something like this:

    DECLARE db_cursor CURSOR FOR SELECT Col1, Col2, -- your select query 
    
    OPEN db_cursor
    FETCH NEXT FROM db_cursor INTO @Var1, @Var2, -- list of your variables based on select query
    
    WHILE @@FETCH_STATUS = 0   
    BEGIN
    
        -- do stuff
    
        FETCH NEXT FROM db_cursor INTO @Var1, @Var2, -- list of your variables based on select query
    END   
    
    CLOSE db_cursor   
    DEALLOCATE db_cursor
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that has a couple of cells that do not contain
I have a table that contain one primary key. When I run EXPLAIN SELECT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have to develop a table that would contain distance between destinations and need
I have CMS table that contain CMS_STARTTIME and CMS_STOPTIME (attachment). alt text http://img339.imageshack.us/img339/755/exdatabase.jpg I
I have one table that contain more that 40 thousand record when I retrieve
I have seen apps that have table views that have rows that contain 2
I have one data warehouse table that contain one row for each item sold.
I have a table that contain about 60 columns and if i write a
I have a table that contain follow logic. The table display list of names

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.