• subscribe
September 19, 2001 12:00 AM

Truncating Data

SQL Server Pro
InstantDoc ID #21896
Downloads
21896.zip

I built a Data Transformation Services (DTS) package that exports data from a SQL Server 7.0 table to a Microsoft Excel spreadsheet. The package's first run works fine, but subsequent runs just append the data to the spreadsheet instead of replacing the data in the spreadsheet. How can I avoid this problem?

I suspect that you want to execute a TRUNCATE statement, then create new inserts. You can accomplish these steps easily in two ways: Use Excel's automation model to empty the spreadsheet, or superimpose a blank copy of the Excel spreadsheet on top of the populated spreadsheet by using a small script such as the example that Listing 1 shows.



ARTICLE TOOLS

Comments
  • David Wood
    10 years ago
    Jan 03, 2002

    I use a DROP TABLE `results` (Execute SQL Task) as the first step of the DTS package (where "results" is the name of the sheet that contains the data in the excel spreadsheet). Make sure you set it to the Excel file connection (in my case, connection 2).

You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...