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

  • Home
  • SEARCH
  • 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 7760673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:57:06+00:00 2026-06-01T13:57:06+00:00

I have a query that is more complicated, but basically creates an HTML page

  • 0

I have a query that is more complicated, but basically creates an HTML page for me.

DECLARE @indSubject varchar(7)
SET @indSubject = '61-0036'

--  LOTS of query stuff here that makes a page.  For simplicity 
--  just use this:

SELECT '<html><body>' + @indSubject + '</body></html>'

I want to do two things:

  1. Have SQL Server save this on my machine somewhere with the name of
    @indSubject.html (e.g. C:\TEMP\HTMLOUTPUT\61-0036.html)
  2. Be able to pass different values to the @indSubject (e.g. 91-0003).
    Something command line-ish ?

Can I do this with BCP? Some other way ?

Please note, this is all my personal stuff and this is not being deployed on a web server so I don’t have to really worry to much about security, SQL Injection etc (at least I hope I don’t!)

  • 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-01T13:57:07+00:00Added an answer on June 1, 2026 at 1:57 pm

    You can use SQLCMD to accomplish this fairly easily.

    If you save your existing query as a .sql file, you can execute this using SQLCMD.

    Additionally, SQLCMD will let you specify a variable inside of your .sql file ${indSubject} which you could then provide from the command line.

    Finally, using the -o switch, you can output the results directly to a file, and you can suppress the headers on your result set using the following environment setting:

    :SETVAR SQLCMDHEADERS -1

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

Sidebar

Related Questions

I have a Linq-to-Entities query that is not complicated but requires an .include and/or
I have a complicated SELECT query that filters on a time range, and I
I have been thinking about a complicated view/query I need to create but I
I was wondering if you guys could help with a complicated query. I have
I'm trying to redirect requests that have a query string to a different domain
I have this rather complex query that grabs data from three tables, and now
I have an sql query (MyQSL DB, using .Net's SqlClient) that returns a dataset.
I have a table, Foo. I run a query on Foo to get the
I have a regex expression that traverses a string and pulls out 40 values,
I'm sending a post request to a php file that makes an MySQL query

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.