Transact SQL :: Linked Server Return Message Query Timeout

Jul 22, 2015

Error below was returned from an agent job:

OLE DB provider "SQLNCLI11" for linked server returned message "Query timeout expired". [SQLSTATE 01000]

A linked Server was set up against a remote database to backup a database and it runs perfectly well when executed directly against the remote server but returns the above error when set up through Sql Server Agent. Permissions are good as the step returns success. I reset the query timeout property to zero but error persist. What else should I be looking at to make this work?

View 3 Replies


ADVERTISEMENT

Linked Server Query - Timeout Error Under Load

Apr 23, 2002

Hello,

I am researching alternatives to a stored procedure that uses a linked server query that my ASP page uses to retrieve records to the page.

Should I:

Use replication (Data is constantly updated, so a snapshot won't do. Merge replication?)

Break up the stored procedure into subqueries?

Use a view on the remote server instead of the actual tables?

I am trying to reduce the amount of table scans, what is the best way to do this?

Here is the stored procedure I am trying to tune:
(@startDate and @endDate are parameters passed from the web page):

CREATE PROCEDURE dbo.spELRMCcardXtionByDate @dcid nvarchar(255), @startDate datetime, @endDate datetime
AS
SELECT Store.[Str#], Store.[Dcid#], E.card_number, E.program_number
, E.start_date, E.end_date, E.card_number, E.event_number
, E.status, E.budget, E.scheduled_date, P.tx_time, P.purchase_amount
, L.merchant_name
FROM (Store INNER JOIN Event E ON Store.[DemoID#] = E.event_number)
LEFT JOIN (Location L RIGHT JOIN POS_TX P ON L.location_number = P.location_number)
ON E.event_number = P.event_number
WHERE (((Store.[Dcid#])= @dcid)) AND E.scheduled_date BETWEEN @startDate AND @endDate
ORDER BY Store.[Str#]
GO

Any suggestions on my sp or anything else that can implement would be greatly appreciated.

TIA,

Bruce Johnston
Programmer/Analyst

View 1 Replies View Related

Linked Server Slow Query Return

Jun 14, 2006

Hello can some one explain this to me and give me some advice. I have sqlserver1 and sqlserver2 I have a linked server set up [ipaddress] on both servers. When I pass a variable to the stored proc or the query it takes up to 20 seconds to return 1 row but if I replace my varibles like email='sqlboy@coxnet' and firstname='ted' and lastname='clien' it returns the one row im looking for in about 2 seconds but if I pass email =@email ,fname=@fname,lname=@lname I get the 20 second thing. The query is a stored proc being called from an asp app. I get the same results when I run this in query analyzer.

Here is the query.

DECLARE @email VARCHAR(75),@fname VARCHAR(50),@lname VARCHAR(100)

IF EXISTS (SELECT TOP 1 email
FROM [ipaddress].{database}.dbo.{tablename}--server1
WHERE email = @email )
BEGIN
set nocount on
SELECT TOP 1 email,
FIRSTNAME,
MIDDLENAME,
LASTNAME,
TITLE,
COMPANYNAME,
ADDRESS1,
ADDRESS2,
CITY,
STATE,
ZIP,
COUNTRY
FROM [ipaddress].{database}.dbo.{tablename} --server2
WHERE email in(SELECT EMAIL
FROM [ipaddress].{database}.dbo.{tablename} where email=@email--server1)
AND RecordStatusID ='1' and FirstName=@fname and LastName=@lname
END
ELSE

IF EXISTS (SELECT top 1 email,
FIRSTNAME,
MIDDLEINITIAL,
LASTNAME,
TITLE,
COMPANYNAME,
ADDRESS1,
ADDRESS2,
CITY,
STATE,
ZIP,
COUNTRY
FROM {databases}.dbo.attendees--server1
WHERE email =@email and FirstName=@fname and LastName=@lname)
BEGIN
SELECT TOP 1 email,
firstname,
MIDDLEINITIAL AS MIDDLENAME,
lastname,
title,
companyname,
address1,
address2,
city,
state,
zip,
country
FROM {database}.dbo.attendees --server1
WHERE email in (SELECT DISTINCT email
FROM server1.dbo.ebooksrequests--server1
where email=@email) and email=@email and FirstName=@fname and LastName=@lname
SET NOCOUNT OFF

END







View 4 Replies View Related

Transact SQL :: Query AD With No Linked Server

Aug 28, 2015

Is it possible to pull name & email from Active Directory using SSMS w/o a linked server connection?

And this would be using SQL 2008

View 7 Replies View Related

Query Timeout Expired.... Message 7412. How To Catch This Error??

Oct 26, 2007

Hi All,

I have the same question and error that Chopaka is getting:

"I have a SQL 2005 job that calls a stored proc. The job step returns the message "Query timeout expired....Message 7412...The step succeeded." The proc never actually ever did anything due to the query timeout, and the job continued on to other steps. I'm going to address the timeout issue eventually, but first I'd like to trap the timeout problem and force the job to end.

It appears that the query timeout isn't really an error, just a message. I've tried TRY-CATCH in the SP but the situation isn't caught, again probably due to the interpretation that it isn't an error."


I have reduced the "Remote Query time out" to 1 sec, in order to catch the error and to prevent the job from running, but the error is not caught.


Is there a way to catch this in the SQL or in the job step to prevent the job from continuing?

This is the script that I'm using without any luck
BEGIN TRY
BEGIN Transaction
Create table #tmpSummaryTable
(
)
insert into #tmpSummaryTable
select * from CDRServer01.iXtemp.dbo.gx_tbFTRSummary_test

COMMIT Transaction
END TRY

BEGIN CATCH
DECLARE @err int
SELECT @err = @@error
PRINT '@@error: ' + ltrim(str(@err))

SELECT ERROR_NUMBER() ERNumber,


ERROR_MESSAGE() Error_Message
ROLLBACK
Return

END CATCH

View 3 Replies View Related

Transact SQL :: Need A Query To Return From LoanStatus

Oct 9, 2015

I have a table which contains a 2 columns "LoanID" and "LoanStatus" and the values in "LoanStatus" are either 0 or 1 in it. If I run a select statement; I get:

LoanID    LoanStatus
1                  0
2                  1
3                  1
4                  1
5                  0

I need a query to return the following from the LoanStatus (distinct Values):

1                 NA
0                 Current
-1                 Late

View 8 Replies View Related

Transact SQL :: How To Return Number Of Records In Query As If TOP Was Not Used

Jul 21, 2015

What I would like to do is to have a TSQL Select return the number of records in the Result as if TOP (n) had not been used. Example:I have a table called Orders containing more than 1.000 records with OrderDate = '2015/07/21' and my client application has a threshold for returning records at 100  and therefore the TSQL would look like

SELECT TOP (100) * FROM Orders Where OrderDate = '2015/07/21'  ORDER by OrderTime Desc

Now I would like to "tell" the client that only 100 of 1.000 records are shown in the client application grid. Is there a way to return a value indicating that if TOP (100) had not been used the resultset would have been 1.000. I know I could create the same TSQL using COUNT() (SELECT COUNT(*) FROM Orders Where OrderDate = '2015/07/21'  ORDER by OrderTime Desc) and return that in a variable in the SELECT statement or even creating the COUNT() as a subquery and return it as a column, but I would like to avoid running multiple TSQL's. Since SQL Server already needs to select the entire recordset and sort it (ORDER BY) and return only the first 100 the total number of records in the initial snapshot must somehow be available.

View 6 Replies View Related

Transact SQL :: Query To Return As Part Of The Fields

Oct 16, 2015

I am working on a query that is quite complex. I need the query to return as part of the fields a field that will contain the total percentage of tickets in a version.The query is below

select cat.name as name,count(distinct bug.id) as numberOfBugs,cast(count(bug.id) * 1000.0 / sum(count(bug.id) * 10.0) over() as decimal(10,2))/100 AS qnt_pct, vers.version, dateadd(s,vers.date_order,'1/1/1970') as "Release_Date"
from mantis_bug_table bug
INNER JOIN mantis_category_table cat on cat.id = bug.category_id
LEFT OUTER JOIN mantis_project_version_table vers on vers.project_id = vers.project_id and vers.version = bug.version

[code]....

View 12 Replies View Related

Linked Server Problem Login Timeout Expired

Aug 3, 2007



Hello All,

My application is dependent on two databases one is on sql 2005 machine and other is on sql 2000 machine. A linked server is establish between these two using sql account which has appropriate rights on both server's databases.

application works fine but after some time it crashes and if i see error from sql profiler i get the error

OLE DB provider "SQLNCLI" for linked server "sql2000machine" returned message "Login timeout expired".

Few days back applciation was working absolutly fine, but i was trying to make linked sever through windows account, i dnt know wat has i changed during achiveing that setup that now application (linked server) is not working even with sql account.

please help its urgent.

View 2 Replies View Related

Linked Server Login Timeout Expired Error

Aug 3, 2007

Hello All,

My application is dependent on two databases one is on sql 2005 machine and other is on sql 2000 machine. A linked server is establish between these two using sql account which has appropriate rights on both server's databases.

application works fine but after some time it crashes and if i see error from sql profiler i get the error

OLE DB provider "SQLNCLI" for linked server "sql2000machine" returned message "Login timeout expired".

Few days back applciation was working absolutly fine, but i was trying to make linked sever through windows account, i dnt know wat has i changed during achiveing that setup that now application (linked server) is not working even with sql account.

please help its urgent.

View 1 Replies View Related

Transact SQL :: Return A Query Based On Dateadd Function

Aug 3, 2015

I'm trying to return a query based on the dateadd function.  I have a column in the database called date_added which is am successfully using the the DATEADD function above as date1.  The Var1 variable I need to populate from the database too from a column called life_span which is an int data type.  The error I get is An expression of non-boolean type specified in context where a condition is expected near select

My query is as follows: select guid, dateadd(day,life_span,date_added) as datepayday. From User_table

View 5 Replies View Related

Transact SQL :: Use Dynamic Table Names And Get Return Value From The Query

Sep 16, 2015

I don't know why this is so difficult. What I want to do is take a table name as a parameter to build a query and get an integer value from the result of the query. But from all of the research I have been doing, Dynamic SQL is bad in SQL server because of SQL Injections. But my users are not going to be supplying the table names.

Things I have learned:

 - SQL Functions cannot use Exec to execute query strings.
 - SQL Functions can return a concatenated string that could be used by a stored procedure to Exec the query string.

So how can I write a stored procedure that will
 
1. take a parameter
2. Pass the parameter to a function that will return a string
3. Execute that string as SQL
4. Get a return value from that SQL statement
5. Then finally, from a View, how can I pass a parameter to the stored procedure and get the returned value from the stored procedure to be used as a field in the View?

Numbers 3, 4, and 5 are where I am really stuck. I guess I don't know the proper syntax and limitations of SQL Server.

View 14 Replies View Related

Transact SQL :: How To Return Content Of Table As Columns In Query

Oct 1, 2015

I have

Customer table, tblCust: ID; Name

1 Peter2 Mary
Product table, tblProduct: ID; Name

1 Banana2 Orange3 Apple
Order tblOrder, tblOrder: CustID; ProductID; Amount

1 ;2 ;$20 – means Peter ordered $20 oranges

How do I write the SQL query so that the values in tblProduct become column, currently I have 20 items in that table. So, it will return something like this according to the information that I provide above?

Name Banana Orange Apple 

Peter 0 20 0

View 4 Replies View Related

Transact SQL :: Query To Return Greater Than Zero Values To Sort Up And Zeros Go Down

Sep 17, 2015

I am using a table to store different size numbers for example:

Look at the picture below:

But I want this type of output look at the picture below:

How to sort the query to return greater than zero values to sort up and zeros go down. 

I am using sql server 2008.

View 14 Replies View Related

Transact SQL :: Query To Return Free Space From Mounted Drive

Nov 25, 2015

Is it possible to find out available free space from a mounted / network drive using tsql query? I am using sql server 2008 R2.

View 5 Replies View Related

How To Return A Varchar From Sproc On Remote Linked Server?

Aug 22, 2007

The following T-SQL 2005 snippet executes a remote sproc on an Oracle database.
DECLARE @OutParam VARCHAR(5)
EXEC ('{Call getnextpin(1)}') AT ALTTEST
 GetNextPin takes a single input parameter.
I need to modify the above code snippet to return the next PIN number into @OutParam.
Any ideas?
Any help appreciated.
 
Regards,
 Paul.

View 1 Replies View Related

Linked Server Doesn't Return All Rows For Some Tables

Jun 4, 2007

Hello,



I created a linked server in sql server 2005 which links to a AS400 DB. I use ODBC driver.

For some tables, it return all data but for another tables, it only return part of the rows.

How it may happen?



Thanks

View 1 Replies View Related

Linked Server To Oracle Via ODBC, Return Less Records

Apr 22, 2006

I have an Oracle 9i server. To access the data in Oracle, I setup an ODBC connection to it and am able to return data from it using WinSQL (a general ODBC database client). The SQL statement is simply "SELECT * FROM COLOR" and all 133 records returned properly.

I need to copy the data from the Oracle server to SQL Express, therefore I set up linked server (by Microsoft ODBC provider) using the same ODBC connection as described above.

The problem is: only 32 records returned.

May I ask if there is any problem to this linked server setup?

Thanks.

View 4 Replies View Related

OLE DB Provider MSDAORA For Linked Server DBNAME Returned Message ORA-01476: Divisor Is Equal To Zero

Aug 14, 2007




Hi All,



I have a strange problem with one of my Linked server connections. I am connecting from
SQL Server 2005 Standard Edition (9.00.3042.00) to and Oracle 10g database using the Microsoft OLE DB Provider for Oracle. The connection works and I am able to select from all the Oracle tables except for 1 table. When selecting from this table I get the following error:


OLE DB provider "MSDAORA" for linked server "DBNAME" returned message "ORA-01476: divisor is equal to zero".

Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "MSDAORA" for linked server "DBNAME".



This probem happens if the table has rows or has no rows (empty table).

I have tried SELECT * and count(*) along with selecting a specific column from the table.

I can use SQL*plus from the system that the SQL database server running on it and select from the table using the same login/password that the linked server uses to rule out a permissions problem.

Any suggestions on what I can try next?


Thanks.

View 3 Replies View Related

Return Records Through A Linked Server That Uses ODBC Data Source

Jul 20, 2005

Hi,I used sp_addlinkedserver to link to a remote server through ODBC.When I execute select count(*) from LinkSrv.SI.DBO.SIHeader in SQL QueryAnalyzer. It returns 13705 records. But when I execute select * fromLinkSrv.SI.DBO.SIHeader. It only return 885 records. If I specify somecolumns, select ODCOMP, ODPONO, ODVDCD from LinkSrv.SI.DBO.SIHeader.It returns more records, 1213 records.I guess there is something limit the return storage, but I can notfind it.Any suggestion will be appreciated. Thank you

View 3 Replies View Related

Transact SQL :: Server Getting Return Value

Sep 15, 2015

I wrote the following Scalar Function.

USE [Metadata]
GO
/****** Object: UserDefinedFunction [Event].[BestTBOI] Script Date: 9/15/2015 11:11:21 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[code]...

But I cannot figure out how to 'Call' this stored procedure from a query, passing the needed parameters, and use the return value from the stored procedure in one of the query fields.

Cannot find either column "Event" or the user-defined function or aggregate "Event.DynamicBestTBOI", or the name is ambiguous. use Metadata select Event.DynamicBestTBOI(IntegratedTest1.Event.EventTrackUpdate.SequenceNumber,'EventTrackUpdate')
from IntegratedTest1.Event.EventTrackUpdate

View 4 Replies View Related

Query To Return Records Where One Table Is Void Of Linked Data In Another Table

Feb 13, 2008

I have two tables that share a common identity row. I need to build a query where data that exists in one table does not contain data in the other table. For example, table 1 has columns of Owner_ID, LastName, FirstName and table 2 has columns Auto_ID, Owner_ID, AutoMake. Both tables are joined by the Owner_ID column. I need a query that provides all owners from table 1 who do not have an entry in table 2.

Thanks in advance,

Mark

View 5 Replies View Related

TimeOut Expired Message

Jun 19, 2000

We have a stored procedure that is creating information in tempdb table and using cursors. It is suppose to produce a report of about 1000 records. If we run the stored procedure as a sql query then it works fine. If we run it using the VB app. it times out with the following message:
[Microsoft][ODBC Sql Server Drive]Timeout expired(#0)

Is there anything I can do to correct this problem?

Thank you,

Tracy

View 1 Replies View Related

Message Sent Retry Timeout

Sep 26, 2006

Hi

here is from BOL

>When a conversation is marked delayed, Service Broker performs the matching process again after a timeout period. Notice that failure to find a matching route is not considered an error.

for example it could happen when there is no route for a service.
the question is - what is this timeout. Is it configurable? on a system wide
basis ?

It will be great if this process is described in more details.

Best regards,

Leonid.

View 3 Replies View Related

Timeout Expire Error Message

Aug 8, 2006

Hi all,

My application is developed using VB6.0 and SQL Server 2000. Frequently the application displays error message, which says 'Timeout Expired - occurred while getting records" when no. of users grows more than 20. We are using processor based licence SQL Server.
Under what are all the scenario, this error may come? Anybody explain me.
Thanks in advance.
K.Manoharan

View 4 Replies View Related

Indexing To Prevent Timeout Expired Message

Jul 20, 2005

sorry for posting a question that has probably been posted hundreds oftimes, but i can't seem to find the answer i need...We're using a SqlServer 7.0 database and recently started getting timeout expirederrors on our views, which i'm assuming is due to the volume ofrecords in our tables. Unfortunately i'm not too experiences w/indexing tables, so my question is:1) how do you determine which fields to index (does it have to be afield w/ no nulls, no duplicates..similar to primary key), and why notindex the primary key2) is it better to index the same field on different tables, or is ita better design to index a different field for each table (ex. do youwant to index the same field that you link the different tables with,or do you want to avoid doing this)3) can somebody explain the concept of creating a clustered index4) once table is indexed, if there are users accessing the linkedtables via Access, do they have to re-link the tables?sorry for the number of questions and what may appear to be simplequestions to most, but again, i'm pretty unfamiliar w/ indexing andwould really appreciate any help...thanks

View 1 Replies View Related

Transact SQL :: Using Linked Server And Windows Authentication

Sep 24, 2015

I have set up two SQL server (e.g. Server1 and Server2) which are set up to use Windows Authentication with my login (e.g. login1).On Server1 I have created a linked server to Server2, I have then selected the Security tab and added my local login and selected impersonate. I have then selected ‘Be Made using the login’s current security context’.I then receive the error message ‘The linked server has been updated but failed a connection test. Do you want to edit the linked server properties?’

View 9 Replies View Related

Transact SQL :: Linked Server Backup Restore

Oct 19, 2015

I need to replicate database from one of LINKED server to another SQL instance on a different server. What will be a best way to achive this ? I'm using MS SQL server 2008 r2

- Should I just take a backup of my current database and restore it (Will this also cover up access to objects for different users, or do I need to write a separate script for it).
OR
-Should I go to TASK > generate scripts and create one... Here I believe I need to additionally take care of access rights, indexes, constraints.

View 4 Replies View Related

Transact SQL :: Self Linked Server For Purpose Of Alias?

Oct 2, 2015

basically, we have two databases, one with fix name, eg. DB1 in all environments, and another is named with prefix based on environment, eg. DB2_DEV, DB2_TEST, that is generated by some managed application. 

Then we have queries or view/SPs residing in the first database, eg. DB1 that access database resources from the second database, DB2_***. Both databases are residing in the same SQL instance.

Currently, we have hardcoded the database name in the query but would prefer not to manually rename or write other scripts to update the query with the correct database name when deploying to other environments.

For example:

SELECT * FROM DB2_DEV.dbo.vAccounts
When deploy to TEST, we need to update the query to:
SELECT * FROM DB2_TEST.dbo.vAccounts

So, I looked at Synonyms but it seems it can only create 'alias' for tables or views, and not database.

Hence, last thought is to create self linked server, so I can write my query like below and setup the linked server accordingly.

SELECT * FROM SRCDB.dbo.vAccounts

Any consideration to think of, eg. performance, security, etc?

View 8 Replies View Related

Transact SQL :: Temporary Table Created In Linked Server

Sep 20, 2015

I'm executing a sp name  [uspGeneral_Getinfo]. It return a global temporary table's name and I want to get data from that table.

[192.168.2.11] = Linked Server

Declare@LinkedServer varchar(40)='[192.168.2.11].DBPharm.dbo.',@OutPutTableName varchar(50)=' ',@SQL nvarchar(max)Set@LinkedServer=Rtrim(Ltrim(@LinkedServer))Set@SQL=' Declare @OutPutTableName varchar(50),@SQL nvarchar(max) EXEC '+@LinkedServer+'[uspGeneral_GetDomainDataNew] 9,null, @OutPutTableName OutPut '+' Set @SQL='''+'Select * from '''+'+ @OutPutTableName'+' Exec sp_executesql @SQL 'Select@SQL

Above code are executing from another server [192.168.2.10].But getting an error that .I can't able to search where the temp table created in linked serve tempdb or ...?

Database name 'tempdb' ignored, referencing object in tempdb.
Database name 'tempdb' ignored, referencing object in tempdb.
Database name 'tempdb' ignored, referencing object in tempdb.
Database name 'tempdb' ignored, referencing object in tempdb.
Msg 208, Level 16, State 0, Line 38
Invalid object name '##table1FD1B81Bx4EAFx4FFDx9F6Fx15B77B6445F'.

View 8 Replies View Related

Transact SQL :: Referencing UDFs And Sprocs In Linked Server

Oct 7, 2015

We have migrated a database (myDb2014) to a SQL Server 2014 instance. We have another on a 2008R2 instance (myDb2008). Both on the same server.

I have setup a linked server to the 2014 instance from the 2008R2 one.

I have a number of sprocs on myDb2008 that call TVFs and sprocs on myDb2014. This worked fine when they were both on the same instance.

Now however, I have an issue where I would have to update all the references in each calling query.

I looked into creating Synonyms but this only works for Tables/Views.

Is there a workaround to querying myDb2014 TVFs/sprocs without having to update each calling query in myDb2008?

View 25 Replies View Related

Transact SQL :: Move Data From Linked Remote Server?

Jun 18, 2015

I have a database that is off site, it has a database one it that I have a Linked server connection to. We have no other means of connecting to that server database except via that linked server connection. Is there a way I can Copy eplicatemoves etc... that database to an internal server with out doing it table by table. It is apx 80gig db 

Copying a backup file is not an option either, and Mailing it on media make it a significant delay.

View 2 Replies View Related

Transact SQL :: Linked Server And LDAP - Get Password Expiration Date

Oct 29, 2015

I have configured a Linked Server with Active Directory (LDAP), working properly.

Now, through this Linked Server, I need information about password expiration date in my AD Domain accounts.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved