Friday, March 30, 2012

Linked Server Query

When I execute the SQL Statement in the SQL Query Analyzer, I get the result
s
returned in 4 seconds but when I use the same query from a stored procedure
and execute it from SQL Analyzer, it is taking too long about 50-55 seconds.
Am I missing something? I have a join between external and internal table.
Thanks!!
Vibs
SELECT
AAPSUser.[ID]
, AAPSUser.First_Name
, AAPSUser.Last_Name
, AAPSUser.Second_Sections,
[UserExtraInfo].[title],
[UserExtraInfo].[profile1_text],
[UserExtraInfo].[profile2_text],
[UserExtraInfo].[profile3_text]
FROM
AAPS.AAPS_Web.DBO.iMIS_Data as AAPSUser
INNER JOIN UserExtraInfo ON AAPSUser.[ID] = UserExtraInfo.Id
WHERE
AAPSUser.[ID] = 003479Are you running the query and the proc containg the query locally i.e, same
SQL Server? (Same security creditials as well?) I.e, log into QA and run
the query then directly below (same window) exectue the proc (same query in
proc right?). You can also compare the execution plans as well for any
visable differences.
HTH
Jerry
"vibs" <vibs@.discussions.microsoft.com> wrote in message
news:6DC8F102-2C0F-4CCE-8831-1F228BAF81AC@.microsoft.com...
> When I execute the SQL Statement in the SQL Query Analyzer, I get the
> results
> returned in 4 seconds but when I use the same query from a stored
> procedure
> and execute it from SQL Analyzer, it is taking too long about 50-55
> seconds.
> Am I missing something? I have a join between external and internal table.
> Thanks!!
> Vibs
> SELECT
> AAPSUser.[ID]
> , AAPSUser.First_Name
> , AAPSUser.Last_Name
> , AAPSUser.Second_Sections,
> [UserExtraInfo].[title],
> [UserExtraInfo].[profile1_text],
> [UserExtraInfo].[profile2_text],
> [UserExtraInfo].[profile3_text]
> FROM
> AAPS.AAPS_Web.DBO.iMIS_Data as AAPSUser
> INNER JOIN UserExtraInfo ON AAPSUser.[ID] = UserExtraInfo.Id
> WHERE
> AAPSUser.[ID] = 003479|||Yes the query and the proc is running from the same query analyzer window on
the same SQL Server. I'll look into the execution plans
Thanks
"Jerry Spivey" wrote:

> Are you running the query and the proc containg the query locally i.e, sam
e
> SQL Server? (Same security creditials as well?) I.e, log into QA and run
> the query then directly below (same window) exectue the proc (same query i
n
> proc right?). You can also compare the execution plans as well for any
> visable differences.
> HTH
> Jerry
> "vibs" <vibs@.discussions.microsoft.com> wrote in message
> news:6DC8F102-2C0F-4CCE-8831-1F228BAF81AC@.microsoft.com...
>
>

No comments:

Post a Comment