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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:56:10+00:00 2026-05-24T18:56:10+00:00

I am exporting an mssql query to an excel file which has the first

  • 0

I am exporting an mssql query to an excel file which has the first two rows as a header. The first row (title) is one cell that spans from A1:K1. The second row (header) has 11 cells and spans from A2:K2. I would like to have an openrowset to change the title and a second openrowset to populate the excel file.

This doesn’t work:

    EXEC('INSERT INTO OPENROWSET(''' + @provider + ''',''' + @ExcelString + ''',''SELECT Top 1 * FROM [Sheet1$]'') 
SELECT Top 1 [Customer] FROM [ORDER SUMMERY] WHERE [Order #] = ''' + @OrderNumber + ''' AND (Status = ''C'' OR Status = ''I'')')

This is the second part and it does work:

    EXEC('INSERT INTO OPENROWSET(''' + @provider + ''',''' + @ExcelString + ''',''SELECT * FROM [Sheet1$A3:K3]'') 
SELECT [ITEMNUMBER],[CustomerSKU],[ITEM_DESCRIPTION],[CASEPACK],[Total Qty],[Case Price],[CASEPACK]*[Total Qty],[Total Qty]*[Case Price],[Unit Price],[PreTicketInfo],[Quote #] FROM [ORDER SUMMERY] WHERE [Order #] = ''' + @OrderNumber + ''' AND (Status = ''C'' OR Status = ''I'')')

Thanks!

  • 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-05-24T18:56:11+00:00Added an answer on May 24, 2026 at 6:56 pm
    EXEC('INSERT INTO OPENROWSET(''' + @provider + ''',''' + @ExcelString + ''',''SELECT Top 1 * FROM [Sheet1$A1]'')  
    SELECT Top 1 [Customer] FROM [ORDER SUMMERY] WHERE [Order #] = ''' + @OrderNumber + ''' AND (Status = ''C'' OR Status = ''I'')')
    

    Try this. Excel holds the value of merged cells in the top left of the merged cell range, so a merged spell spanning A1:K1 would be programmatically referred to as cell A1 when pulling value data

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

Sidebar

Related Questions

Exporting select query data from mysql to csv & opening with excel, the leading
I am exporting from one table and importing to another table. First i import
I have a script for exporting results of a mysql query as a csv
Exporting some data from mysql to a csv file using FasterCSV. I'd like the
When exporting a Visual Studio project to a Template (File/Export Template...) I get the
I'm exporting data programatically from Excel to SQL Server 2005 using SqlBulkCopy. It works
I am programmatically exporting data (using PHP 5.2) into a .csv test file. Example
I am exporting a datatable to an excel sheet successfully... In that excel sheet
I am exporting datatable in MSEXCEL.I need to Assign MultipleLines in a cell in
I'm having a bit of trouble exporting a csv file that is created from

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.