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...
>
>

Linked Server query

I have set up a link server to the AS400and I can see the tables in the Enterprise Manager, How do I query it so I can use the data in my SQL Server database.
*****************************************
* This message was posted via http://sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://sqlmonster.com/Uwe/Abuse.aspx...b79e73dd024921
*****************************************
Take a look at OPENQUERY in the BOL
Rick Sawtell
MCT, MCSD, MCDBA
"Vince Lassiter via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:66558ca34dd7468082b79e73dd024921@.SQLMonster.c om...
> I have set up a link server to the AS400and I can see the tables in the
Enterprise Manager, How do I query it so I can use the data in my SQL Server
database.
> *****************************************
> * This message was posted via http://sqlmonster.com
> *
> * Report spam or abuse by clicking the following URL:
> *
http://sqlmonster.com/Uwe/Abuse.aspx...b79e73dd024921
> *****************************************
sql

linked server query

Hi,
I have added a linked server. Now , how can I query the tables and also I
only see one of the few databases only on the linked server. How can I see
all the databases of linked server.
Thanks,
Via the linked server you will see your 'default database' objects on that
target database. Although you cannot graphically browse the multiple
databases that you have access to on the target linked server, you will be
able to access those other databases and tables via querying.
When querying the databases on the linked server, make sure to set your ANSI
settings and issue the queries using the 4-part object context:
ex:
USE ANSI_NULLS ON
GO
USE ANSI_WARNINGS ON
GO
SELECT name FROM <LINKEDSERVERNAME>.Northwind.dbo.Customers
Replace <LINKEDSERVERNAME> with the name of the linked server
"dotnettester" wrote:

> Hi,
> I have added a linked server. Now , how can I query the tables and also I
> only see one of the few databases only on the linked server. How can I see
> all the databases of linked server.
> Thanks,
>
|||Hi,
Before u query to linked server table see in linked server property
that rpc option are checked.
use the select * from [linked
servername].databasename.username.tablename
hope this help
from
killer

Linked server query

can anybody please tell me how to query a table from a linked server?

thanks

Sure, thats quite easy, use the four part notation:

SELECT <columnlist> FROM LinkedServerName.DatabaseName.Owner.Objectname

HTH, Jens Suessmeyer.

linked server query

Hi,
I have added a linked server. Now , how can I query the tables and also I
only see one of the few databases only on the linked server. How can I see
all the databases of linked server.
Thanks,Via the linked server you will see your 'default database' objects on that
target database. Although you cannot graphically browse the multiple
databases that you have access to on the target linked server, you will be
able to access those other databases and tables via querying.
When querying the databases on the linked server, make sure to set your ANSI
settings and issue the queries using the 4-part object context:
ex:
USE ANSI_NULLS ON
GO
USE ANSI_WARNINGS ON
GO
SELECT name FROM <LINKEDSERVERNAME>.Northwind.dbo.Customers
Replace <LINKEDSERVERNAME> with the name of the linked server
"dotnettester" wrote:
> Hi,
> I have added a linked server. Now , how can I query the tables and also I
> only see one of the few databases only on the linked server. How can I see
> all the databases of linked server.
> Thanks,
>|||Hi,
Before u query to linked server table see in linked server property
that rpc option are checked.
use the select * from [linked
servername].databasename.username.tablename
hope this help
from
killer

Linked Server query

I have set up a link server to the AS400and I can see the tables in the Enterprise Manager, How do I query it so I can use the data in my SQL Server database.
*****************************************
* This message was posted via http://sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://sqlmonster.com/Uwe/Abuse.aspx?aid=66558ca34dd7468082b79e73dd024921
*****************************************Take a look at OPENQUERY in the BOL
Rick Sawtell
MCT, MCSD, MCDBA
"Vince Lassiter via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:66558ca34dd7468082b79e73dd024921@.SQLMonster.com...
> I have set up a link server to the AS400and I can see the tables in the
Enterprise Manager, How do I query it so I can use the data in my SQL Server
database.
> *****************************************
> * This message was posted via http://sqlmonster.com
> *
> * Report spam or abuse by clicking the following URL:
> *
http://sqlmonster.com/Uwe/Abuse.aspx?aid=66558ca34dd7468082b79e73dd024921
> *****************************************

Linked Server query

I have set up a link server to the AS400and I can see the tables in the Ent
erprise Manager, How do I query it so I can use the data in my SQL Server da
tabase.
****************************************
*
* This message was posted via http://droptable.com
*
* Report spam or abuse by clicking the following URL:
* http://droptable.com/Uwe/Abuse.asp...2b79e73dd024921
****************************************
*Take a look at OPENQUERY in the BOL
Rick Sawtell
MCT, MCSD, MCDBA
"Vince Lassiter via droptable.com" <forum@.droptable.com> wrote in message
news:66558ca34dd7468082b79e73dd024921@.SQ
droptable.com...
> I have set up a link server to the AS400and I can see the tables in the
Enterprise Manager, How do I query it so I can use the data in my SQL Server
database.
> ****************************************
*
> * This message was posted via http://droptable.com
> *
> * Report spam or abuse by clicking the following URL:
> *
http://droptable.com/Uwe/Abuse.asp...2b79e73dd024921
> ****************************************
*sql