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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:23:35+00:00 2026-05-31T00:23:35+00:00

Perhaps someone could provide some insight into a problem I have. I have a

  • 0

Perhaps someone could provide some insight into a problem I have.

I have a SQL Server database which receives information every hour and is updated from a stored procedure using a Bulk Insert. This all works fine, however the end result is to pull this information into Excel.

Establishing the data connection worked fine as well, until I attempted some calculations. The imported data is all formatted as text. Excel’s number formats aren’t working so I decided looking at the table in the database.

All the columns are set to varchar for the Bulk Insert to work so I changed a few to numeric. Refreshed in Excel and the calculations worked.

After repeat attempts I’ve not been able to get the Bulk Insert to work, even generating a format file with bcp it still returned errors on the insert. Could not convert varchar to numerical, after some further searching it was only failing on one numerical column which is generally empty.

Other than importing the data with VBA and converting it like that or adding zero to every imported value so Excel converts it.

Any suggestions are welcome.

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-31T00:23:36+00:00Added an answer on May 31, 2026 at 12:23 am

    Thanks for the replies I had considered using =value() in Excel but wanted to try avoid the additional formulas.

    I was eventually able to resolve my problem by generating a format file for the Bulk Insert using the bcp utility. Though getting it to generte a file proved tricky enough below is an example of how I generated it.

    At an elevated cmd:

    C:\>bcp databasename.dbo.tablename format nul -c -x -f outputformatfile.xml -t, -S localhost\SQLINSTANCE -T
    

    This generated an xml format file for the specific table. As my table had two additional columns which weren’t in the source data I edited the XML and removed them. They were uniqueid and getdate columns.

    Then I changed the Bulk Insert statement so it used the format file:

    BULK INSERT [database].[dbo].[tablename]
    FROM 'C:\bulkinsertdata.txt'
    WITH (FORMATFILE='C:\outputformatfile.xml',FIRSTROW=3)
    

    Using this method I was able to use the numeric and int datatypes successfully. Going back to Excel when the data connection was refreshed it was able to determine the correct datatypes.

    Hope that helps someone!

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

Sidebar

Related Questions

I have a pretty simple question which perhaps someone familiar with Server/Client design &
Hi wondering if perhaps someone could shed some light on the below error. The
This has always bugged me. Perhaps someone with some hardcore knowledge of .NET internals
Heads starting to hurt. I think I dropped into this too fast... Perhaps someone
I think I may have a misunderstanding of <xsl:variable\> and <xsl:value-of\> so perhaps someone
Only got rough idea of what I want, perhaps someone could pad it out
Perhaps someone can point me in the correct direction, because I'm completely stumped on
Perhaps someone can help me out with this one: I'm using a basic search
An odd error here, perhaps someone can help track down source as it's attempting
I'm not sure what this practice is actually called, so perhaps someone can edit

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.