Helpful Information
 
 
Category: MS SQL Development
Help! Linked server query problem.

When querying a linked server using a declared variable, a simple query takes forever to run. example is...

declare @temp varchar(10)
set @temp = 'blue'
SELECT * FROM linked_server.database.dbo.table_name tn
WHERE tn.color_id = @temp

-- When I executed this query , it takes forever, but when I execute the query below, it comes back without hesitation..

declare @temp varchar(10)
set @temp = 'blue'
SELECT * FROM linked_server.database.dbo.table_name tn
WHERE tn.color_id = 'blue'

I tried this on another sql server with the exact same version and service pack.. 5.0 NT sql ver. 8.00? with service pack 2 AND IT WORKS FINE.. It is only happening on one isolated server, which to rebuild would be a HUGE task since it is the live server... Does anyone know what is going on or a reference on what is wrong..
Thanks










privacy (GDPR)