Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loop for several values
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01327001
Message ID:
01327007
Views:
12
Actually, I like your solution more than mine, because I can use it with select :)

>>Hi everybody,
>>
>>Suppose I have several PersonIDs I'd like to test my SP with. How can I create a loop to do it?
>>
>>Thanks in advance, though I do have an idea myself.
>
>
>DECLARE @Test TABLE (PersonId int /*or whatever*/, ID Int IDENTITY(1,1))
>INSERT INTO @Test (PersonId) VALUES (??)
>INSERT INTO @Test (PersonId) VALUES (??)
>INSERT INTO @Test (PersonId) VALUES (??)
>INSERT INTO @Test (PersonId) VALUES (??)
>INSERT INTO @Test (PersonId) VALUES (??)
>INSERT INTO @Test (PersonId) VALUES (??)
>
>DECLARE @PersonId      int -- or whatever
>DECLARE @id_min        int
>DECLARE @id_max        int
>SET @id_min = 1
>SELECT @id_max = MIN(Id) FROM @Test
>
>WHILE @id_min <= @id_max
>      BEGIN
>         SELECT @PersonId = PersonId FROM @Test WHERE Id = @id_min
>         --- Test your SP here
>         SET  @id_min =  @id_min + 1
>      END
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform