Query run in SQL against a linked server never completes

145 views Asked by At

I have 2 servers, Server A is SQL Express with a linked server connection to server B running Advantage.

The linked server set up is fine, and I can see all the tables from Server B via the linked server in Server A.

I can run a script using the execute at syntax to pull data from the linked server fine, eg this script runs in 11 seconds:

execute(' select pl_process, pl_barcode
from opt011d 
left join opt012d on pl_barcode = bc_key 
where pl_process in (''007'')

')

AT ADVANTAGE

I have a large script to run that requires several temp tables to run effeciently.

By adding INTO ##TEMP to the above the script never finishes..

execute(' select pl_process, pl_barcode
INTO ##TEMP
from opt011d 
left join opt012d on pl_barcode = bc_key 
where pl_process in (''007'')

')

AT ADVANTAGE

I have tried running the script with INTO TEMP (ie not a temp table)

execute(' select pl_process, pl_barcode
INTO TEMP
from opt011d 
left join opt012d on pl_barcode = bc_key 
where pl_process in (''007'')

')

AT ADVANTAGE

to store the results in a new table on Server B and the script does not finish, but if I look at the newly created table in Server B the info is all there. It just seems like SQL Express does not know that it's finished?

Has anyone delt with this before?

Thanks.

0

There are 0 answers