@tempTable

  • Hi guys

    When i Execute this Query , The result is

    Msg 102, Level 15, State 1, Line 20

    Incorrect syntax near '@tempTable'.

    declare @tempTable table (Id int identity , child_work_id Varchar(max),PrimaryBBPProcess varchar(max),

    PrimaryBBPlevel2 varchar(max),PrimaryBBPlevel3 varchar(max),

    WorkstreamBusinessGroup varchar(max),WorkBusArea varchar(max),

    WorkProjectArea varchar(max))

    SELECT child_work_id = [object_id],

    PrimaryBBPProcess = MAX(CASE WHEN tagset_name = ' Primary Financial BBP Metric Impacted' THEN tag_name ELSE NULL END),

    PrimaryBBPlevel2 = MAX(CASE WHEN tagset_name = 'Primary Fin. BBP Metric (Level 2)' THEN tag_name ELSE NULL END),

    PrimaryBBPlevel3 = MAX(CASE WHEN tagset_name = 'Primary Fin. BBP Metric (Level 3)' THEN tag_name ELSE NULL END),

    WorkstreamBusinessGroup = MAX(CASE WHEN tagset_name = 'Workstream Business Group' THEN tag_name ELSE NULL END),

    WorkBusArea = MAX(CASE WHEN tagset_name = 'Workstream Business Focus Area' THEN tag_name ELSE NULL END),

    WorkProjectArea = MAX(CASE WHEN tagset_name = 'Workstream Project Focus Area' THEN tag_name ELSE NULL END)

    INTO @tempTable

    FROM view_tag

    GROUP BY [object_id]

    Please help me on this

  • declare @tempTable table (Id int identity , child_work_id Varchar(max),PrimaryBBPProcess varchar(max),

    PrimaryBBPlevel2 varchar(max),PrimaryBBPlevel3 varchar(max),

    WorkstreamBusinessGroup varchar(max),WorkBusArea varchar(max),

    WorkProjectArea varchar(max))

    INSERT INTO @tempTable

    SELECT child_work_id = [object_id],

    PrimaryBBPProcess = MAX(CASE WHEN tagset_name = ' Primary Financial BBP Metric Impacted' THEN tag_name ELSE NULL END),

    PrimaryBBPlevel2 = MAX(CASE WHEN tagset_name = 'Primary Fin. BBP Metric (Level 2)' THEN tag_name ELSE NULL END),

    PrimaryBBPlevel3 = MAX(CASE WHEN tagset_name = 'Primary Fin. BBP Metric (Level 3)' THEN tag_name ELSE NULL END),

    WorkstreamBusinessGroup = MAX(CASE WHEN tagset_name = 'Workstream Business Group' THEN tag_name ELSE NULL END),

    WorkBusArea = MAX(CASE WHEN tagset_name = 'Workstream Business Focus Area' THEN tag_name ELSE NULL END),

    WorkProjectArea = MAX(CASE WHEN tagset_name = 'Workstream Project Focus Area' THEN tag_name ELSE NULL END)

    FROM view_tag

    GROUP BY [object_id]



    Ole Kristian Velstadbråten Bangås - Virinco - Facebook - Twitter

    Concatenating Row Values in Transact-SQL[/url]

  • Hi Farooq,

    You cannot use SELECT ... INTO with a table variable, you should only use INSERT INTO ... SELECT.

    --Ravi.

    Regards,
    Ravi.

Viewing 3 posts - 1 through 2 (of 2 total)

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