traspose columns dynamically

  • Hello

    I have a table that has a numeric primary key and other columns like personName, assignedgnedDate, status, description.

    The logic of this table is like this: a record with a generated primary key shows the status of a person with a given name on certain date. A person can have different stauses with different concepts. The number of records by person is not fixed but it will be less than 20. I need to show something like a workflow where I will have a single record by person but that will show each status, assignedDate and other columns.

    (columns of table: ID, name, assignedDate, status, description)

    I've read about dynamic queries and pivot tables but I see that pivot tables imply aggregation functions.

    how can I accomplish the task?

    regards

    edotom

  • This is easier to do at the client level.

    Send the data order by Client, date

    while not rs.eof

    while client didn't change, addcolumns

    change row

    wend

  • cross tabs works well for this, especially if you can only have one status/concept pair for a given date and user.

    Something like this (can't be more clear without table definitions and data):

    SELECT

    [name],

    assignedDate,

    MAX(CASE WHEN status = 'Status1' THEN description ELSE null END) AS 'Status1',

    MAX(CASE WHEN status = 'Status2' THEN description ELSE null END) AS 'Status3',

    MAX(CASE WHEN status = 'Status3' THEN description ELSE null END) AS 'Status2'

    FROM [Table]

    GROUP BY [name], assignedDate

    Now, if your number of statuses is dynamic, then you'll have to build this query as a dynamic version, by looping through your list of statuses and appending them accordingly. But otherwise this should work.

  • Thanks!!

    I'll try that

  • I made myself a mess. I'm pasting table structure plus some records. Please notice that the key field is userCode. In many cases it has more than 10 records. The objective is to group by userCode and have as many columns as responsible and statuses are accompanied with their related approvalDate.

    kindly advice

    edotom

    /****** Object: Table [dbo].[tmpReport] Script Date: 08/02/2011 13:59:39 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[tmpReport](

    [userCode] [varchar](15) NOT NULL,

    [varchar](4) NOT NULL,

    [responsible] [varchar](15) NOT NULL,

    [typeResponsible] [varchar](5) NOT NULL,

    [status] [varchar](3) NOT NULL,

    [createDate] [datetime] NULL,

    [assignmentDate] [datetime] NULL,

    [approvalDate] [datetime] NULL,

    [updateUser] [varchar](50) NULL,

    [grade] [varchar](8) NULL,

    [changeDate] [datetime] NULL

    ) ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    GO

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'12207004', N'GERE', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'12212202', N'TESOR', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), CAST(0x00009EF500A13047 AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'12213330', N'GERE', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'16238591', N'GERE', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'fedegest', N'GERE', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005861', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF500A09EDC AS DateTime), CAST(0x00009EF500A09F10 AS DateTime), CAST(0x00009EF500A13047 AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), NULL, NULL, N'ddimarco', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), CAST(0x00009EF500A62223 AS DateTime), CAST(0x00009EF500B3F681 AS DateTime), N'12212202', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), NULL, NULL, N'ddimarco', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), NULL, NULL, N'ddimarco', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), NULL, NULL, N'ddimarco', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), CAST(0x00009EF500A2A343 AS DateTime), CAST(0x00009EF500A62223 AS DateTime), N'18896332', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005862', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500A2A301 AS DateTime), NULL, NULL, N'ddimarco', N'00314705', CAST(0x00009EF500E858DC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'12207004', N'GERE', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), NULL, NULL, N'12210153', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'12212202', N'TESOR', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), CAST(0x00009EF500D0B7D4 AS DateTime), CAST(0x00009EF500F5AB2F AS DateTime), N'12212202', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'12213330', N'GERE', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), NULL, NULL, N'12210153', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'16238591', N'GERE', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), NULL, NULL, N'12210153', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'fedegest', N'GERE', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), NULL, NULL, N'12210153', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'javlosi', N'GERE', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), NULL, NULL, N'12210153', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005863', N'4445', N'javlosi', N'GERE', N'RGZ', CAST(0x00009EF500B8FAF7 AS DateTime), CAST(0x00009EF500B8FB2A AS DateTime), CAST(0x00009EF500D0B7D4 AS DateTime), N'javlosi', N'00314762', CAST(0x00009EF50133B570 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'12207004', N'GERE', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), NULL, NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'12212202', N'TESOR', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), CAST(0x00009EF500D0EE03 AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'12213330', N'GERE', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), NULL, NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'16238591', N'GERE', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), NULL, NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'fedegest', N'GERE', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), NULL, NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'javlosi', N'GERE', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), NULL, NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005864', N'4445', N'javlosi', N'GERE', N'PRC', CAST(0x00009EF500C8D169 AS DateTime), CAST(0x00009EF500C8D1AA AS DateTime), CAST(0x00009EF500D0EE03 AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), NULL, NULL, N'12210153', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), CAST(0x00009EF500D123B8 AS DateTime), CAST(0x00009F090133920D AS DateTime), N'12212202', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), NULL, NULL, N'12210153', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), NULL, NULL, N'12210153', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), NULL, NULL, N'12210153', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), NULL, NULL, N'12210153', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005865', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CC5365 AS DateTime), CAST(0x00009EF500CC5394 AS DateTime), CAST(0x00009EF500D123B8 AS DateTime), N'javlosi', N'00317318', CAST(0x00009F09017FDA68 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), NULL, NULL, N'12210153', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), CAST(0x00009EF500D16151 AS DateTime), CAST(0x00009F010143FE2B AS DateTime), N'12212202', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), NULL, NULL, N'12210153', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), NULL, NULL, N'12210153', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), NULL, NULL, N'12210153', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), NULL, NULL, N'12210153', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005866', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CD69E9 AS DateTime), CAST(0x00009EF500CD6A1D AS DateTime), CAST(0x00009EF500D16151 AS DateTime), N'javlosi', N'00316287', CAST(0x00009F01017F0AFC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), NULL, NULL, N'12210153', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), CAST(0x00009EF500D1BEC1 AS DateTime), CAST(0x00009F090144CD71 AS DateTime), N'12212202', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), NULL, NULL, N'12210153', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), NULL, NULL, N'12210153', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), NULL, NULL, N'12210153', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), NULL, NULL, N'12210153', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005867', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CE1B4D AS DateTime), CAST(0x00009EF500CE1B98 AS DateTime), CAST(0x00009EF500D1BEC1 AS DateTime), N'javlosi', N'00317293', CAST(0x00009F09017AA728 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'12207004', N'GERE', N'PEN', CAST(0x00009EF500CF024E AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'12212202', N'TESOR', N'PEN', CAST(0x00009EF500CF024E AS DateTime), CAST(0x00009EF500D1ECB2 AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'12213330', N'GERE', N'PEN', CAST(0x00009EF500CF024E AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'16238591', N'GERE', N'PEN', CAST(0x00009EF500CF024E AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'fedegest', N'GERE', N'PEN', CAST(0x00009EF500CF024E AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF500CF024E AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005868', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF500CF024E AS DateTime), CAST(0x00009EF500CF0274 AS DateTime), CAST(0x00009EF500D1ECB2 AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), NULL, NULL, N'12210153', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), CAST(0x00009EF500D2436A AS DateTime), CAST(0x00009EFC01483EC1 AS DateTime), N'12212202', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), NULL, NULL, N'12210153', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), NULL, NULL, N'12210153', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), NULL, NULL, N'12210153', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), NULL, NULL, N'12210153', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005869', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500CF8B11 AS DateTime), CAST(0x00009EF500CF8B3F AS DateTime), CAST(0x00009EF500D2436A AS DateTime), N'javlosi', N'00315561', CAST(0x00009EFD00EC9988 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), NULL, NULL, N'12210153', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), CAST(0x00009EF500D26F90 AS DateTime), CAST(0x00009EFB014F7A38 AS DateTime), N'12212202', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), NULL, NULL, N'12210153', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), NULL, NULL, N'12210153', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), NULL, NULL, N'12210153', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), NULL, NULL, N'12210153', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005870', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF500D035E9 AS DateTime), CAST(0x00009EF500D0361D AS DateTime), CAST(0x00009EF500D26F90 AS DateTime), N'javlosi', N'00315467', CAST(0x00009EFC00EECADC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), NULL, NULL, N'ddimarco', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), CAST(0x00009EF500D37CAB AS DateTime), CAST(0x00009EF500D61F37 AS DateTime), N'12212202', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), NULL, NULL, N'ddimarco', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), NULL, NULL, N'ddimarco', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), NULL, NULL, N'ddimarco', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), CAST(0x00009EF500D1B6C5 AS DateTime), CAST(0x00009EF500D37CAB AS DateTime), N'18896332', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005871', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF500D1B696 AS DateTime), NULL, NULL, N'ddimarco', N'00314742', CAST(0x00009EF50117DE18 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'12207004', N'GERE', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'12212202', N'TESOR', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), CAST(0x00009EF501159573 AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'12213330', N'GERE', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'16238591', N'GERE', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'fedegest', N'GERE', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), NULL, NULL, N'12209600', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005872', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF500FB1BBB AS DateTime), CAST(0x00009EF500FB1BEE AS DateTime), CAST(0x00009EF501159573 AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'12207004', N'GERE', N'PEN', CAST(0x00009EF501119E4C AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'12212202', N'TESOR', N'PEN', CAST(0x00009EF501119E4C AS DateTime), CAST(0x00009EF50115E154 AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'12213330', N'GERE', N'PEN', CAST(0x00009EF501119E4C AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'16238591', N'GERE', N'PEN', CAST(0x00009EF501119E4C AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'fedegest', N'GERE', N'PEN', CAST(0x00009EF501119E4C AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF501119E4C AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005873', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF501119E4C AS DateTime), CAST(0x00009EF501119EB7 AS DateTime), CAST(0x00009EF50115E154 AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'12207004', N'GERE', N'PEN', CAST(0x00009EF501121B5F AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'12212202', N'TESOR', N'PEN', CAST(0x00009EF501121B5F AS DateTime), CAST(0x00009EF50116270D AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'12213330', N'GERE', N'PEN', CAST(0x00009EF501121B5F AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'16238591', N'GERE', N'PEN', CAST(0x00009EF501121B5F AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'fedegest', N'GERE', N'PEN', CAST(0x00009EF501121B5F AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF501121B5F AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005874', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF501121B5F AS DateTime), CAST(0x00009EF501121BDE AS DateTime), CAST(0x00009EF50116270D AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF501151E65 AS DateTime), NULL, NULL, N'12210153', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF501151E65 AS DateTime), CAST(0x00009EF5011653AD AS DateTime), CAST(0x00009EFE01430D4B AS DateTime), N'12212202', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF501151E65 AS DateTime), NULL, NULL, N'12210153', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    GO

    print 'Processed 100 total records'

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF501151E65 AS DateTime), NULL, NULL, N'12210153', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF501151E65 AS DateTime), NULL, NULL, N'12210153', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF501151E65 AS DateTime), NULL, NULL, N'12210153', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005875', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF501151E65 AS DateTime), CAST(0x00009EF501151E99 AS DateTime), CAST(0x00009EF5011653AD AS DateTime), N'javlosi', N'00315961', CAST(0x00009EFF011EF7AC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), NULL, NULL, N'12209600', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), CAST(0x00009EF5011AADC7 AS DateTime), CAST(0x00009EFE0155CBAC AS DateTime), N'12212202', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), NULL, NULL, N'12209600', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), NULL, NULL, N'12209600', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), NULL, NULL, N'12209600', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), NULL, NULL, N'12209600', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005876', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF5011A4182 AS DateTime), CAST(0x00009EF5011A41AC AS DateTime), CAST(0x00009EF5011AADC7 AS DateTime), N'javlosi', N'00315938', CAST(0x00009EFF011BD298 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), NULL, NULL, N'12209600', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), CAST(0x00009EF600B0C5C4 AS DateTime), CAST(0x00009F0901447603 AS DateTime), N'12212202', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), NULL, NULL, N'12209600', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), NULL, NULL, N'12209600', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), NULL, NULL, N'12209600', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), NULL, NULL, N'12209600', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005877', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF600A56EF5 AS DateTime), CAST(0x00009EF600A56F32 AS DateTime), CAST(0x00009EF600B0C5C4 AS DateTime), N'javlosi', N'00317294', CAST(0x00009F09017AC924 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600A8647D AS DateTime), NULL, NULL, N'12209600', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600A8647D AS DateTime), CAST(0x00009EF600B0F19E AS DateTime), CAST(0x00009EFC01432662 AS DateTime), N'12212202', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600A8647D AS DateTime), NULL, NULL, N'12209600', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600A8647D AS DateTime), NULL, NULL, N'12209600', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600A8647D AS DateTime), NULL, NULL, N'12209600', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF600A8647D AS DateTime), NULL, NULL, N'12209600', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005879', N'4445', N'javlosi', N'GERE', N'PPL', CAST(0x00009EF600A8647D AS DateTime), CAST(0x00009EF600A864B0 AS DateTime), CAST(0x00009EF600B0F19E AS DateTime), N'javlosi', N'00315557', CAST(0x00009EFD00E7C084 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), NULL, NULL, N'ddimarco', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), CAST(0x00009EF600C209F0 AS DateTime), CAST(0x00009EF600F34F10 AS DateTime), N'12212202', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), NULL, NULL, N'ddimarco', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), NULL, NULL, N'ddimarco', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), NULL, NULL, N'ddimarco', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), CAST(0x00009EF600BE8F04 AS DateTime), CAST(0x00009EF600C209F0 AS DateTime), N'18896332', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005880', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600BE8EDF AS DateTime), NULL, NULL, N'ddimarco', N'00314830', CAST(0x00009EF6012813B4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C02078 AS DateTime), NULL, NULL, N'ddimarco', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C02078 AS DateTime), CAST(0x00009EF600C2B222 AS DateTime), CAST(0x00009EF600F36436 AS DateTime), N'12212202', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C02078 AS DateTime), NULL, NULL, N'ddimarco', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C02078 AS DateTime), NULL, NULL, N'ddimarco', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C02078 AS DateTime), NULL, NULL, N'ddimarco', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C02078 AS DateTime), CAST(0x00009EF600C020A2 AS DateTime), CAST(0x00009EF600C2B222 AS DateTime), N'18896332', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005881', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C02078 AS DateTime), NULL, NULL, N'ddimarco', N'00314831', CAST(0x00009EF601281D14 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C1693A AS DateTime), NULL, NULL, N'ddimarco', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C1693A AS DateTime), CAST(0x00009EF600E22907 AS DateTime), CAST(0x00009EF600F37A04 AS DateTime), N'12212202', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C1693A AS DateTime), NULL, NULL, N'ddimarco', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C1693A AS DateTime), NULL, NULL, N'ddimarco', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C1693A AS DateTime), NULL, NULL, N'ddimarco', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C1693A AS DateTime), CAST(0x00009EF600C16969 AS DateTime), CAST(0x00009EF600E22907 AS DateTime), N'18896332', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005882', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C1693A AS DateTime), NULL, NULL, N'ddimarco', N'00314832', CAST(0x00009EF601282548 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C29140 AS DateTime), NULL, NULL, N'ddimarco', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C29140 AS DateTime), CAST(0x00009EF600E26F73 AS DateTime), CAST(0x00009EF600F39010 AS DateTime), N'12212202', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C29140 AS DateTime), NULL, NULL, N'ddimarco', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C29140 AS DateTime), NULL, NULL, N'ddimarco', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C29140 AS DateTime), NULL, NULL, N'ddimarco', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C29140 AS DateTime), CAST(0x00009EF600C2918B AS DateTime), CAST(0x00009EF600E26F73 AS DateTime), N'18896332', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005883', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C29140 AS DateTime), NULL, NULL, N'ddimarco', N'00314833', CAST(0x00009EF601283100 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), NULL, NULL, N'ddimarco', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), CAST(0x00009EF60106D709 AS DateTime), CAST(0x00009EF6011BC106 AS DateTime), N'12212202', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), NULL, NULL, N'ddimarco', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), NULL, NULL, N'ddimarco', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), NULL, NULL, N'ddimarco', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), CAST(0x00009EF600C3B124 AS DateTime), CAST(0x00009EF60106D709 AS DateTime), N'18896332', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005884', N'0021', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C3B0FE AS DateTime), NULL, NULL, N'ddimarco', N'00314876', CAST(0x00009EF6014DEF1C AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), NULL, NULL, N'ddimarco', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), CAST(0x00009EF6011036FC AS DateTime), CAST(0x00009EF6011BDFCE AS DateTime), N'12212202', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), NULL, NULL, N'ddimarco', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), NULL, NULL, N'ddimarco', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), NULL, NULL, N'ddimarco', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), CAST(0x00009EF600C638FE AS DateTime), CAST(0x00009EF6011036FC AS DateTime), N'18896332', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005885', N'0020', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C638D4 AS DateTime), NULL, NULL, N'ddimarco', N'00314879', CAST(0x00009EF6014DFAD4 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C80075 AS DateTime), NULL, NULL, N'ddimarco', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C80075 AS DateTime), CAST(0x00009EF60112D293 AS DateTime), CAST(0x00009EF6011BF742 AS DateTime), N'12212202', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C80075 AS DateTime), NULL, NULL, N'ddimarco', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C80075 AS DateTime), NULL, NULL, N'ddimarco', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C80075 AS DateTime), NULL, NULL, N'ddimarco', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C80075 AS DateTime), CAST(0x00009EF600C800AD AS DateTime), CAST(0x00009EF60112D293 AS DateTime), N'18896332', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005886', N'0020', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C80075 AS DateTime), NULL, NULL, N'ddimarco', N'00314880', CAST(0x00009EF6014DFE58 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), NULL, NULL, N'ddimarco', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), CAST(0x00009EF60119CCF0 AS DateTime), CAST(0x00009EF6011C3791 AS DateTime), N'12212202', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), NULL, NULL, N'ddimarco', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), NULL, NULL, N'ddimarco', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), NULL, NULL, N'ddimarco', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'18896332', N'GERE', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), CAST(0x00009EF600C95D40 AS DateTime), CAST(0x00009EF60119CCF0 AS DateTime), N'18896332', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005887', N'0020', N'fedegest', N'GERE', N'PPL', CAST(0x00009EF600C95D07 AS DateTime), NULL, NULL, N'ddimarco', N'00314878', CAST(0x00009EF6014DF750 AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'12207004', N'GERE', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'12212202', N'TESOR', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), CAST(0x00009EF600D1928C AS DateTime), NULL, N'12212202', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'12213330', N'GERE', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'16238591', N'GERE', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'fedegest', N'GERE', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), NULL, NULL, N'12210153', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005888', N'4445', N'javlosi', N'GERE', N'PEN', CAST(0x00009EF600D017B5 AS DateTime), CAST(0x00009EF600D017ED AS DateTime), CAST(0x00009EF600D1928C AS DateTime), N'javlosi', NULL, NULL)

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005889', N'4445', N'12207004', N'GERE', N'PPL', CAST(0x00009EF600D09D01 AS DateTime), NULL, NULL, N'12210153', N'00315936', CAST(0x00009EFF011B8FCC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005889', N'4445', N'12212202', N'TESOR', N'PPL', CAST(0x00009EF600D09D01 AS DateTime), CAST(0x00009EF600D1C0F6 AS DateTime), CAST(0x00009EFE01570EEB AS DateTime), N'12212202', N'00315936', CAST(0x00009EFF011B8FCC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005889', N'4445', N'12213330', N'GERE', N'PPL', CAST(0x00009EF600D09D01 AS DateTime), NULL, NULL, N'12210153', N'00315936', CAST(0x00009EFF011B8FCC AS DateTime))

    INSERT [dbo].[tmpReport] ([userCode],

    , [responsible], [typeResponsible], [status], [createDate], [assignmentDate], [approvalDate], [updateUser], [grade], [changeDate]) VALUES (N'9000000005889', N'4445', N'16238591', N'GERE', N'PPL', CAST(0x00009EF600D09D01 AS DateTime), NULL, NULL, N'12210153', N'00315936', CAST(0x00009EFF011B8FCC AS DateTime))

  • Try this code. It does the dynamic SQL cross tabs that I had mentioned earlier. I put the date as '1900-01-01' for the records which have a matching responsible-status pair, but who's date is null, just so you can differentiate.

    CREATE TABLE #ResponsibleStatus

    (

    ID INT IDENTITY PRIMARY KEY,

    Responsible VARCHAR(13),

    Status VARCHAR(5)

    )

    INSERT INTO #ResponsibleStatus (Responsible, Status)

    SELECT DISTINCT Responsible, Status

    FROM #tmpReport

    DECLARE @SelectClause VARCHAR(MAX)

    SET @SelectClause = 'SELECT

    userCode,

    '

    DECLARE @FromClause VARCHAR(MAX)

    SET @FromClause = '

    FROM #tmpReport

    GROUP BY userCode'

    DECLARE @CurrID INT

    DECLARE @NewID INT

    SET @CurrID = 0

    SET @NewID = 0

    DECLARE @CurrResponsible VARCHAR(MAX)

    DECLARE @CurrStatus VARCHAR(MAX)

    WHILE 1 = 1

    BEGIN

    SET @CurrResponsible = ''

    SET @CurrStatus = ''

    SELECT TOP 1

    @NewID = ID,

    @CurrResponsible = Responsible,

    @CurrStatus = Status

    FROM #ResponsibleStatus

    WHERE ID > @CurrID

    ORDER BY ID

    IF @CurrID = @NewID

    BREAK

    SET @SelectClause = @SelectClause + 'MAX(CASE WHEN Responsible = ' + CHAR(39) + @CurrResponsible + CHAR(39) + ' AND Status = ' + CHAR(39) + @CurrStatus + CHAR(39) + ' THEN ISNULL(approvalDate, ''1900-01-01'') ELSE NULL END) AS [' + @CurrResponsible + ' - ' + @CurrStatus + '],

    '

    SET @CurrID = @NewID

    END

    SET @SelectClause = LEFT(@SelectClause, LEN(@SelectClause) - 3)

    PRINT @SelectClause + @FromClause

    EXEC (@SelectClause + @FromClause)

    DROP TABLE #ResponsibleStatus

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply