Guest User

Untitled

a guest
Aug 15th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.05 KB | None | 0 0
  1. USE [SDS_DevSchoolDistrict]
  2. GO
  3. -- =============================================
  4. -- Author:      School Data Solutions
  5. -- Create date: <Create Date, ,>
  6. -- Description: <Description, ,>
  7. -- Copyright 2011-2012 School Data Solutions, All Rights Reserved
  8. -- =============================================
  9. CREATE FUNCTION [dbo].[WidgetDataForStudentLearningPlanForPrintAsXml]
  10. (
  11.         @EntityId int,
  12.         @SchoolYearId int = NULL,
  13.         @IncludeHeader  bit = 1,
  14.         @DataViewMode varchar(200) = 'Standard',
  15.         @EncryptIds bit = 0,
  16.         @ApplicationUserId int,
  17.         @ApplicationUserPersonRoleId int
  18. )
  19. RETURNS Xml
  20. AS
  21. BEGIN
  22.         /*---------------------------------------------
  23.         DECLARE @EntityId int = 38515
  24.         DECLARE @DataViewMode varchar(200) = 'Standard'
  25.         DECLARE @EncryptIds bit = 0
  26.         DECLARE @IncludeHeader bit = 1
  27.         DECLARE @ApplicationUserId int = 357
  28.         DECLARE @ApplicationUserPersonRoleId int = 1
  29.         -- SELECT dbo.WidgetDataForStudentLearningPlanForPrintAsXml(34261, 12, 1, DEFAULT, DEFAULT, 357, 1)
  30.         ---------------------------------------------*/
  31.  
  32.  
  33.         ---------------------------------------------
  34.         -- Declare the return variable here
  35.         -- Prepare for performance metrics
  36.         ---------------------------------------------
  37.         DECLARE @StartTime time = CAST(GETDATE() as time)
  38.         DECLARE @Xml XML = '<Xml xmlAssemblyTimeInMilliseconds=""></Xml>'
  39.         ---------------------------------------------
  40.  
  41.  
  42.  
  43.  
  44.         ---------------------------------------------
  45.         DECLARE @Entity Xml
  46.         ---------------------------------------------
  47.         IF(@IncludeHeader = 1)
  48.         BEGIN
  49.                 DECLARE @PersonRoleId int
  50.                 ---------------------------------------------
  51.                 SELECT  @PersonRoleId = PersonRoleId
  52.                 FROM    PersonRoles PR
  53.                 WHERE   PR.PersonRole LIKE '%Student%'
  54.                 ---------------------------------------------
  55.                 SET @Entity = dbo.WidgetDataForEntityProfileAsXml(@EntityId, @PersonRoleId, @SchoolYearId, @DataViewMode, @EncryptIds, @ApplicationUserId, @ApplicationUserPersonRoleId)
  56.         END
  57.         ---------------------------------------------
  58.         --SELECT @Entity AS '@Entity'
  59.         ---------------------------------------------
  60.  
  61.  
  62.         IF(@SchoolYearId IS NULL) SET @SchoolYearId = dbo.SchoolYearIdValue(getDate())
  63.  
  64.  
  65.         ---------------------------------------------
  66.         -- Assemble output Xml
  67.         ---------------------------------------------
  68.         SET @Xml = dbo.WidgetDataForStudentLearningPlanAsXml(@EntityId, @SchoolYearId, @DataViewMode, @EncryptIds, @ApplicationUserId, @ApplicationUserPersonRoleId)
  69.         SET @Xml = dbo.XmlAdopt(@Xml, @Entity, 'Xml', 'Entity')
  70.         ---------------------------------------------
  71.  
  72.  
  73. ALLDONE:
  74.  
  75.         ---------------------------------------------
  76.         -- Track Assembly time
  77.         ---------------------------------------------
  78.         DECLARE @XmlAssemblyTimeInMilliseconds int = DATEDIFF(ms, @StartTime,  CAST(GETDATE() as time))
  79.         SET @Xml = dbo.XmlAssignAttributeValues(@Xml, '//Xml', 'xmlAssemblyTimeInMilliseconds', @XmlAssemblyTimeInMilliseconds)
  80.         ---------------------------------------------
  81.  
  82.  
  83.         --SELECT @Xml AS '@Xml'
  84.         ---------------------------------------------
  85.         RETURN @Xml
  86. END
Add Comment
Please, Sign In to add comment