Solved

Set param - dynamic- better way to write what I have

Posted on 2012-03-20
3
276 Views
Last Modified: 2012-03-20
Is there a more "elegant" way to write the below - perhaps some simple loop to make it more "dynamic" so I dont have to iterate through every number - say up to 10000, etc.?

DECLARE @startIndex int, @pageSize int
SET @startIndex = 2

SET @startIndex =
CASE
WHEN @startIndex = 1 THEN 0
WHEN @startIndex = 2 THEN 1000
WHEN @startIndex = 3 THEN 2000
WHEN @startIndex = 4 THEN 3000
WHEN @startIndex = 5 THEN 4000
WHEN @startIndex = 6 THEN 5000
WHEN @startIndex = 7 THEN 6000
WHEN @startIndex = 8 THEN 7000
END
0
Comment
Question by:tbaseflug
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 37743034
doesn't this work:

SET @startIndex = 1000 * (@startIndex - 1)

Open in new window

0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 37743040
SET @startIndex = (@startIndex - 1) * 1000
0
 

Author Closing Comment

by:tbaseflug
ID: 37743053
It sure does... Whoops...  Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Job Hung 17 37
MS Access Pasthru Query to Execute SQL Stored procedure 8 45
Trouble installing msi file with msiexe.exe 2 20
A question about syntax 5 29
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question