Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

Can DatabaseMail attach a formatted Excel file? Expand / Collapse
Author
Message
Posted Tuesday, January 10, 2012 4:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 15, 2015 10:50 AM
Points: 4, Visits: 226
Thanks, Ted!
Post #1233625
Posted Friday, August 3, 2012 8:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, January 20, 2015 3:39 AM
Points: 92, Visits: 395
Hi, would it be possible to post the full script you got working please. Thank you.
Post #1339876
Posted Wednesday, June 25, 2014 9:05 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 3:22 PM
Points: 11, Visits: 69
I'd like to see the script too. Trying to get a tab delimiter to work. the char(9) doesn't work
Post #1585953
Posted Monday, November 30, 2015 4:05 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, April 4, 2016 12:54 AM
Points: 235, Visits: 937
Thanks a lot. it worked for me also.

But still i am getting ------ one complete row after the header columns

Post #1741110
Posted Tuesday, December 1, 2015 12:21 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, December 1, 2015 12:15 PM
Points: 54, Visits: 145
Lavanyasri (11/30/2015)
Thanks a lot. it worked for me also.

But still i am getting ------ one complete row after the header columns



I started this thread years ago - brings back memories hehe

Funny, I just updated a query to fix this very issue you mentioned.

Step 1: Prepare a table with your data AND a single row that will become your column headings (using UNION ALL), as follows:

create table temptbl(ACCOUNT VARCHAR(15),FACILITY VARCHAR(255),SORTORDER INT)
insert into temptbl(account,facility,sortorder)
SELECT 'ACCOUNT','FACILITY',0 -- these will be your column headings
UNION ALL
SELECT
ACCOUNT,
FACILITY,
1 -- these are your rows of data with a sort order of 1 to make sure they are situated below your column headings
FROM someothertbl

Then in your database mail code, remove the automatic headings, because those come with the annoying dashes row that you're wanting to get rid of and populate your file making sure its sorted by SORTORDER:

    @profile_name = 'YOURPROFILE',
@recipients = 'YOUR EMAIL ADDRESSES',
@subject = 'SUBJECT',
@query = 'set nocount on;SELECT account,facility FROM TEMPTBL order by sortorder',
@attach_query_result_as_file = 1,
@query_result_separator = ' ' ,
@query_result_no_padding = 1,
@query_result_header =0,
@query_attachment_filename = 'BOOK1.csv'

Hope this helps.
Post #1741712
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse