Anyone have any ideas as to why I'm getting the attached error to this code? You can click on the image for the full error.
Any help is appreciated.
DECLARE @RESULTS TABLE( Application_Name varchar(50), Port_Number int, NodeName nvarchar(50), SUM_of_Bytes_Transferred int)
DECLARE @RESULTSOUTPUT TABLE(Application_Name varchar(50), Port_Number int, NodeName nvarchar(50), SUM_of_Bytes_Transferred int)
-- this will insert the results into one master temp table
INSERT INTO @RESULTS(Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred)
SELECT NetflowApplicationSummary.AppName AS Application_Name,
NetflowApplicationSummary.Port AS Port_Number,
Nodes.Field_Site_Location AS NodeName,
SUM(NetflowApplicationSummary.TotalBytes) AS SUM_of_Bytes_Transferred
FROM NetflowApplicationSummary INNER JOIN Nodes ON (NetflowApplicationSummary.NodeID = Nodes.NodeID)
WHERE
DateTime between dateadd(week, -1, getdate()) and getdate()
-- now query that master table looking for site 1 data and put that into the Results Output
INSERT INTO @RESULTSOUTPUT(Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred)
SELECT TOP 10 Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred
FROM @RESULTS
WHERE (Nodes.NodeID = 22)
ORDER BY SUM_of_Bytes_Transferred DESC
-- now query that master table looking for site 2 data and put that into the Results Output
INSERT INTO @RESULTSOUTPUT(Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred)
SELECT TOP 10 Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred
FROM @RESULTS
WHERE (Nodes.NodeID = 23)
ORDER BY SUM_of_Bytes_Transferred DESC
-- now query that master table looking for site 3 data and put that into the Results Output
INSERT INTO @RESULTSOUTPUT(Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred)
SELECT TOP 10 Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred
FROM @RESULTS
WHERE (Nodes.NodeID = 27)
ORDER BY SUM_of_Bytes_Transferred DESC
--this query will group the sites back together with each site containing the top 10 results from whatever
SELECT Application_Name, Port_Number, NodeName, SUM_of_Bytes_Transferred
FROM @RESULTSOUTPUT
GROUP BY NodeName,Application_Name, Port_Number