question

muk avatar image
muk asked

insert line breaks into xml output of stored procedure

Hello SSC community, I am trying to insert line breaks into the XML output of this stored procedure: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[Populate_Emp_Directory] AS BEGIN declare @query nvarchar(max) set @query = N' select convert(varchar(max), (select( SELECT [J03_EMP_ID] as [ID] ,PERSON.FIRST_NAME ,PERSON.MIDDLE_NAME ,PERSON.LAST_NAME ,PERSON.LAST_NAME + ''_'' + PERSON.FIRST_NAME AS LAST_FIRST ,PERSON.NICKNAME ,[J03_JOB_TITLE] as [JOB_TITLE] ,[J03_OFFICE] as [OFFICE] ,[J03_TEL_EXT] as [EXT] ,[J03_DIR_DIAL] as [DIRECT_DIAL] ,[J03_ONLINE] as [DISPLAY_ONLINE_FLAG] ,[J03_DEPT_LONG] as [DEPARTMENT] ,[J03_BUILDING] as [BUILDING] ,[J03_SIGNATURE] as [SIGNATURE] ,PERSON.SOURCE FROM [coll18_test02].[dbo].[J03_EMP_DIR] left join PERSON on J03_EMP_DIR.J03_EMP_ID = PERSON.ID where PERSON.SOURCE IN (''FAC'',''STA'') AND (PERSON.PERSON_STATUS = ''A'' OR PERSON.PERSON_STATUS is null) order by LAST_FIRST FOR XML PATH, ELEMENTS XSINIL ))) as XMLforEmail' exec msdb.dbo.sp_send_dbmail --@recipients ='RSvea@jmls.edu', --@recipients ='jroth@jmls.edu', @ recipients='muk@jmls.edu', @query=@query, @execute_query_database='coll18_test02', @query_no_truncate=1, @exclude_query_output=1, @query_result_width=32767, @profile_name = 'test', @attach_query_result_as_file=1, @query_attachment_filename='directory.xml' END Can anyone help me?
sql-server-2008-r2sql-serverstored-procedures
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.