Query Runs OK In QueryAnalyzer, But Fails In Batch

Jul 20, 2005

A colleague of mine has a query which fails to run under SQLAgent
batch with the following error:

The conversion of a char data type to a datetime data type resulted in
an out-of-range datetime value. [SQLSTATE 22007] (Error 242) The
statement has been terminated. [SQLSTATE 01000] (Error 3621). The
step failed.

He can run the same query sucessfully via query analyzer (i.e. no
errors, and it does what he wants)

If I try to run the same query through Query Analyzer on my
workstation, I get a different error altogether:

Server: Msg 242, Level 16, State 3, Procedure DateForGrouping, Line 11
The conversion of a char data type to a datetime data type resulted in
an out-of-range datetime value.

Any idea what might be causing these differences in behaviour
depending on how and/or where the query is run from?

The (working) statement in question is:

================================================== ======================
insert into Summary_ReferrerSales
select DateCreated,
ReferrerID,
ReferrerIDCount,
PUIDCount,
ReferrerDescription,
0 as TotalOrderValue,
0 as TotalOrderLines
from vw_ReferrerPopularity

Warning: Null value is eliminated by an aggregate or other SET
operation.

(11996 row(s) affected)
================================================== ====================
And the table / view / function definitions (I take no responsibility
for the view definition!) are:

CREATE TABLE [Summary_ReferrerSales] (
[DateCreated] [datetime] NULL ,
[ReferrerID] [char] (2) NULL ,
[ReferrerIDCount] [int] NULL ,
[PUIDCount] [int] NULL ,
[ReferrerDescription] [nchar] (100) NULL ,
[TotalOrderValue] [numeric](18, 0) NULL ,
[TotalOrderLines] [numeric](18, 0) NULL
) ON [PRIMARY]


CREATE VIEW dbo.vw_ReferrerPopularity
AS
SELECT TOP 100 PERCENT COUNT(dbo.LogReferrerID.Referrer) AS
ReferrerIDCount,
COUNT(DISTINCT dbo.LogReferrerID.PUID) AS PUIDCount,
dbo.DateForGrouping(dbo.LogReferrerID.DateUsed)
AS DateCreated,
dbo.LogReferrerID.Referrer AS ReferrerID,
dbo.LookupReferrerID.ReferrerDescription
FROMdbo.LogReferrerID INNER JOIN dbo.LookupReferrerID
ON dbo.LogReferrerID.Referrer = dbo.LookupReferrerID.ReferrerID
WHERE (dbo.LogReferrerID.DateUsed > CONVERT(DATETIME, '2003-09-01
00:00:00', 102))
GROUP BY dbo.LogReferrerID.Referrer,
dbo.DateForGrouping(dbo.LogReferrerID.DateUsed),
dbo.LookupReferrerID.ReferrerDescription
HAVING (dbo.LogReferrerID.Referrer <> 'WS')
AND (COUNT(dbo.LogReferrerID.Referrer) IS NOT NULL)
AND (dbo.LookupReferrerID.ReferrerDescription IS NOT NULL)
AND (dbo.DateForGrouping(dbo.LogReferrerID.DateUsed) >
CONVERT(DATETIME, '2003-09-01 00:00:00', 102))
AND (COUNT(DISTINCT dbo.LogReferrerID.PUID) IS NOT NULL)
ORDER BY dbo.DateForGrouping(dbo.LogReferrerID.DateUsed) DESC


CREATE TABLE [LogReferrerID] (
[LogReferrerID] [int] NULL ,
[Referrer] [varchar] (2) NULL ,
[DateUsed] [smalldatetime] NULL ,
[HTTPReferrer] [varchar] (1000) NULL ,
[TargetURL] [varchar] (1000) NULL ,
[QueryString] [varchar] (1000) NULL ,
[PUID] [varchar] (50) NULL
) ON [PRIMARY]


CREATE TABLE [LookupReferrerID] (
[ReferrerID] [char] (2) NOT NULL ,
[ReferrerDescription] [varchar] (100) NOT NULL ,
CONSTRAINT [PK_Lookup_ReferrerID] PRIMARY KEY CLUSTERED
(
[ReferrerID]
) ON [PRIMARY]
) ON [PRIMARY]


CREATE FUNCTION dbo.DateForGrouping (@RowDate datetime)
RETURNS datetime AS
BEGIN

declare @datestring char(10)

set @datestring=cast(datepart(dd,@RowDate) as char(2)) + '/' +
cast(datepart(mm,@RowDate) as char(2)) + '/' +
cast(datepart(yyyy,@RowDate) as char(4))

return cast(@datestring as datetime)
END

View 3 Replies


ADVERTISEMENT

A Procedure Runs Slow As A Job But Runs Fast Executed In A Query Window

Apr 23, 2008

Performance issue.


I have a very complex Stored Procedure called by a Job that is Scheduled to run every night.
It's execution takes sometimes 1 or 2 hours and sometimes 7 hours or more.

So, if it is running for more than 4 hours I stop the Job and I run the procedure from a Query Window and it never takes more than 2 hours.

Can anyone help me identify the problem ? I want to run from the Job and not to worry about it.

Some more information:
- It is SQL 2000 Enterprise with SP4 in a Cluster (It happens the same way in any node).
- The SQL Server and SQL Agent services run using a Domain Account that have full Administrative access.
- When I connect to a Query Window I also use a Windows Account.

- There is no locks or process bloking or being blocked while the job is running.
- Using the Task Manager the processor activity is ok, no more than 30 % in any processor.

View 15 Replies View Related

HELP: Package Runs...job Fails!

Dec 18, 2000

I'm trying to run a job which moves data from one machine to another. I can manually execute the package successfully, but the job always fails. I get the dreaded error message 18456, "login failis for user "". I have double checked the logins for both machines,(sql server agent AND the sql server authentication).
Also, I can run a select statement (from server_ to server_2) successfully from query analyzer i.e.

Select *
from <linked_server_name>.<database>.<database_owner>.<table_name>

however, if I run this query from server_2 to server_1 I get the failed login message similar to the error message found in the job history. Since both servers accept nt logins, where is my problem? They are both set up as linked servers, and they are both mssql oledb.
Any suggestions will be appreciated!
thanks

View 1 Replies View Related

Job Fails Though Package Runs

Dec 31, 2007



Like the name says, I'm trying hard, but I'm obviously missing something. Okay, I'm new to SSIS. I'm trying to write a job that deletes some Excel files on the server, copies some Excel files from a Sharepoint instance to the location where the deleted files were, runs an executable to manipulate those files, and then imports them to my SS instance.

the package runs fine when I run it from Managment Studio after installing it on the server. The 'execute task' fails when I run the job containing the package. After creating a proxy to have the SQL Server agent Service run with appropriate permissions, I thought I would have been rid of permissions issues (I gave the proxy way too much permission in an effort to narrow in on my issue), but I could still be missing something.

The job doesn't get into the package enough to even start writing to my log file, and all I get in the job history is the very cryptic 'DTExec: The package execution returned DTSER_FAILURE (1) ' error. If anyone has ideas, I would greatly appreciate being shown the error of my ways.

Thanks!

View 6 Replies View Related

DTS Runs Manually, Fails As Scheduled Job

Jun 26, 2006

I've mined countless threads all over the Net where people are having my problem, but none of the solutions I've seen seem to apply.

When I run a DTS package from Enterprise Manager, everything works great. When I schedule the same package as a job, it fails immediately and reports this error:

Executed as user: SERVER-NAMESYSTEM. DTSRun:  Loading...      Error:  -2147221005 (800401F3); Provider Error:  0 (0)      Error string:  Invalid class string         Error source:  Microsoft Data Transformation Services (DTS) Package      Help file:  sqldts80.hlp      Help context:  713.  Process Exit Code 1.  The step failed.

My hunch is the SERVER-NAMESYSTEM.DTSRun account doesn't have sufficient privileges, but I can't find how/where to fix that.

Help, please.

Thanks,

Doug

 

View 2 Replies View Related

Stored Procedure Runs Manually But Fails As A Job

Oct 8, 2007

I have a stored procedure that syncs 2 databases. It runs fine if I go into the stored procedures and execute it manually, there are a few errors but it doesnt choke on them it completes with the desired end result. However if I create a job to run this dbo, it fails, The error log shows this:

Date,Source,Severity,Step ID,Server,Job Name,Step Name,Notifications,Message,Duration,Sql Severity,Sql Message ID,Operator Emailed,Operator Net sent,Operator Paged,Retries Attempted
10/03/2007 16:06:00,sync,Error,0,MACHINENAME,sync,(Job outcome),,The job failed. The Job was invoked by User MACHINENAMEAdministrator. The last step to run was step 1 (sync).,00:00:19,0,0,,,,0
10/03/2007 16:06:00,sync,Error,1,MACHINENAME,sync,sync,,Executed as user: companyname. ... 0) aspnet Member Exists [SQLSTATE 01000] (Message 0) DNN User Exists [SQLSTATE 01000] (Message 0) Updaing Roles __noelle(5281) [SQLSTATE 01000] (Message 0) aspnet User Exists [SQLSTATE 01000] (Message 0) aspnet Member Exists [SQLSTATE 01000] (Message 0) DNN User Exists [SQLSTATE 01000] (Message 0) Updaing Roles 0(5036) [SQLSTATE 01000] (Message 0) aspnet User Exists [SQLSTATE 01000] (Message 0) aspnet Member Exists [SQLSTATE 01000] (Message 0) New DNN User [SQLSTATE 01000] (Message 0) aspnet User Exists [SQLSTATE 01000] (Message 0) aspnet Member Exists [SQLSTATE 01000] (Message 0) DNN User Exists [SQLSTATE 01000] (Message 0) Updaing Roles 0000000(3795) [SQLSTATE 01000] (Message 0) aspnet User Exists [SQLSTATE 01000] (Message 0) aspnet Member Exists [SQLSTATE 01000] (Message 0) DNN User Exists [SQLSTATE 01000] (Message 0) Updaing Roles 007(8) [SQLSTATE 01000] (Message 0) aspnet User Exists [SQLSTATE 01000] (Message 0) aspnet Member Exis... The step failed.,00:00:19,14,3621,,,,0

So the error is 3621, and the severity is 14 which as I understand it means Insufficient Permissions.

I have already tried this:
Making the Job Agent service logon as MACHINeNAME/Administrator instead of System, giving the user here (companyname) more permissions, but I am at a loss as to why this runs ok when manually executed but fails when run as a job. I have created the job by scripting the dbo "Execute to a file" and having the job run that file as a step, I have also tried copying and pasting the code from the stored procedure into the job step. It always fails for the same reason.

I must say I am very new to SQL, I am a network admin and have inherited this database and server from another client and have to get this sync task to run daily at certain intervals.

Please can anyone shed light on this issue?
Thanks,

View 7 Replies View Related

SQLMaint Runs Clean BUT Sched Task Fails

Jun 18, 1999

I have a number of test databases which were created from the same backup. Set up SQLMaint to run on them each night. SQL Maint seems to run clean on all of them, but on two the Scheduled Task shows "Failed". All tasks have been set up exactly the same.

Has anyone run into something like this?

Here's the output from the maintenance job for one of the failing db's:



Microsoft (R) SQLMaint Utility, Version 6.50.240
Copyright (C) Microsoft Corporation, 1995 - 1996

Logged on to SQL Server 'COSTGUARD2' as 'sa' (trusted)
Starting maintenance of database 'Test15' on Thu Jun 17 23:10:01 1999

[1] Check Data and Index Linkage...

** Execution Time: 0 hrs, 0 mins, 1 secs **

[2] Check Data and Index Allocation...

** Execution Time: 0 hrs, 0 mins, 2 secs **

[3] Check System Data...

** Execution Time: 0 hrs, 0 mins, 1 secs **

[4] Update Statistics...

** Execution Time: 0 hrs, 0 mins, 27 secs **

End of maintenance for database 'Test15' on Thu Jun 17 23:10:30 1999

SQLMAINT.EXE Process Exit Code: 0 (Success)

View 2 Replies View Related

Package Runs Fine In BIDS, Fails When Scheduled

Dec 28, 2007

I have a 7 step SSIS package that manipulates some data on a DB2 database. The package executes perfectly in Business Intelligence Development Studio. I save the package to my SSIS store and then point my scheduled task to it and it fails after about 9 seconds everytime. I have an identical job that works with a different DB2 database that works without any problem. The only difference is the database it's pointing to.

The package is executing as the same user who created it, which has sysadmin to both the SSIS store and the SQL instance the package is executing on. When I saved the package I selected "Rely on server storage roles for access control" for the protection level.

This one is driving me crazy, can't figure it out. Any idea's?

View 7 Replies View Related

SSIS Package Runs Fine; SQL Job Fails (DBF Involved)

Jun 14, 2007

I have created an SSIS package which, as its 2nd step, picks up a .dbf table and does a Data Flow Task of putting the .dbf table into a SQL Server 2005 table (which was just truncated in Step 1).



The Connection Manager that works on the .dbf table is Native OLE DBMicrosoft Jet 4.0 OLE DB Provider.



The entire SSIS package runs perfectly when i run it from my development environment.



I then assigned this Package to a SQL Server 2005 Job. The entire package is the sole step of the job.



But when I run the SQL Job, the Job fails immediately on Step 2.



Here is the error message in View History of the SQL Job:

-----------------------------------------------------------------------------

Executed as user: DBASE01SQLExec. ...on 9.00.3042.00 for 32-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 11:48:37 AM Progress: 2007-06-14 11:48:37.91 Source: DBF to ScanUS_Process Validating: 0% complete End Progress Progress: 2007-06-14 11:48:37.91 Source: DBF to ScanUS_Process Validating: 33% complete End Progress Error: 2007-06-14 11:48:37.91 Code: 0xC0202009 Source: DBF to ScanUS_Process ScanUS DBF Output File [1] Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E37. End Error Error: 2007-06-14 11:48:37.91 Code: 0xC02020E8 Source: DBF to ScanUS_Process ScanUS DBF Output File [1] Description: Opening a rowset for "scanus_process" failed. Check that the object exists in the database. End Error Error: 2007-06-14 11:48:37.95 Code: 0xC004706B Source: DBF to ScanUS_Process DTS.Pipeline Description: "component "ScanUS... The package execution fa... The step failed.

-----------------------------------------------------------------------------



Could someone suggest why this works OK within SSIS but not when the SSIS Pakcage is called from SQL?



thx very much/spirits.



seth j hersh

View 7 Replies View Related

DTS Package Manually/locally It Runs Fine. But The Scheduled Job Run And Fails

Oct 16, 2007

I was facing some issue on MP. Yesterday I changed the SQL services to use the local admin account. That didn't help my MP issue. But it may have created another issue.
When I run the package manually/locally it runs fine. But the scheduled job run and fails with the Title string.
---------------------------------
Executed as user: IL06EDM00SYSTEM. ...tart: DTSStep_DTSExecuteSQLTask_1 DTSRun OnStart: DTSStep_DTSExecuteSQLTask_2 DTSRun OnStart: DTSStep_DTSExecuteSQLTask_3 DTSRun OnError: DTSStep_DTSExecuteSQLTask_2, Error = -2147467259 (80004005) Error string: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. Error source: Microsoft OLE DB Provider for SQL Server Help file: Help context: 0 Error Detail Records: Error: -2147467259 (80004005); Provider Error: 18452 (4814) Error string: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. Error source: Microsoft OLE DB Provider for SQL Server Help file: Help context: 0 DTSRun OnFinish: DTSStep_DTSExecuteSQLTask_2 DTSRun OnError: DTSStep_DTSExecuteSQLTask_3, Error = -2147467259 (80004005) Error string: Login failed for user '(null)'. Reason: Not associated with ... Process Exit Code 2. The step failed.
--------------------------------------------------------------

Any ideas.

View 1 Replies View Related

Lookup Fails When Package Runs In Development On Another PC Than The One Where It Was Created Error: 0xC020824E

Feb 27, 2007

Hi all,

I try to make SSSIS packages made on my pc accesible to an other user of SSIS (both running on Windows 2000). The packages are on a shared drive in our LAN.. Some configurationfiles are use to configure the Oracle DBconnection.The same files are on the same location on both PC's

The other user can open and run the packages but from the moment the lookup buffers are loaded, we get the following errors:

Error: 0xC0202009 at AB_ADDRESS_DF, LOOKUP_POST_ID [22801]: An OLE DB error has occurred. Error code: 0x80004005.

An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80004005 Description: "".

Error: 0xC020824E at AB_ADDRESS_DF, LOOKUP_POST_ID [22801]: OLE DB error occurred while populating internal cache. Check SQLCommand and SqlCommandParam properties.

Error: 0xC004701A at AB_ADDRESS_DF, DTS.Pipeline: component "LOOKUP_POST_ID" (22801) failed the pre-execute phase and returned error code 0xC020824E.

Any suggestion would be most welcome.

View 3 Replies View Related

EXEC Procedure Behave Different In DTS/QueryAnalyzer

Nov 9, 2000

Hi,

My DTS package performs the following:
1. 4 transformations to transform data from Sybase tables A,B,C,D to the temp tables in MSSQL
tmpA, tmpB,tmpC,tmpD
2. Next, I have a task to run 4 stored procedures to load the 4 tmp* tables to actual tables A,B,C,D
(so the task is "exec spA, exec spB, exec spC, exec spD".
3. There are 9/26/280/10000 records in the tables A,B,C,D
4. each stored procedure basically checks whether the record in the tmp* tables exist in the actual
table baesd on the primary key and then perform an insert/update.

The strange thing is:
1. All 9 records in the tmpA is loaded to A. Only 17 records from tmpB is loaded to B
2. The same codes "exec spA, exec spB, exec spC, exec spD", if copied to query analyzer,
they all run to completion, ie all 10000+ records are loaded. so there is no pbm with the data.
3. If I "split" the task such that task1 loads A and task2 loads B,C,D (and task2 runs after task1)
now again all data for A is loaded, but 25 records from B is loaded
4. I tried to catch the @@error in the stored procedure for the insert/update statements
but there's no error. Most importantly, the stored procedures run fine in query analyzer

Is there some sort of timeout or buffer issue here that is causing this strange behaviour.

All help is appreciated.

Thanx
Jes

View 3 Replies View Related

Package Execution Fails In Windows Service But Runs Fine As A Windows Application.

Jun 23, 2006

I am attempting to write a Windows service that watches a database for uploaded files to import. When a new file is found, the corresponding SSIS package is run from the file system with variables passed through. I started development as a Windows app and copied the functionality to a service.

The app runs fine. The service does not. I get a "Failure" each time a package is executed. Everything is identical behind the scenes with the obvious exceptions that OnStart and OnStop handlers are buttons in the app. I added a script task at the beginning of one of the SSIS packages to notify me that it is even running at all. It doesn't even hit that initial task.

Again, the app will run all packages just fine. The data is imported and the results return as "Success."

The following is the code executing the package. Any help is appreciated. I've been banging my head on this one for a few days now. (Is there a tag to format a code sample?)

Dim pkgLocation As String
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult

pkgLocation = sPackageFolder & PackageName & ".dtsx"

pkg = app.LoadPackage(pkgLocation, Nothing)

Dim vars As Variables = pkg.Variables

vars("ImportId").Value = ImportId
vars("ProductionServer").Value = ProductionServer
vars("ProductionDatabase").Value = ProductionDatabase
vars("SourceFileName").Value = FileName
vars("SourceFilePath").Value = FilePath

pkgResults = pkg.Execute()

View 3 Replies View Related

Query Runs Fine In Query Analyser But Not The Query Debugger

Dec 19, 2003

I'm running a query, actually its an insert that works when using the TSQL below.

However when I try to use the debugger to step through and using the exact same values as those below I get the following error:

[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

Its Killing me because everything else works, but this. Can somebody help.


DECLARE @NoteID INT,-- NULL OUTPUT,
@Note_Description NVARCHAR(3000),-- = NULL,
@Date DateTime,-- = NULL OUTPUT,
@ByWho NVARCHAR(30),-- = NULL,
@FK_Action_Performed NVARCHAR(40),-- = NULL,
@FK_UserID INT,-- = NULL,
@FK_JobID INT,-- = NULL,
@Job_Date DateTime,-- = NULL,
@Start DateTime,-- = NULL,
@Finish DateTime,-- = NULL,

@BeenRead NVARCHAR(10),-- = NULL

@FK_UserIDList NVARCHAR(4000)-- = NULL


--SET @NoteID = 409 --NULL OUTPUT,
SET @Note_Description = 'Tetsing'
--SET @Date DateTime = NULL OUTPUT,
SET @ByWho = 'GeorgeAgaian'
SET @FK_Action_Performed = 'Worked hard'
SET @FK_UserID = 5
SET @FK_JobID = 29
SET @Job_Date = 28/01/03
SET @Start = '1:00:20 PM'
SET @Finish = '1:00:20 PM'
SET @BeenRead = 'UnRead'

SET @FK_UserIDList = '1,2,3'


--AS

--SET NOCOUNT ON


SET NOCOUNT ON

SET XACT_ABORT ON

BEGIN TRANSACTION

SET @Date = GETDATE()

-- Insert Values into the customer table
INSERT Note (Note_Description,
Date,
ByWho,
FK_Action_Performed,
FK_UserID,
FK_JobID,
Job_Date,
Start,
Finish)

SELECT --@NoteID,
@Note_Description,
@Date,
@ByWho,
@FK_Action_Performed,
@FK_UserID,
@FK_JobID,

@Job_Date,
@Start,
@Finish

-- Get the new Customer Identifier, return as OUTPUT param
SELECT @NoteID = @@IDENTITY


-- Insert new notes for all the users that the note pertains to, in this case this will be by the assigned
-- users.
IF @FK_UserIDList IS NOT NULL
EXECUTE spInsertNotesByAssignedUsers @NoteID, @FK_UserIDList

-- Insert New Address record
-- Retrieve Address reference into @AddressId
-- EXEC spInsertForUserNote
-- @FK_UserID,
--@NoteID,
-- @BeenRead
-- @Fax,
-- @PKId,
-- @AddressId OUTPUT

COMMIT TRANSACTION

--------------------------------------------------
GO

View 1 Replies View Related

A Query Runs Fast In Query Analuser But Slow In APplication

Jul 23, 2005

I am able to run a query which runs FAst in QA but slow in theapplication.It takes about 16 m in QA but 1000 ms on theApplication.What I wanted to know is why would the query take a longtime in the application when it runs fast on SQL server?How should we try debugging it?Ajay

View 2 Replies View Related

Why Is Execution Of A Storedprocedure In QueryAnalyzer Faster Thanexecuting This SP As Scheduled Job?

Jul 23, 2005

Hi NG!I wrote a stored procedure which at first deletes 100.000 rows and theninserts 100.000 new rows.There is a huge difference between executing this SP in thequery-analyzer (runtime approx. 2 minutes), and scheduling this SP as anJob (runtime > 30 minutes!!!).Why? Whats the issue?And how can i improve the "job"-runtime?The INSERT-Statement gets the data from a joined and grouped SELECT -here is the code (exemplary):INSERT INTO [Table1](Field1, Field2,... )SELECT DISTINCT Field1, Count(field2), (Count(field2) * (-1))FROM Table2 T2INNER JOIN Table3 T3 ON T2.[ID] = T3.[ID]INNER JOIN Table4 T4 ON T2.[DID] = T4.[ID]INNER JOIN Table5 T5 ON T2.[SID] = T5.[ID]GROUP BY field1, field2...I have noticed something strange: After executing the SP thequeryanalyzer outputs "1 Row(s) affected." line by line - 100.000times... Obviously every line is inserted one by one.Any idea?Would it help, to create a temporary-table with SELECT INTO, and thenjust INSERT this data (w/o aggregation) into the target table?Any help is greatly appreciated, tia and best regards---Heiko

View 10 Replies View Related

Query Analyzer Runs The Query Instantly But ADO Can Take Forever???

Aug 29, 2001

THis is so annoying. I have 3 ADO executes in my program. THe first one creates a view, the second one performs an outer join on that view and returns a result set, the third execute drops the aforementioned view. THe program that is using this is installed on about 200 computers scattered across Germany and Italy, all querying the same MSsql server 7.0. THe queries run quite quick when few users are actively using the program (after hours for example). however in the heat of the day performance goes up and down dramatically with identical queries taking from 1 to 20 seconds to return their result set. Now I initially thought 'bandwidth issue out of our server'. However I noticed that if I take those three queries and run them from the sql server enterprise manager( running on the same computer as the aforementioned program) then the queries run instantly and the data is in my result pane in less than 2 seconds ALWAYS....even when the program is dogging it with 20 second delays before the result set returns. I know it is hanging on the return of the result set as I put a stop after before each ADO execute in order to check which one was eating up my time. Why is there this dichotomy between running the queries from my enterprise manager versus running them from an ADO object. Both are using TCP/IP (no named pipes involved). I havent monkied with the attributes of the ADO result set so they are all set to default.
I have used the sql server profiler to trace these queries and they always run in less than 33 milliseconds. THe duration is also never more than 33 milliseconds. THis stinks of a network resource issue but what always leads me somewhere else is how consistent the performance of the enterprise manager is when it runs the exact same three queries.

Here is my slightly edited connection string
Public Const connection_string = "Provider=SQLOLEDB;Server=000.000.000.000;" & _
"User ID=johndoe;Password=janedoe;Network=dbmssocn;" & _
"database=fidojoe"

Here are the 3 ADO executes:
conn.Execute (sqlstr_create_view)
Set resultset1 = conn.Execute(sqlstr_get_providers_by_DMISID)
conn.Execute (sqlstr_drop_view)

View 3 Replies View Related

Query Call By App Runs Long, Same Query In QA Doesn't.

Feb 19, 2008

Hi Guys,

I've got a stored proc used for order generation which runs long sometimes when called from within our app. A normal run will complete within 20s, a long run will get terminated by the app at the 6 minute mark.

When it runs long once, repeated attempts will also do so until I execute the same query the app did, but from within Query Analyzer. At which time the problem will disappear for a day or two. The app connects to the SQL Server 200 SP4 database using ADO.

I suspected statistics might be at fault here but have tried both "UPDATE STATISTICS table WITH FULLSCAN" and "DBCC DBREINDEX('table') to no avail. This issue has occurred and been worked around in this manner a few dozen times.

Any idea what might be going on here?

View 7 Replies View Related

UDF That Runs A Dynamic Query

Mar 11, 2008

Good afternoon,
i'm new to Functions on the SQL server

I'm trying to create a dynamic query that would select the the column passed to the function from a certain table

my table called selected_Date, and has StartDate, and EndDate columns

when the user select for example "StartDate", i pass this as a variable to the function which runs the query. but i always gets back the passed string as a result..

here is my table

StartDate | EndDate
---------------------
20071231 | 20080306


here is my function knowing that i'm passing "Start" as a variable:


Code:

ALTER FUNCTION tu_efgn_int.Get_StartEndDates(@DateType varchar(10))
RETURNS varchar(8)
AS
BEGIN
DECLARE @vDate varchar(15)

Set @vDate= (Select @DateType + 'Date' From dbo.ps_tbl_SelectedDates)

RETURN @vDate
END



@vDate always returns "StartDate" as result instead of 20071231 why is that ?

View 2 Replies View Related

MDX Query Runs Out Of Memory

Jan 15, 2008

Hi,


I am running the following MDX query through a DataReader and a Ado.Net Connection.

SELECT
{[Measures].[Deuda Total Nacional],
[Measures].[Deuda Total Nacional Maximo],
[Measures].[Cupo Nacional],
[Measures].[Porcentaje Utilizacion Maximo],
[Measures].[Pago Minimo Estado Cuenta],
[Measures].[Deuda Ultima Facturacion],
[Measures].[Dias Mora],
[Measures].[Dias Mora Maximo],
}
ON COLUMNS
,[Cuenta].[Cuenta].[Cuenta]*[Cuenta].[Rut].[Rut]*[Cuenta].[Dv].[Dv] ON ROWS

FROM [Bd Rtd]
WHERE [Tiempo].[Mes].&[2007-09-01T00:00:00]

The thing is, when I have about 10 thousand rows It runs in about 50 seconds which is good, but when I run this query and I have processed the cube with 100 thousand rows it runs out of memory and crashes.

I'm working in a shared development server with 1GB of memory for my project.

Is there any way to make it run anyway?? I mean even if it has to swap.


thanks


By the way when this thing goes into production it will have 1.5 million rows

View 2 Replies View Related

Drop PK And Query Runs Faster. Why?

Aug 23, 2000

I have a query which joins multiple tables. This query has suddenly begun to take up to 2 minutes to run (vs. 5-10 seconds previously).

No major change in number of records in the tables (currently about 220,000). When I remove the PK from one of the tables which then forces a tablescan, the query returns to running in 5-10 seconds. If I add the PK back, performance is back to 2 minutes.

Any suggestions short and/or long term?

Thanks for any help.

View 1 Replies View Related

Query Runs On Production And Not On Development?

Jun 30, 2014

I have two servers: one production and one development. There is a third party query that runs on both servers. Yes, the query is poorly tuned - I cannot change it. In production, it runs in 54 minutes. In development, I have tried to let it run for days and it never completes.

Here's what I have tried so far:

Compared the settings of production vs. development. The settings are very similar - the development box is larger, 4 times more memory.

Max degree of parallelism is the same on both boxes.

No compression on both boxes.

The production server is fairly busy, the development server is empty - this is the only process running on it.

Plenty of free disk space.

Updated all statistics on all databases touched by the query on dev.

Indexing is the same on both boxes.

The development box is running MSSQL2012.

The production box is running MSSQL2008R2.

What I've noticed:

The query consumes a massive amount of CPU time.

HUGE number of reads (16 million reads for 10 writes according to sp_WhoIsActive)

Largest wait types are CXPACKET, SOS_SCHEDULER_YIELD and TRACEWRITE respectively.
wait_typesum_wait_time_mspct_wait_timesum_waiting_tasksavg_wait_time_ms
CXPACKET4142765580.7176307423.5
SOS_SCHEDULER_YIELD24146944.7532725530.0
TRACEWRITE19856343.914831338.9

View 9 Replies View Related

Query To Find Who Runs Jobs

Aug 29, 2007

I would like to create a query to find what user owns the job. It probably is in the master db, but I wouldn't know where to begin other than that. Telling me how to either change the job owner or create a job through t-sql would also help. Thanks
-Kyle

View 1 Replies View Related

SQL Pass Through Query Runs Twice From Access

Jul 18, 2007

Hi All,



Recently we started using Pass throughs to perofmr large inserts, however we have started to notice that some of these pass throughs are executing twice, and therefore duplicating data.



Is this a known bug, and if not has anyone got any advice on what could be causing it?



We're connecting from Access 2002 (SP6) to SQL Server 2000 Enterprise.



The conenction string / code is as follows :-



Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.Properties("Jet OLEDBDBC Pass-Through Statement") = True
cmd.Properties _
("Jet OLEDB*** Through Query Connect String") = _
"ODBC;DSN=" & myDatabaseShort & ";DATABASE=" & myDatabase & ";UID=sa;PWD=" & Left(myDatabaseShort, 4) & ";"



It connects fine. My sql string is a straightforward Insert statement that only executes once via SQL Query Analyzer.



I'm calling the pass through using the following lines of code:-



cmd.CommandText = mysql
cmd.Execute



Can anyone see anything obvious that I'm doing wrong, or is this a known issue?


Cheers

View 5 Replies View Related

Query In Stored Procedure Runs Too Fast

Jan 8, 2008

Ok, I'll admit right off the bat that I never suspected that I'd ever raise this complaint, much less worry about how to fix the "problem" associated with it!

We're preparing to take a large set of changes (projects) to PeopleSoft Financials from development to test. The code is still somewhat rough, but it has been "desk checked" to ensure that it does what the developers think that it ought to do, and they've blessed it at that point. The code is now moving into the test phase, and the QA team is finding locking/blocking issues that we've never seen in this code before... Sort of a "lock avalanche" where no one process locks for very long, but many of them block one another to the point where applications actually "freeze" while almost never hitting a deadlock.

My solution was to create a "blitzkrieg" query / stored procedure that would periodically sample master.dbo.sysprocesses, master.dbo.sysdatabases, and apply one of the dm_ functions to gather information on locking, blocking, and deadlocking. My procedure runs nicely (it never hangs) and gets about 99.3% of the data that I want.

The problem is that the blasted query / stored procedure runs either too fast or too slow, depending on how you look at it. Because the dm_ function takes a few ms to run, there can be a situation where either a row appears as a false positive or as a missing row because of timing... Either the culprit shows up as a blocker, but by the time the victim spid is evaluated the block has cleared, or the row is skipped and by the time the victim is evaluated the block has occured.

The whole process runs in well under 100 ms when there is nothing to report, and I've never seen it run 200 ms yet under the worst conditions it has faced, so the code is fast... The problem is that I really don't want to try to enforce any kind of locking to resolve the issue, because that locking would impact performance and that is EXACTLY what I do NOT want to do.

Any suggestions?

-PatP

View 8 Replies View Related

Query Runs Slower When Converted To A View

Jul 23, 2005

I have a query I developed and optimised as well as possible beforeconverting to a view.When running in query analyser the query runs in 15 to 18 seconds -which is acceptable.When "converting" into a view ( This is necessary for operationalreasons) and running with the same parameter it runs in 3 to 4minutes.Is there something I am unaware of ( well of course there is !!) -I was wondering why this occurs and how I can avoid / correct theissue.All advice gratefully received.Dave ( Still learning stuff about SQL Server every day!!)

View 1 Replies View Related

Simple Select Query Runs Forever

Dec 14, 2007



Hi all,

I know this sounds rather dumb but my select statement is running forever!
I am trying to execute the statement through my C# code.

If I try to run the query through sql server management studio, sometimes it runs fine, but sometimes it keeps running and never returns a value.

I am doing something like this:

###########################################################################################
String query = "SELECT studentID from StudentTable WHERE studentDeptID = '100' AND deptName = 'CS'";

SqlCommand command = new SqlCommand(query, connection);
Object myObject = command.ExecuteScalar();

############################################################################################

StudentTable contains roughly 1000 rows.


Somebody please help me out of this. Thanks in advance.

Surya

View 11 Replies View Related

Help Me Diagnose This SQL Timeout (runs 40 Seconds In ASP.NET, &<1 Second In Query Analyzer)

Mar 8, 2007

This is in ASP.NET 1.1.  I have a performance problem with a webform.  The form contains several bound fields and a couple datagrids.  I fill the grids by creating a data adapter, then I use the adapter to fill a dataset, then I set the grid datasource to the dataset.
The query to fill one of the grids is getting a SQL timeout when running from my application (it takes about 40 seconds to complete).  When I run the same SQL code from SQL Query Analyzer it runs in less than 1 second.  (it is embedded sql in the app, not a stored procedure).
I suspect that something else is being requested from SQL during the postback that is causing a blocking issue or something but I can't tell exactly what is happening.  I've tried tracing through the code and all that I can tell is that the timeout occurs during the dataadapter.fill command.
Has anyone else seen something similar?  Is there a good way for me to see what SQL commands are being executed from ASP.NET?  Any advice on debugging this would be much appreciated.

View 1 Replies View Related

Query Runs 10x Slower In Asp.net Than In Management Studio - Any Ideas?

May 5, 2007

We're on SQL 2005 SP1, IIS6, ASP.NET 2.0Data access is 3 tier (.xsd, BLL) similar to the data tutorials.From SQL Profiler:ASP.NETexec dbo.SpGetCatalogCategories @Show='Children',@ServiceId=31016,@BrandId=NULL,@CategoryId=NULL,@ParentId=10028,@ApplicationId=NULL,@ShowUniversal=1Event Class: RPC:Completed CPU: 5,109Reads: 613,174Writes: 0Duration: 5,133Management Studioexec dbo.SpGetCatalogCategories @Show='Children',@ServiceId=31016,@BrandId=NULL,@CategoryId=NULL,@ParentId=10028,@ApplicationId=NULL,@ShowUniversal=1Event Class: SQL:BatchCompletedCPU: 407Reads: 2,182Writes: 0Duration: 409I can post the SP if it will help.This is in a production enviroment and any help is greatly appreciated.kyle 

View 12 Replies View Related

Query Based On Two Temp Tables Runs Forever

Oct 28, 1998

View 1 Replies View Related

Query Runs On Sql7.0 But Keeps Running On Sql2000 Without Output

Aug 15, 2001

The following query runs fine on sql 7.0 but it kind of hangs/keeps running without any output on sql server 2000
---------------------
Set @cmd = 'Update ABCD Set
'+@day+'_LB = IsNull(LB,0),
'+@day+'_UT = IsNull(UNIT,0)
From tempData as T
Where T.STORE_NUM = ABCD.STORE_NUM And T.ITM_ID = ABCD.UPC'
execute (@cmd)
------------------------------------
But if we hard code the @day parameter and run the query like this it runs very fast on sql 2000....

Update ABCD Set THIRD_LB = IsNull(LB,0),
THIRD_UT = IsNull(UNIT,0)
From tempData as T
Where T.STORE_NUM = ABCD.STORE_NUM And T.ITM_ID = ABCD.UPC
------------------------------

View 2 Replies View Related

Why Does A Query Runs Considerably Faster Than Stored Procedure?

Dec 29, 2003

I have an stored procedure that takes 23 seconds to execute. However, the same query is executed in 4 seconds.

All the tests where made using the Query Analizer.

What could be wrong?

Thanks a lot in advance.

View 13 Replies View Related

SQL Server 2008 :: Query Runs Fine Individually But Not Together?

Jul 21, 2015

I am able to select the average, max, etc of the variable in a simple select statement but when I do the following, it doesn't work. The reason I am doing the following is because I am calculating the average and such over a 5 min interval, then saving the output as one line. That is why I condense average, max, min, and stdev into one variable which I then output. why it won't run when I have it like this but will run when it is like this?

will run:

SELECT AVG(NacTemp), MAX(NacTemp),MIN(NacTemp), STDEV(NacTemp)
FROM [DATABASE]
WHERE [UTCDeviceTimeStamp] between DATEADD(minute, -5, GETUTCDATE()) and GETUTCDATE()

won't run but I need it to:

DECLARE @now datetime SET @now = GETUTCDATE() --Universal Time
DECLARE @timeint int SET @timeint = '5' --time interval in minutes
DECLARE @time datetimeSET @time = (SELECT MIN([UTCDeviceTimeStamp]) FROM [DATABASE] WHERE [UTCDeviceTimeStamp] BETWEEN DATEADD(minute, -@timeint,@now) AND @now) -- Timestamp data will be saved as
DECLARE @comma varchar(4) SET @comma = ', '

[Code] ....

View 9 Replies View Related







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