jeudi 30 juin 2016

SSIS Execute SQL Task Editor query failed to parse

I have the following script in a Execute SQL Task Editor. I have two parameters that I have mapped to the question marks. The query parses when I set @ClientCode and @PEK to something else. Why does my query not parse with the ? parameters? The full error is "The query failed to parse. Syntax error, permission violation, or other nonspecific error"

declare @ClientCode varchar(100)
declare @PEK int
set @ClientCode = ?
set @PEK = ?


if((@ClientCode != '') and (@ClientCode is not null))
begin
    exec        portal.GetClients @ClientCode
end

else if((@PEK != 0) and (@PEK != '' ))
begin

    select      distinct c.Id, c.Name, c.Code
    from        Features.map.ProfileAreasManagementAreas pama INNER JOIN
                ClientDW.dbo.ManagementAreas ma ON pama.ManagementAreaKey = ma.ManagementAreaKey INNER JOIN
                ClientDW.dbo.Clients c ON ma.ClientKey = c.ClientKey
    where       pama.PublishEventKey = @PEK
end

else 
begin  
    select      top 1 PublishEventKey
    from        Features.publish.PublishEvents
    order by    PublishDate  desc

end 

image of Parameter Mapping

Aucun commentaire:

Enregistrer un commentaire