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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:17:47+00:00 2026-06-10T18:17:47+00:00

I have an SQL procedure that calls the command shell to write an SQL

  • 0

I have an SQL procedure that calls the command shell to write an SQL dump to a file. Take this redacted file for example:

VALUES(
  @SomeVar
  ,1
)

The procedure calls:

echo VALUES(>> C:\somefile.sql
echo @SomeVar>> C:\somefile.sql
echo ,1>> C:\somefile.sql
echo )>> C:\somefile.sql

This works fine, except for the ,1 line. If you run echo ,1>> C:\somefile.sql in CMD, you will see that C:\somefile.sql only contains ,

My theory is that echo thinks it can accept more than 1 parameter.

If you modify the command to echo ,1blah>> C:\somefile.sql, it works perfectly.

I could modify my procedure to check if the line contains a , followed by a number, not followed by anything, and prepend ^ to the number to escape it. This is a bit of a pain though.

Also, echo 1>> C:\somefile.sql writes Echo is ON

Is there a way to echo a literal string in CMD? Enclosing the string in " " outputs the " marks. Or is there any other solution you can think of?

  • 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-10T18:17:49+00:00Added an answer on June 10, 2026 at 6:17 pm

    The problem is that 1 is the file descriptor for the standard output stream in batch files / CMD.EXE. You can work around this by using this line instead:

    echo ,1 1>> C:\somefile.sql
    

    Or, but more fragile, just put a space between the 1 and the >> redirection

    echo ,1 >> C:\Somefile.sql
    

    Update: If you are really concerned about the trailing whitespace for the above examples, you could also use

    >> C:\Somefile.sql echo ,1
    

    I.e. you can also put the redirection in front of the command. Personally, I think it looks a little awkward, but YMMV.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL procedure that generates a util file as its output depending
I have written a SQL Server stored procedure that includes a DateTime parameter. This
I have a line in my SQL Stored Procedure that looks like this (works
I have a stored procedure that has this line: SET @SQL = 'SELECT path,title,tags
Need to have a stored procedure that calls a SQL Server Agent Job and
I have a PHP webpage that calls a MS SQL 2005 Stored Procedure on
I have a SQL Server stored procedure that is not returning any data when
I have an SQL CREATE PROCEDURE statement that runs perfectly in my local SQL
I have a stored procedure that runs custom backups for around 60 SQL servers
On our SQL Server (Version 10.0.1600), I have a stored procedure that I wrote.

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.