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 7738163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:11:39+00:00 2026-06-01T08:11:39+00:00

I am using Microsoft Windows XP [Version 5.1.2600] Trying to do this. Trying to

  • 0

I am using Microsoft Windows XP [Version 5.1.2600]

Trying to do this.

Trying to create the variable dynamically and then read the value out of that variable in a loop.

@ECHO off

SET SQL1=TEST
SET SQL2=TEST1
SET SQL3=TEST2
SET SQL=SQL
SETLOCAL ENABLEDELAYEDEXPANSION

SET /A number=0

FOR /l %%A IN (1,1,3) DO (

SET /A number = number + 1
echo !number!
    echo %SQL%!number!

)
endlocal

Output should be 
 1
 test
 2
 test2
 3
 test3
I am getting 
 C:\temp>c.bat
  1
  SQL1
  2
  SQL2
  3
  SQL3

Please help!

  • 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-01T08:11:40+00:00Added an answer on June 1, 2026 at 8:11 am

    Ugh.

    First way (note that instead of your number variable, it uses the loop counter variable %%A):

    @ECHO off
    
    SET SQL1=TEST
    SET SQL2=TEST1
    SET SQL3=TEST2
    
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    SET /A number=0
    
    FOR /l %%A IN (1,1,3) DO (
    
    SET /A number = number + 1
    echo !number!
    echo !SQL%%A!
    
    )
    endlocal
    

    Second way (ugly but it does what you want):

    @ECHO off
    
    SET SQL1=TEST
    SET SQL2=TEST1
    SET SQL3=TEST2
    
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    SET /A number=0
    
    FOR /l %%A IN (1,1,3) DO (
    
    SET /A number = number + 1
    echo !number!
    for %%i in (!number!) do (echo !SQL%%i!)
    
    )
    endlocal
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an application that runs on a Windows Mobile device. I'm using Microsoft's
I am using Microsoft Lync 2010 version 4 running on Windows 7. It is
string registryKey = @SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall; using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryKey)) { (from a in key.GetSubKeyNames()
My application (Microsoft Windows only) is using a wxToolBar with wxTB_HORIZONTAL|wxTB_TEXT|wxTB_HORZ_LAYOUT flags set. All
How to connect to a Microsoft Access-based database in a Windows using JDBC code?
using Microsoft.SqlServer.Management.SqlStudio.Explorer; unable to find this pls assist [update] found the dll's in this
Using Microsoft Visual Studio 2010: Can I write this type of macro in C?
Using Microsoft SQL server 2008 I have a query that is in need of
I'm using Microsoft Visual C# 2008 Express. In my main form, there's that X
i am trying to read an excel file using java. while compiling the program

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.