Results 1 to 3 of 3

Thread: calling stored procedure inside while loop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    83

    calling stored procedure inside while loop

    Hi,

    I noticed that in Sql server 2000 it is not possible to call a stored procedure
    inside the while loop. I have a while loop similar to the following inside a stored procedure which in turn calls a stored procedure. However an error is thrown.

    while (intNumber < 10)
    Begin
    Exec someStoredProcedure
    intNumber = intNumber + 1
    End

    thanks in advance

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: calling stored procedure inside while loop

    I noticed that in Sql server 2000 it is not possible to call a stored procedure inside the while loop.
    It certainly is possible.

    However an error is thrown.
    Post the error information.

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: calling stored procedure inside while loop

    That is not real T-SQL code - it would be more like this:

    Code:
    declare @intnumber int
    set @intnumber=0
    while (@intNumber < 10)
    Begin
    Exec someStoredProcedure
    set @intNumber = @intNumber + 1
    End
    If what you posted was not real code - please post the real code.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width