Issues with equal sign when assigning statement to @ variable for EXEC sp_executesql

you need to put it in quote like this '63FEB60-4516-4C1A-9A11-DB30ACA44301' , so your adhoc query would look like this :

    @date datetime,
    @query nvarchar(Max)
    set @date = getdate()-4
    set @query = --'Insert into [SolarWindsOrion].[dbo].[BWC_VPN_Hourly_Long_Store]
                    'SELECT * FROM [SolarWindsOrion].[dbo].[CustomPollerStatistics_Hourly]
                    where Cast(CustomPollerAssignmentID as nvarchar(max)) = ''63FEB60-4516-4C1A-9A11-DB30ACA44301'''
    EXEC sp_executesql @query

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top