December 9, 2009 at 11:32 am
I have a table with a column for comments. VARCHAR(1000). When executing a query in QA and results to text option I get this field 1000 characters wide. When this is used, SUBSTRING(COMMENTS, 1, 4) al is good but, when I use this SUBSTRING(COMMENTS, 1, LEN(COMMENTS)) and the length is 4 I get the full length of the field. is there any type of formating that can be done to fix this? My ultimate goal is to have this query be sent my xp_sendmail.
Thanks
Jim
December 9, 2009 at 11:12 pm
SUBSTRING(COMMENTS, 1, LEN(COMMENTS)) will always return the full length of the field. Look at it... you need to do something else.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 10, 2009 at 2:56 pm
Will this not work?
SELECT RTRIM(COMMENTS) FROM <table_name>
Joie Andrew
"Since 1982"
December 10, 2009 at 3:03 pm
An update. I am using XP_SENDMAIL with @QUERY. The results for @QUERY can be sent as an attachment or in the message of the email. In either case the results are formated with the columns length set to the field description ie VARCHAR(1000). So a better question is can the results from @QUERY be formated with XP_SENDMAIL?
Thanks
Jim
December 10, 2009 at 3:16 pm
Have you tested it? If you run the query statement that is being assigned to @query in management studio and have the output written to a file that would probably give you a good idea of what it would look like as an attachment when being sent with xp_sendmail. What happens when you try using xp_sendmail to send the e-mail to yourself?
Joie Andrew
"Since 1982"
December 10, 2009 at 3:50 pm
The RTRIM(COMMENTS) does not give me the correct results. The 'header line' that is generated by 'results to file' option is 1000 characters. But I have found a solution with using Crystal Reports and our main application.
Thanks for the asist.
Jim
December 10, 2009 at 3:56 pm
Ah... now I see what you're trying to do.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply