T-SQL (SS2K8) :: How To Return Jobs That Are In Progress

Mar 8, 2014

I have a query that returns the jobs that have completed for the nightly processing.

If I run the query it does not reflect jobs that are in progress.How can the following query be modified to reflect jobs that have started but have not completed?

SELECT DISTINCT j.Name AS Job_Name,
msdb.dbo.Agent_datetime(Run_Date, Run_Time) AS Run_Datetime,
Dateadd(second, Datediff(second, 0, msdb.dbo.Agent_datetime(19000101, Run_Duration)), msdb.dbo.Agent_datetime(Run_Date, Run_Time)) AS Run_Endtime,
Stuff(Stuff(RIGHT('000000'
+ Cast(Run_Duration AS VARCHAR(6)), 6), 5, 0, ':'), 3, 0, ':') AS Run_Duration,

[code]....

View 6 Replies


ADVERTISEMENT

Reporting Services :: Modify Report To Return Events In Progress Over Arrival Date Parameter?

Aug 6, 2015

I have a report which queries events occurring during the reporting time frame the user selects.

A user selects arrivalDateStart as 8/1/2015 and arrivalDateEnd as 12/31/2015 and the results are returned.

The issue is that there is an event that began 7/31/2015 and ends 8/2/2015. This does not appear on the report. The user does not want to have to pick an earlier arrival date as the parameter of his report to pick up anything that was already in progress prior to the beginning of the month.

I am trying to figure out how to add an expression that will also return events that are in progress over the arrival date chosen for the report.

View 9 Replies View Related

T-SQL (SS2K8) :: How To Return Top N And Sum Up The Rest

Feb 10, 2015

I am looking for an elegant way to return top n and sum up the rest, in my case CTE/temp table/variables are not allowed.

View 9 Replies View Related

T-SQL (SS2K8) :: How To Return Zero If No Rows Found

Jun 25, 2014

I have a report that needs to return a count of zero for the rows that have no data, I have tried to use the Left Outer Join but my where clause is excluding the rows with no data and I need to filter the report with the Year, day and Month.

The date filters are from different table(dimDate), not sure how to include them in the #tmpOperationalTypes join as filters

ALTER PROCEDURE [dbo].[spcAdvancedComparisonDateDWReport]
@Year varchar(4000) = '',
@Day varchar(28) = '',
@Month varchar(28) = '',
@Locations varchar(4000) = '',

[Code] .....

View 9 Replies View Related

T-SQL (SS2K8) :: How To Return Max From A Varchar Column

Jan 21, 2015

I need to return the max value from a fieldwhich contains a three part numeric, stored as a varchar. For example

1.0.0
1.0.1
1.1.0
1.2.1
2.0.0
2.1.1
etc

These represent processes, and sub tasks. So I want to return the highest process and its highest task and sub task.

View 9 Replies View Related

T-SQL (SS2K8) :: Return All Values From Table

Oct 1, 2015

I have a small problem with a join clause, because i need to return all values from my table BL:

my code is:

SELECT cast(0 as bit) as 'Escolha',data, contado , ollocal ,origem, ousrdata,ousrhora
FROM
(
SELECT noconta,banco, u_area
FROM BL

[code]....

In fact, i need to return 2 accounts (16,35) - x.NOCONTA IN (16,35), but I know that the problem is on the WHERE clause.How can do that, because i need all the condition on WHERE clause regarding my table OL, but also, i need to return my two accounts (16,35).

View 2 Replies View Related

T-SQL (SS2K8) :: Always Return X Number Of Records Even If Less In Recordset

Jun 27, 2015

I am using SQL Server 2008 as a back end for a Microsoft Access front end. I have created a report that is essentially a Bill Of Lading. The detail section lists all the purchase orders that are being shipped on a single load. The problem with the Access Report is that I always need a set number of records (8) so that the layout is consistent. So, if the query returns 5 records, I need an additional 3 blank records returned with the recordset. If there are 2 records, I need an additional 6, and so on. For simplicity sake the query is:

SELECT tblBOL.PONumber FROM tblBOL WHERE tblBOL.BOLNumber=@BOLNumber;Now, I can get the results I want by using a union query for the "extra" records.

For instance, if there are 6 records returned for BOLNumber '12345', I can get the expected results by this query:

SELECT tblBOL.PONumber FROM tblBOL WHERE tblBOL.BOLNumber='12345'
UNION ALL SELECT '12345',Null
UNION ALL SELECT '12345',Null;

Another solution would be to create a temporary table with the "extra" records and then have only one Union statement. Not sure which is better, but I'm not really sure how to programmatically do either of these. I'm guessing I need to do it in a stored procedure. How do I programmatically create these extra records? One other note.... If there are more than 8 records, I need to return 8 of these "blank" records and none of the real records (hard to explain the reason behind this, but it has to do with the report being only a summary when there are more than 8 records while the actual records will go on a different supplemental report).

View 8 Replies View Related

T-SQL (SS2K8) :: Calculate And Return Previous Date At 18:00 Hours

Mar 4, 2014

How can I calculate and return the previous Date at 18:00 Hours?

Here is a miserable attempt:

DECLARE @RunDate SmallDateTime
DECLARE @CurrentDate SmallDateTime
DECLARE @RunDateWoTime SmallDateTime
SET @CurrentDate = GETDATE()

SET @RunDate = DATEADD(day,-1,@CurrentDate)-- AS CurrentDate
SELECT @RunDate AS RunDate

-- Desired Result is the following:

-- 2014-03-03 18:00

View 9 Replies View Related

T-SQL (SS2K8) :: Convert Column In Query1 And Return Unmatched?

Apr 14, 2014

I have cpt codes in qry1 that need to be converted then match against qry2 and return the unmatched.

Example:

Cpt 88305 in qry1 can be either g4164 or g4165 in qry2
Cpt 88174 in qry1 can be either g3564 or g3565 or g3566 in qry2

select
Invoice_number
,cpt
From qry1
Select
Invoice_number
,cpt
From qry2

What is the easiest way to get the unmatched from qry1 against qry2 joining on invoice_number and converted cpt?

View 1 Replies View Related

T-SQL (SS2K8) :: Return Primary Key From (updated) Record Of Merge Statement

Apr 16, 2014

I'm using a Merge statement to update/insert values into a table. The Source is not a table, but the parameters from a Powershell script. I am not using the Primary Key to match on, but rather the Computer Name (FullComputerName).

I am looking on how-to return the Primary Key (ComputerPKID) of an updated record as "chained" scripts will require a Primary Key, new or used.As an aside: the code below does return the newly generated Primary Key of an Inserted record.

CREATE PROCEDURE [dbo].[usp_ComputerInformation_UPSERT](
@FullComputerName varChar(50) = NULL
,@ComputerDescription varChar(255) = NULL
,@ComputerSystemType varChar(128) = NULL
,@ComputerManufacturer varChar(128) = NULL

[code]....

View 4 Replies View Related

T-SQL (SS2K8) :: Return A Count Per Unique Check In Invoice Table?

May 12, 2014

We have a table that has customers invoices and payment records. In some cases a customer has 10 lines with 10 different invoice numbers but may have paid 2 or more invoices with one check. I need to know how many unique payments were made per customer.

Cust# Inv# Chk#
1 109 101
1 110 101
1 111 102
3 112 10003
2 113 799
2 114 800
1 115 103
3 116 10009
2 117 799
1 118 103

So I need the statement to update the customer table with the annual payments

Customer Table
Cust# Payments
1 3
2 2
3 2

I get close but just not getting it to sort itself out.

View 9 Replies View Related

T-SQL (SS2K8) :: Return Single Row For Matching Columns Based On 3rd Column

Sep 3, 2014

I have data:

Ticket User Priority
A ME 1
B ME 1
C ME 2
C ME 3
D ME 2
E YOU 2
F YOU 1
G ME 3
H YOU 2
H YOU 3
I ME 1

Essentially if Ticket and User are the same I just want the min priority returned.

SO:
Ticket User Priority
A ME 1
B ME 1
C ME 2
D ME 2
E YOU 2
F YOU 1
G ME 3
H YOU 2
I ME 1

I've tried partition and rank but can't get it to return the right output.

View 5 Replies View Related

T-SQL (SS2K8) :: Stored Procedure And SELECT Statement Return Different Results

Dec 4, 2014

I have a stored procedure on a SQL Server 2008 database. The stored procedure is very simple, just a SELECT statement. When I run it, it returns 422 rows. However, when I run the SELECT statement from the stored procedure, it returns 467 rows. I've tried this by running both the stored procedure and the SELECT statement in the same SSMS window at the same time, and the behavior is the same. The stored procedure is:

USE [REMS]
GO
/****** Object: StoredProcedure [mobile].[GetAllMobileDeviceUsers] Script Date: 12/04/2014 */
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[Code] ....

When I do this in the same SSMS window:

exec mobile.GetAllMobileDeviceUsers

SELECT
ee.EmployeeID,
EmployeeName = LastName + ', ' + FirstName
FROM EmployeeInvData ee
--UNION

[Code] ....

I get two result sets. The first is 422 rows; the second is 467 rows. Why?

View 4 Replies View Related

T-SQL (SS2K8) :: Multiple Databases - Return A Single Table With Three Columns

Jan 13, 2015

I have multiple databases in the server and all my databases have tables: stdVersions, stdChangeLog. The stdVersions table have field called DatabaseVersion which stored the version of the database. The stdChangeLog table have a field called ChangedOn which stored the date of any change made in the database.

I need to write a query/stored procedure/function that will return all the database names, version and the date changed on. The results should look something like this:

DatabaseName DatabaseVersion DateChangedOn
OK5_AAGLASS 5.10.1.2 2015/01/12
OK5_SHOPRITE 5.9.1.6 2015/01/10
OK5_SALDANHA 5.10.1.2 2014/12/23

The results should be ordered by DateChangedOn.

View 4 Replies View Related

T-SQL (SS2K8) :: How To Return 3 Month Rolling Average Count Per Username

Mar 30, 2015

how to return the 3 month rolling average count per username? This means, that if jan = 4, feb = 5, mar = 5, then 3 month rolling average will be 7 in April. And if apr = 6, the May rolling average will be 8.

Columns are four:

username, current_tenure, move_in_date, and count.

DDL (create script generated by SSMS from sample table I created, which is why the move_in_date is in hex form. When run it's converted to date. Total size of table 22 rows, 4 columns.)

CREATE TABLE [dbo].[countHistory](
[username] [varchar](50) NULL,
[current_tenure] [int] NULL,
[move_in_date] [smalldatetime] NULL,
[Cnt_Lead_id] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

[code]....

View 9 Replies View Related

T-SQL (SS2K8) :: Return Value In A Status Field Which Has Latest Year And Month

May 11, 2015

I have table in which month & year are stored, Like this

Month Year
10 2014
11 2014
12 2014
1 2015
2 2015
3 2015
4 2015

I wanted a query in which it should return the value in a status field which has latest year & month.

View 9 Replies View Related

T-SQL (SS2K8) :: One Stored Procedure Return Data (select Statement) Into Another Stored Procedure

Nov 14, 2014

I am new to work on Sql server,

I have One Stored procedure Sp_Process1, it's returns no of columns dynamically.

Now the Question is i wanted to get the "Sp_Process1" procedure return data into Temporary table in another procedure or some thing.

View 1 Replies View Related

Progress

May 25, 2006

I have some SP's I run once a month and each SP takes a few mins to run and when I batch em together in one shot, I hate sitting there waiting for them to finish
whats the easiest way to report back the status of the exec?

Ex:
Set NoCount ON
EXEC StatesUpdateZipTableUpdate 'AE'
EXEC StatesUpdateZipTableUpdate 'AK'
EXEC StatesUpdateZipTableUpdate 'AL'
EXEC StatesUpdateZipTableUpdate 'AP'
EXEC StatesUpdateZipTableUpdate 'AR'
EXEC StatesUpdateZipTableUpdate 'AZ'

How would I get it to report the results after each Exec?
In otherwords Id like to create a progress bar......

Just for Query Analyzer..... no bells and whistles

View 5 Replies View Related

DTS Progress Logging

Nov 22, 2002

I need to logg progress of a DTS job. How do I do that? I'd like the progress to be stored in a file and emailed to me.

I need to track progress of the transfer of each table in two databases.

View 2 Replies View Related

Backup Progress Bar

Aug 5, 1998

I am having a problem backing up a customer database to tape.
The progress bar just sits there with no movement. I have even left it running overnight and nothing the next day
I am able to backup all other databases (master, msdb, model).
Any help would be appreciated.

Thank you,
joseph gerardi

View 1 Replies View Related

SQL Communicating With Progress

May 15, 2008

Our ERP uses a Progress db but several of our web apps are developed in vb.Net and use a SQL backend. I need to pull some data in from Progress using TSQL queries.

Experimenting a little I find that a simple query, i.e. from 1 Progress table, takes anywhere from 20 seconds to a couple of minutes. However, when I joined on a 2nd table, I had to cancel the query after it ran for over 10 minutes.

SQL server is connected to Progress via a Linked server.

Any advice on improving the query will be appreciated.

I believe the query has to be in the T-SQL syntax; is that right? Where does the translation into Progress syntax occur?


Thank you,
LadyReader

View 7 Replies View Related

Where In The Restore Progress Am I?

May 30, 2008

Hello, we started a restore of a database that is just over 1.2 TB. It took 23 hours to complete the Copy Data Phase. Now, SQL Server continues to show the database in a Restoring state, however, there is no other indication of what SQL Server is doing. We do not have any way to see in which phase of the restore process SQL Server is in or how much time may be remaining. We do know that SQL Server is doing something because of the I/O activity. Its there a command, script, or other tool that we can use to determine where in the Restore process we are and how much time may be remaining? We did not use the WITH STATS = switch so that is out, and the sys.dm_exec_requests shows Percent_Complete is 100, however, we know that its not done, the Data Copy Phase has completed but the Severe is still churning.

Thanks, Clay

View 4 Replies View Related

Databases Progress

Jul 5, 2006





How Can connect tha Progress Databases in DTS?



View 3 Replies View Related

Parameters - Progress

Dec 10, 2007

Using Reporting Services when I go against an SQL database I use @Company.
when I go against an Oracle database I use :Company.

What do you use when you go against a Progress database?

View 1 Replies View Related

Persist Progress Tab?

Mar 24, 2006

is there a way to capture what gets written to the progress tab to a table, or is it overwritten on each execution as xml somewhere so it can be saved kind of like an odometer? the mission is to be able to audit the results of a load, or even if it doesnt turn out to be a load, then document the run.

similarly, is there a way to watch what executes to see what actually runs during a merge join transform, iow, something that exposes ssis to trace? how do i find it?

thanks

drew

View 2 Replies View Related

How To Get Execution Progress ?

Sep 5, 2007

Does anyone knows how to retrieve execution progress from ssis package, that was
executed programatically.
What I am trying to do, is to launch ssis package on server
and send the progress ("percent complete") to some remote client in order to display it
in progress bar.
I want that ,while ssis package executes, it will raise some event every time the progress changes.

View 4 Replies View Related

SQL Query Progress

Oct 17, 2007

When running large Store Procedures that take several hours, does SQL 05 have a way of monitoring the progress by telling you what it has actually completed so far rather than having to wait till the query has finished to find out.

View 11 Replies View Related

Want To Show The Progress In Status Bar

May 29, 2007

Hi guys, I am using ASP.NET 2.0, In one web page i am loading a data from VIEW,This view takes more time to execute and this this data is i am showing in grid on page load event.and the web page only displayes after the view execute until it remains on old page User fills there is no response. I want to show the progress in status bar,Can any one tell me how can i do this. Thanks in advance

View 1 Replies View Related

How To Show Progress Percent

Jun 14, 2004

I have a script file which do the replication and in the script there is a lot of table need to be addad as article.

So while use osql execute the script there would be cost a lot of time. What I want to do is show a dialog which could show the progress percent and the file name which is now being addad as article.

hwo can i use Transact-SQL to do this?

Thanks a lot

View 4 Replies View Related

SQL Dump Progress Indicator?

Feb 16, 1999

Has anyone heard of/know of a SQL server Dump/Load progress indicator?

Thanks!

-Chris

View 2 Replies View Related

SQL Server && Progress Databases

Jan 20, 2004

Does anybody have information on co-existence of SQL Server and Progress on the same machine? Are they happy to live together, or should they be given separate homes?
I would like to cut down on server proliferation, if possible, and have a server "beefy" enough to handle both, but is it a wise thing to do?

View 1 Replies View Related

Index Creation Progress

Jun 16, 2008

I have 2 questions,

1. I am trying to create an index, which is running for a long time. Is there an option to know the progress so far or how much more time it is going to take?

2. Is there anyway to find out how much space is required to rebuild an index?




------------------------
I think, therefore I am - Rene Descartes

View 2 Replies View Related

Pulling Progress Data

Jun 26, 2006

I'm trying to pull data from about 30 progress databases using DTS andscheduling the jobs to run monthly. I'd like to pull data betweenspecific dates, but for some reason, I can't figure out how to filterthe data on the progress side.I want to run a query that will pull all data fromprior-month/8/current-yearandcurrent-month/15/current-yearI'll also have to account for when it's january, make it december ofthe year before.Any ideas?thanks,M@

View 1 Replies View Related







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