Home Forums SQL Server 7,2000 T-SQL INSERT into Excel leaves values as text RE: INSERT into Excel leaves values as text

  • Hi smv

    I'm using linked spreadsheets and doing updates, but the principle is probably the same - use a template spreadsheet and ensure that the columns you want numeric, are formatted as the correct numeric type. Provided that the first 8 values in a column are numeric, the driver will continue to write numeric values in the rest. I've got sp's for a) copying/renaming template to target directory and b) linking to a spreadsheet$worksheet, and sample code for doing updates - will post if you wish. It's been used for data migrations and will require tweaking and tidying up if you're working in a production environment.

    Incidentally, using this method allows you to mimic a VLOOKUP with considerably more flexibility than Excel offers, e.g. UPDATE FROM with a JOINed source.

    Cheers

    ChrisM

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden