Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

How To? -- DTS, Excel, Send Mail Task Expand / Collapse
Author
Message
Posted Tuesday, January 6, 2004 1:17 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, March 16, 2007 11:16 AM
Points: 11, Visits: 1

Not sure where to post my question, so I applolgize if this is in the wrong forum.

I have a DTS job that runs a sql query to join 3 tables to pull data needed for an excel spreadsheet and then on completion, the excel spreadsheet is emailed to a user.

My problem is that this runs multiple times a day and currently, the excel spreadsheet is just appended to.  I need it to NOT append but to create a new excel spreadsheet.  If I manually remove the excel spreadsheet, then DTS fails indicating that a temp table(created by DTS for the excel spreadsheet) does not exist.

How do I create the spreadsheet from scratch each time the DTS is executed?

Jeff




Post #93756
Posted Tuesday, January 6, 2004 3:12 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, October 1, 2014 11:29 PM
Points: 1,084, Visits: 59
There are more than one way to skin a cat.  One solution in this case is to use ActiveX, open the Excel spreadsheet and remove all the data at the beginning of the DTS.


Joseph
Post #93777
Posted Wednesday, January 7, 2004 1:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2007 7:17 AM
Points: 4, Visits: 2
Create your Excel workbook, format as required, then delete any data rows in it, then store a copy somewhere the DTS can access. Have an ActiveX delete the existing workbook, copy the new empty workbook to the same location then run the DTS task to transfer your data to the new empty workbook. Data goes in and adopts all the formatting applied to the original data...


Post #93816
Posted Wednesday, January 7, 2004 3:49 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:49 AM
Points: 292, Visits: 661
I skin my cat this way - I create a sql task who's connection is the spreadsheet and drop the table and recreate it. eg. drop table err_screwup go create table 'err_screwup' ('user' varchar(30), 'err' decimal (28,8)). Works a treat.


Post #93832
Posted Wednesday, January 7, 2004 11:18 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, May 5, 2005 5:37 AM
Points: 344, Visits: 1
Could you give me some more detail on how you do this, wildh? I am currently doing the ActiveX script to copy an empty template over the end excel file, but if I could simplify the process, I would certainly like to!


Post #93958
Posted Thursday, January 8, 2004 1:37 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:49 AM
Points: 292, Visits: 661
In excel
Create a spreadsheet called screwup.xls

In MMC
Create a SQL server connection
Create a spreadsheet connection (who’s filename is the screwup.xls file)
Create the Transform data task, in the source type “select 'user1' as [username], '1000' as err” in the SQL query. In destination click “create and change table name to “screwup”. Note. copy out the statement you will need it later it may look like CREATE TABLE `screwup` (`username` VarChar (5) , `err` VarChar (4) )

Execute the Transform data task twice and open the spreadsheet. You will see two records.

Create a SQL task who’s existing connection is the excel spreadsheet. Remember, the sheet “screwup” is treated like a table so you must drop it and re- create it, so type in “drop table screwup go” and now paste your create table syntax. Truncate table won’t work.
Create an on completion/ success precedence from the SQL task to the SQL server connection.

Run the package again and open the spreadsheet, there should be only one record.

Hope this is the kind of thing you’re looking for and that my guide is straightforward.



Post #94038
Posted Thursday, January 8, 2004 8:42 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, March 16, 2007 11:16 AM
Points: 11, Visits: 1
That works like a charm!  Simple and straight-forward.  Thanks for the help.


Post #94105
Posted Wednesday, March 31, 2004 8:15 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, October 3, 2012 8:35 AM
Points: 242, Visits: 1,242

Create a SQL task who’s existing connection is the excel spreadsheet. Remember, the sheet “screwup” is treated like a table so you must drop it and re- create it, so type in “drop table screwup go” and now paste your create table syntax

I tried the above suggestion of wildh and get an error on the drop table:

"Cannot drop table 'Screwup', because it does not exist in the system catalog"

The Excel file was created with the 2 records as described.  What am I missing?

Terri

tsanta@lsuhsc.edu





Terri

To speak algebraically, Mr. M. is execrable, but Mr. C. is
(x+1)-ecrable.
Edgar Allan Poe
[Discussing fellow writers Cornelius Mathews and William Ellery Channing.]
Post #109269
Posted Wednesday, March 31, 2004 9:54 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, October 3, 2012 8:35 AM
Points: 242, Visits: 1,242

Never mind, the SQL task had the wrong connection.  It works now, if the Excel file exists.  Is there a way to check if the file exists before dropping it?  I tried : IF NOT (OBJECT_ID('Screwup') IS NULL) DROP TABLE Screwup

but I get an error.  Where can I find the syntax I can use here?





Terri

To speak algebraically, Mr. M. is execrable, but Mr. C. is
(x+1)-ecrable.
Edgar Allan Poe
[Discussing fellow writers Cornelius Mathews and William Ellery Channing.]
Post #109303
Posted Thursday, June 10, 2004 7:21 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:49 AM
Points: 292, Visits: 661
tsanta, sorry for any delay!! have a browse and replace the print statement with other syntax.

http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=114315#bm116592

Hop it points you in the right direction.



Post #120329
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse