Avatar of binaryman101
binaryman101Flag for United States of America

asked on 

Simple Export SQL 2005 View to a email CSV file

I have a SQL script that I would like to send the file in CSV instead of TXT  I have attached the following code.  Am asking it to do something that it can not do?
EXEC msdb.dbo.sp_send_dbmail
 
@profile_name = 'U4 Notifications.com'
,@recipients = 'test@test.com'
,@subject = 'Circuits missing a CLLI Code - Process Z4026 - "Garbage man cometh"'
,@attach_query_result_as_file = 1
-- can go to 32767 for query width
,@query_result_width = 32767
,@body_format = 'TEXT'
,@body = 'blah blah blah test message
 
'
,@append_query_error = 0
,@exclude_query_output = 0
,@query_no_truncate = 0
,@query = 'SELECT ANI = Left(ANI,12) FROM [Billing Automation Processes].dbo.[Z4026 - Circuits missing CO information]'

Open in new window

Microsoft SQL Server 2005

Avatar of undefined
Last Comment
binaryman101
Avatar of Marcjev
Marcjev
Flag of Belgium image

Directly simple answer... yes,
but, you can select a wide varchar line and make each line of the CSV yourselves.
Something like select convert(varchar(10),attrib1) + ',' + convert ... etc,
write it to a file and give it an explicit filename like @query_attachment_filename='fileout.csv'
Avatar of binaryman101
binaryman101
Flag of United States of America image

ASKER

I am a newbie to this, can you offer a little more step by step instructions?
ASKER CERTIFIED SOLUTION
Avatar of MonkeyPushButton
MonkeyPushButton
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of binaryman101
binaryman101
Flag of United States of America image

ASKER

Worked great!  Thanks.  
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo