I am pretty new to SQL Server, and I have stumbled upon this right here:
BEGIN TRANSACTION loadTTAllocations
INSERT INTO @ttaAllocs
SELECT
company_code AS CompanyId,
job_number AS JobNo,
...
is_blocked AS IsBlocked
FROM
OPENQUERY([SRV_TimeTac],
'SELECT DISTINCT
job.individual_value_1 AS job_number,
job.individual_value_3 AS company_code,
...
now() AS queryTimeStamp
FROM
pm_altran.pm_tasks_subprojects AS taskCode
INNER JOIN
pm_altran.pm_tasks_subprojects AS job
ON job.id = taskCode.mother_id
AND job.is_done = 0
AND NOT job.is_blocked
INNER JOIN
pm_node_to_user AS n2u
ON n2u.node_id = taskCode.id
AND n2u.access = 1
AND n2u.is_todo = 1
LEFT JOIN
altran_pm_user_user_settings AS u
ON u.administrators_id = n2u.user_id
WHERE
taskCode.object_type = ''task''
AND taskCode.is_paid_non_working = 0
AND taskCode.id > 50');
SET @rowCount = @@ROWCOUNT
SET @eventDetails = 'End loadTTAllocations: ' + CAST(@rowCount as VARCHAR(10)) + ' rows affected';
COMMIT TRANSACTION loadTTAllocations
The issue is the OPENQUERY
.
What I understand from the docs is basically, that it is a query just on another server. In this case the SRV_TimeTac?
So in this example, we are querying on another server called "SRV_TimeTac" and returning results to be loaded finally into the temp table called @ttaAllocs.
Is this correct?
Thank you for your help.