Transact SQL :: Records Returned To Same Status

Jul 23, 2015

In my database I have an Audit table, that keeps track of teams worked upon the same record in a workflow.I need to find out how many records have been returned to the first team for correction ?The column 'Status' is numbered from 1 to 6 and Column 'EditTime' saves the time when record has been edited.how many records have been returned for correction and identify those records.

View 9 Replies


ADVERTISEMENT

Transact SQL :: Send Mail If Any Records Returned

Nov 4, 2015

I would like to use sp_send_dbmail, but I only want to send mail if there are any records returned.

I have found some solutions, but you must always first check if there is any record and later you can call "sp_send_dbmail" and within you must again query database for results.

What I want to do is to query database just once, because I dont want to use server performance two times. Query is bit complicated.

View 11 Replies View Related

Transact SQL :: Fetching Records Based On Maximum Date And Status

Jul 2, 2015

I have a scenario to fetch records for each ID on 2 conditions. There are 2 types of Product type for each ID. PFE and PRI. I need only latest active PFE and at the same time all the latest PRI should be closed. (meaning, only PFE should be in Active status currently)

1.) Latest Product type PFE should be A (active) status for the particular ID
2.) At the same time ALL the latest PRI should be C(closed) status for the same ID

I have give example with 3 scenarios and desired output

1.) For ID 101, Latest PFE is active and all latest PRI is closed ----> Should come in result
2.) For ID 102, Latest PFE is Closed and all latest PRI is closed ---->Should NOT come in result

View 5 Replies View Related

Returned Status Value 2 Error

Jan 14, 2006

Could someone please explain why I get the following errors ?

I have them in 15 out of 20 packages and its always the same, I have tried, removing the columns from the data source but it just seems to jump then to another column.

I have also tried redirecting the errors to a differnet error database but ALL the rows just seem to be errors then

In event viewer I get no further information simply

Event Type: Error
Event Source: SQLISPackage
Event Category: None
Event ID: 12291
Date:  14/01/2006
Time:  14:57:56
User:  
Computer: 
Description:
Package "Policy_PC" failed.

[Flat File Source [1]] Error: Data conversion failed. The data conversion for column "Column 42" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".

[Flat File Source [1]] Error: The "output column "Column 42" (176)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "Column 42" (176)" specifies failure on error. An error occurred on the specified object of the specified component.

[DTS.Pipeline] Error: The PrimeOutput method on component "Flat File Source" (1) returned error code 0xC0202092.  The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.

Any input at all is welcome, Im still a newbie at this

View 4 Replies View Related

DTS Error ? No Query Specification Returned By Transform Status

Mar 3, 2004

I'm getting this error in a simple DTS package.

No query specification returned by transform status.

Any ideas what's causing this ?

DTS is simply running a query (which returns data via preview)
and insert results into a table.

Thanks
Mark

View 1 Replies View Related

The Data Provider Or Other Service Returned An E_FAIL Status!?!?! WT-???

Oct 24, 2006

I'm running sql server ver 7.0 SP4.I have an access project (.adp) that runs a view which is nothing morethan a select statement. Access locks up solid when I try to run thisquery - with NO error messages what-so-ever.If I sign onto the server, and run the view from enterprise manager - Iget:"the data provider or other service returned an E_FAIL status" !?!?!There is NO ERROR number, or further explanation of the message!!Now - this query DID work last week - all of a sudden I get this error- I've:1) repaired / compacted this database2) rebooted the server3) spent several hours searching websites & groups for an explanationa) I don't care how useless some people think enterprise manager is -at least it gave me SOME kind of error; where access just locks up!b) There are no issues with null values, or problem date fieldsanywhere in these tables.4) tried MANY variations on the query, and am now more confused thanever.5) I've RUN THIS QUERY IN AN ACCESS MDB WITH LINKS TO THE SQL SERVER -AND IT WORKS!?!?!?!?The query I'm using follows; if I remove ONE field from the selectstatement - this query RUNS!!!It doesn't matter what field I remove! It's as if, I can only have somany fields in the select statement!?!?!?This is clearly ridiculous since the query ran fine last week with thesame number of fields, not thatthat should have anything to do with this, as sql shouldn't care howmany fields I request.I'm not actually requesting any fields in the last table - but if Iremove this table it works!? If I leave this table, and select fieldsfrom it, but remove another table - again it works!So my questions:1) What [T-] is going on here?2) Why would an mdb be able to run a query that an adp can not!?!?3) When will microsoft ever release a product that provides usefulerror messages?I really don't expect an answer to #3, because I know the answer isNEVER - microsoft doesn't want to make solving problems easy.Here's the query I'm using:SELECT codes.proj_id, answers.report_date,answers.release_date, answers.notes,answers.answer_date, answers.answer_person,answers.answer, answers.answer_status,answers.answer_person2, codes.cust_idFROM dbo.codes LEFT OUTER JOINdbo.demos ONdbo.codes.code = dbo.demos.code LEFT OUTER JOINdbo.answers ON dbo.codes.code = dbo.answers.codeany help appreciated - TIABob

View 2 Replies View Related

Data Access :: Recordset Returned By Query Have A Status Of Closed?

Oct 8, 2015

I'm running the following SQL query from LabVIEW, a graphical programming language, using the built in capabilities it has for database connectivity:

    DECLARE @currentID int
    SET @currentID = (SELECT MIN(ExperimentID) FROM Jobs_t WHERE JobStatus = 'ToRun');
    UPDATE [dbo].[Jobs_t]
    SET [JobStatus] = 'Pending'
    WHERE ExperimentID = @currentID;
    SELECT @currentID AS result
<main.img>

This is the analogous code to main() is a C-like language. The first block, which has the "Connection Information" wire going into it, opens a .udl file and creates an ADO.NET _Connection reference, which is later used to invoke methods for the query.

<execute query.img>

This is the inside of the second block, the one with "EXE" and the pink wire going into it. The boxes with the gray border operate much like "switch" statements. The wire going into the "?" terminal on these boxes determines which case gets executed. The yellow boxes with white rectangels dropping down are invoke nodes and property nodes; they accept a reference to an object and allow you to invoke methods and read/write properties of that object. You can see the _Recordset object here as well. <fetch recordset.img>

Here's the next block to be executed, the one whose icon reads "FETCH ALL". We see that the first thing to execute on the far left grabs some properties of the recordset, and returns them in a "struct" (the pink wire that goes into the box that reads "state"). This is where the code fails. The recordset opened in the previous VI (virtual instrument) has a status of "closed", and the purple variant (seen under "Read all the data available") comes back empty.

The rest of the code is fairly irrelevant, as it's just converting the received variant into usable data, and freeing the recordset reference opened previously. My question is, why would the status from the query of the recordset be "closed"? I realize that recordsets are "closed" when the query returns no rows, but executing that query in SSMS returns good data. Also, executing the LabVIEW code does the UPDATE in the query, so I know that's not broken either.

View 3 Replies View Related

Data Conversion Failed. The Data Conversion For Column Value Returned Status Value 4 And Status Text Text Was Truncated Or On

Jan 7, 2008

Hi Experts,

I am extracting data from SQL Server 2005 to flat file destination. I am using SQL Command to specify the data selection query. One of my query uses Replicate function to derive a column value. When I execute this package it fails with the error "Data conversion failed. The data conversion for column "value" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page".

The reason for the problem is that, it is taking the InputColumnWidth of the flat file destination as 8000 and I specified the OutputColumnWidth as 4.

If I change the OutputColumnWidth to 8000, it is working without any error but resulting in the column width of 8000.

I tried using DerivedColumn Transformation's Type cast and DataConversion Transformation but still I am getting the same error in the respective Transformation components.

Can anyone suggest how to solve this issue.

View 11 Replies View Related

Data Provider Or Other Service Returned An E_Fail Status In Sql Server 2005

May 15, 2007

after converting database from sql server 2000 to sql server 2005. my program on vb6 is facing runtime error. i.e.data provider or other service returned an E_Fail status .

how can i get rid this problem

View 2 Replies View Related

Data Conversion Failed From String To Numeric Returned Status Value 6 In Ssis

Sep 6, 2007

Hi i am working on sending data from a dat file to table in sql server Database and i am using the Data conversion transformation in ssis to convert string of fixed length into numeric (11,5) which is the datatype for the price field in the table and its returning an error saying that status vale 6 and error text as Conersion Failed sue to overflow of specific type ... Can anyone let me know how to overcome this error.

View 6 Replies View Related

SQL Server 2005 &&amp; Data Provider Or Other Service Returned An E_FAIL Status

Apr 22, 2007

Dear all,



I am running an Access adp application with SQL Server 2005 as back end database. I run a query by using Management Studio query window, and it returned correct results with some columns containing NULL value. But when I run this query through MS Access client side, popup an error "Data provider or other service returned an E_FAIL status" and crash the Access application. I moved the database back to SQL Server 2000, and it runs perfect on both client side and server side returning the correct result. This query is important for the application. Please help!!!!



Query as followed:



SELECT TOP (100) PERCENT dbo.VWINFO312FYTRStreamEnrolments.StudentID, dbo.RequiredStreams.StreamType,
dbo.VWINFO312FYTRStreams.StreamCode + CAST(dbo.VWINFO312FYTRStreams.StreamNo AS varchar) AS FullStreamCode,
dbo.DaysOfWeek.DayCode, dbo.VWINFO312FYTRClasses.StartTime, dbo.VWINFO312FYTRClasses.EndTime, dbo.VWINFO312FYTRClasses.Room,
dbo.Tutors.TutorName, dbo.Tutors.PhoneExtn, dbo.Tutors.OfficeHours, dbo.DaysOfWeek.DaySequence, dbo.RequiredStreams.StreamOrder
FROM dbo.RequiredStreams INNER JOIN
dbo.VWINFO312FYTRStreams ON dbo.RequiredStreams.PaperID = dbo.VWINFO312FYTRStreams.PaperID AND
dbo.RequiredStreams.StreamCode = dbo.VWINFO312FYTRStreams.StreamCode INNER JOIN
dbo.VWINFO312FYTRStreamEnrolments ON dbo.VWINFO312FYTRStreams.PaperID = dbo.VWINFO312FYTRStreamEnrolments.PaperID AND
dbo.VWINFO312FYTRStreams.StreamCode = dbo.VWINFO312FYTRStreamEnrolments.StreamCode AND
dbo.VWINFO312FYTRStreams.StreamNo = dbo.VWINFO312FYTRStreamEnrolments.StreamNo LEFT OUTER JOIN
dbo.DaysOfWeek INNER JOIN
dbo.VWINFO312FYTRClasses ON dbo.DaysOfWeek.DayCode = dbo.VWINFO312FYTRClasses.DayofWeek ON
dbo.VWINFO312FYTRStreams.PaperID = dbo.VWINFO312FYTRClasses.PaperID AND
dbo.VWINFO312FYTRStreams.StreamCode = dbo.VWINFO312FYTRClasses.StreamCode AND
dbo.VWINFO312FYTRStreams.StreamNo = dbo.VWINFO312FYTRClasses.StreamNo LEFT OUTER JOIN
dbo.Tutors ON dbo.VWINFO312FYTRClasses.ResponsibleTutor = dbo.Tutors.TutorID

View 4 Replies View Related

Data Provider Or Other Service Returned An E_Fail Status In Sql Server 2005

May 17, 2007

Main_Module.STRCNNN1 = "driver={SQL Server};server=" & Main_Module.Server_Name & ";" & _
"uid=SA;pwd=;database=" & Main_Module.Common_Database
error msg is

runtime error

data provider or other service returned an E_Fail status in sql server 2005



when i am fetching record from view using order by clause in select statement then error is coming

as

select * from vew_emp where grade='C' order empno



at the first time it fetching record with order by

but when i am using recordset.Requiry

it cud not fetch the record

i think when the recordset is open with the record of view

i am deleting ,inserting record in the view base table then the main recordset is not working

without using order by it is running and working well
plz reply me quickly

View 3 Replies View Related

Once Again, No Records Returned....

Dec 21, 2004

The following sproc returns no records in query analyzer, although it doesn't error out either. Last time adding the length to the end of the variable fixed this problem, but this time it's an integer type which doesn't accept a length. Any ideas?



----------------------------------------------------------------------------------------------------
CREATE PROCEDURE spUnitsbyUnitID
@unitid int
AS

SELECT
E.camid, E.camname, E.cammodel, E.unitid,
D.contactid, D.Contactfname, D.Contactlname, D.Contactphone, D.Contactcell, D.Contactcompany, D.unitid,
C.videoserverid, C.videoservermac, C.videoserveruser, C.videoserverpass, C.videoservermodel, C.videoserverip, C.unitid,
B.radioid, B.radioip, B.radiomac, B.radioessid, B.radiouser, B.radiopass, B.unitid,
A.unitid, A.unitcity, A.unitname, A.unitalias, A.unitdeploydate, A.unitpickupdate, A.unitattatchedcams, A.unitenabled

FROM tbl_units as A

INNER JOIN tbl_radios as B ON A.unitid = B.unitid
INNER JOIN tbl_videoservers as C ON A.unitid = C.unitid
INNER JOIN tbl_contacts as D on A.unitid = D.unitid
INNER JOIN tbl_cameras as E on A.unitid = E.unitid

WHERE A.UnitID = @unitID
GO
-----------------------------------------------------------------------------------------------------

View 3 Replies View Related

No Records Returned

Jun 12, 2007

I have a simple report with a group header, details and footer. How do I display a message to inform users when no data is returned when they enter a parameter which returns no records - at the moment my report returns a blank screen, it would be more useful if I could output the following

'Parameter Name' does not exist.

View 1 Replies View Related

Status Of Replication Through Transact-SQL

Aug 8, 2006

Hello,

I currently have a transactional replication between SQL Server 2000 and an Oracle database. Once a week on Monday mornings we have a process that drops replication, uploads data to the SQL Server database from Oracle, does some manipulation of the data and then recreates replication.

We came across the thought of what would happen if replication had erred out and there were still transactions within the distribution database to be replicated across. Then our job just came about and dropped the replication.

We are looking for a way to tell what the status is of replication through Transact-SQL. This way we can check the status and if it contained an error that we could abort the job, so as to not lose any transactions.

Does anyone have an idea of how to accomplish this?

Thanks

crusso

View 3 Replies View Related

No Records Returned Using Contains Keyword

Apr 12, 2006

Hi,

This is my 1st thread. Hopefully somebody can help me with the full-text serach.

I enabled full text serach on sql server 2k and created a catalog for a table
I tried using the following sql statement but it doesn't seem to return any records although I used a like statement and got some records. Can anybody answer why this is so? Thanks!

Select * from table1 where contains (field1, '"ESTATE PLAN"')

Regards,
Ronald

View 3 Replies View Related

Multiple Records Returned.

Sep 2, 2006

The following statement gives the error that multiple records are returned. I am attempting to pick one weight out of a group of three, the three have the same ResidentID and different dates in the table variable @WeightReportRaw. If I hard code the ResidentID, ResidentID = 6, it works fine. The variable @intMonth3 passes in a month number ans dosen't seem to be a problem.

What am I missing, Thanks in advance for any help.

update tblResidentWeightsTemp set FirstWeight =

(select RWeight from @WeightReportRaw as W where ResidentID = W.ResidentID and month(W.RWeightDate) = @intMonth3)

View 6 Replies View Related

How Do I Get A Count Of All Records Returned.

Apr 9, 2007

I'm trying to put the total number of records returned from from a query in the bottom of our report. I don't want to do a count(*) in my sql stmt.



thanks.



View 5 Replies View Related

Count Of Records Returned

Oct 18, 2007

How can i get a Count of the number of records returned

Here is my code
Im using VS2005 connected to SQL Compact v3.1


myCmd.CommandType = Data.CommandType.Text

myCmd.CommandText = "Select * From tblParts"


Dim myDataAdapter As SqlCeDataAdapter = New SqlCeDataAdapter(myCmd)

Dim myDataSet As DataSet = New DataSet()

myDataAdapter.Fill(myDataSet)


TblPartsDataGrid.DataSource = myDataSet.Tables(0)

View 3 Replies View Related

Transact SQL :: Only 1st Result Being Returned?

Jun 10, 2015

We have multiple employees assigned to the same assignment sometimes, and my query is skewed as that if there are 2 people assigned to the ssame assigment I can only see the amt of time worked for the 1st person.  What should I do to remedy this?

Ouput I am receiving is

BadgeNum - Assignment -- FullName --TimeworkToday
A2323   ---- Accident Reconstruction ---- Football Helmet ---- .50
AB12 ---- Accident Reconstruction ---- Brown Shoe ---- Null
AB66 ----- Accident Reconstruction ---- Black Shoe ---- Null
ABB28 ---- Accident Reconstruction ---- White Shoe ---- Null

--And now here it's a new assignment so timeworktoday is populating

MC22 ---- Crime Prevention ---- Laptop Coputer ---- 1.13

Desired output is all employees have a value populate for timeworktoday

Declare
@count int,
@Assignment varchar(100),
@fullname varchar(100),
@timeworkedtoday decimal(18,2),
@badgeNum varchar(50)
Create Table #possibleemployees(ID INT IDENTITY NOT NULL, badgeNum varchar(50), workingtoday int)

[code]....

View 7 Replies View Related

Transact SQL :: Updating Table Set Sent To 1 For All Status IDs

Nov 30, 2015

SID statusid listindex listsize sent
1           12     25        25       1
2           12    25        50       0
3            12   75       150       1
4            14     25     25        1

I have a table like above where cid is unique but status is not for all the status id i need put 1 as they sent out .but till now i used max listindex because they used to send files sequentially but now list index is random so how to update sent to 1 for all the status ids.

View 5 Replies View Related

Deleting Records Returned By Datareader

May 8, 2005

I have a function that opens a connection to an SQL database, issues a
SELECT command, and reads the records with an OleDbDataReader. As the
records are read, any that match certain criteria are deleted with a
DELETE command. Simplified example code is shown below:

Dim dbCmd As OleDb.OleDbCommand = New OleDb.OleDbCommand()
dbCmd.Connection = New OleDb.OleDbConnection(UserDbConnString)
dbCmd.CommandText = "SELECT * FROM [User] ORDER BY UserID"
dbCmd.Connection.Open()
Dim reader as OleDb.OleDbDataReader = dbCmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
    If reader("SomeColumn") = SomeCalculatedValue Then
        Dim dbCmd2 As OleDb.OleDbCommand = New OleDb.OleDbCommand()
        dbCmd2.Connection = New OleDb.OleDbConnection(UserDbConnString)
        dbCmd2.CommandText = "DELETE FROM [User] WHERE UserID = " + reader("UserID")
        dbCmd2.Connection.Open()
        dbCmd2.ExecuteNonQuery()
        dbCmd2.Connection.Close()
    End If
End While
reader.Close()

This code worked well with an MS Access database, but when I changed to
SQL Server, I get a database timeout error when attempting to do the
DELETE. I suspect the reason is that the connection the reader has open
has the record locked so it cannot be deleted.

The SQL connection string I am using is something like this:

UserDbConnString = "Provider=SQLOLEDB; Server=(Local); User ID=userid; Password=password; Database=dbname"

The connection string I used for MS Access included the property
"Mode=Share Deny None". I wonder if there is some similar way to tell
SQL Server to allow editing of records that are open for reading with
an OleDbDataReader.

Any help would be appreciated.

View 3 Replies View Related

Strange Records Returned By Inner Join

Apr 23, 2007

Hi, all experts here,

Thank you very much for your kind attention.

I got a problem with the records returned by inner join query. It is weird as in table a I with records r1, and in table b with records r2 (r1>r2), but the returned record number r3 is greater than r1? That is so strange. As the reasonable records returned should be less than r1?(inner join on attribute a). What probably is the cause of the problem? I am looking forward to hearing from you and thank you very much.

With best regards,

Yours sincerely,





View 5 Replies View Related

Transact SQL :: Value In Field Not Returned By WHERE Clause

Nov 18, 2015

I have a small table named Exclude_Cusno_Item that has a varchar(29)  field named

ITEM. When I query the table to show all of the records like this:
Select * from Exclude_Cusno_Item

The result set contains a record with 'AAA' in the ITEM field.  However, where I write a query with a WHERE clause to select this specific 'AAA' record like this:

Select * from Exclude_Cusno_Item where item = 'AAA'

I get no results. What could be happening that would prevent the 'AAA' record from appearing in the result set of this query? Note that the 'AAA' entry has no trailing or leading blanks.

View 12 Replies View Related

T-SQL (SS2K8) :: How To Select Records Only When Their Status Has Been Changed

Jun 9, 2015

I have a product table and my task is to select only the products that had been paid for, but later their status has been changed.

I need to report the original paid date, the most recent status, and most recent updated date. Here is the sample table:

CREATE TABLE #Products (primKey int, productId int, productName varchar(100), productStatus varchar(50), logDate datetime )

Insert into #Products(primKey, productId, productName, productStatus, logDate)

Values
(1, 201, 'pen', 'received', '01/01/2011'),
(2, 201, 'pen', 'sold', '01/02/2011'),
(3, 201, 'pen', 'paid', '01/03/2011'),
(4, 201, 'pen', 'returned', '01/04/2011'),
(5, 201, 'pen', 'refurbished', '01/05/2011'),
(6, 202, 'pencil', 'received', '01/06/2011'),
(7, 202, 'pencil', 'sold', '01/07/2011'),
(8, 202, 'pencil', 'paid', '01/08/2011'),
(9, 201, 'pen', 'sold', '01/09/2011'),
(10, 201, 'pen', 'paid', '01/10/2011')

/* temp table records */
Select * From #Products order by productId

/* The desired outcomes would be showing only the Record 3 and 10.

This is a "fake" query to get the results:
*/
Select * From #Products Where primKey in (3, 10) order by productId

View 9 Replies View Related

Records Erroring Out. Error Description --- &&> No Status Available

Mar 22, 2007

hi All,

In process of migrating a database we had developed a SSIS package that loads fairly straight forward data. It was all working fine but now suddenly around 95 % of the data is getting errored out and all i get as a Error Description is that 'No Status is Available'. I know its pretty tough to ask wht can be the reason ? But can someone guide me onto what exactly I look for ? Has some one before got into such thing and did some resolution ?

Thanks in advance.

View 9 Replies View Related

Listbox To Only Appear If There Are Records Returned From The SQL Select Query

Oct 19, 2006

I would like to make a listbox only appear if there are results returned by the SQL select statement. I want this to be assessed on a click event of a button before the listbox is rendered.I obviously use the ".visible" property, but how do I assess the returned records is zero before it is rendered?

View 3 Replies View Related

Transact SQL :: EXCEPT Not Showing The Results - Zero Rows Returned

Sep 10, 2015

I have two tables A and B, A has 8000 and B has 8122 records. I want to see what records are missing. I tried EXCEPT and it returned zero rows. I used where non exists also still no records.

View 5 Replies View Related

Transact SQL :: Does Fetch Status In Nested Loops Conflict

Apr 24, 2015

Does fetch status in nested loops conflict?I have a script that should output a cluster record line and for each cluster record it must create a line for each household in the cluster.  All the data is pulled from one table, 'LFS_APRIL_2015.dbo.LISTING'.This is the script:

--VARIABLE DECLARATION
DECLARE @CLUSTER FLOAT, @HOUSEHOLD_NUMBER FLOAT, @FULL_ADDRESS CHAR(50), @HEAD_NAME CHAR(24)--CLUSTER LOOP
DECLARE CLUSTER_CURSOR CURSOR FOR
SELECT [LFS_APRIL_2015].[dbo].[LISTING].CLUSTER
from [LFS_APRIL_2015].[dbo].[LISTING] where CLUSTER IS NOT NULL and DISTRICT = 1

OPEN CLUSTER_CURSOR

[code]...

It appears however that the clusters are being repeated.

View 5 Replies View Related

How To Get Number Of Records A Query Has Returned Using SqlDataSource Control?

May 17, 2007

Hi,
I'm using SqlDataSource control.
Is there a way to know how many records a query has returned?

View 3 Replies View Related

Limit The Number Of Records Returned In Stored Procedure.

Aug 17, 2007

In my ASP page, when I select an option from the drop down list, it has to get the records from the database stored procedure. There are around 60,000 records to be fetched. It throws an exception when I select this option. I think the application times out due to the large number of records. Could some tell me how to limit the number of rows to be returned to avoid this problem. Thanks.
 Query
SELECT @SQLTier1Select = 'SELECT * FROM dbo.UDV_Tier1Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers(' + CAST(@UserID AS VARCHAR(4)) + '))' + @Criteria + ' AND (number IN (SELECT DISTINCT ph1.number FROM Collect2000.dbo.payhistory ph1 LEFT JOIN Collect2000.dbo.payhistory ph2 ON ph1.UID = ph2.ReverseOfUID WHERE (((ph1.batchtype = ''PU'') OR (ph1.batchtype = ''PC'')) AND ph2.ReverseOfUID IS NULL)) OR code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryPaidPaymentsT1 = 1))'

View 2 Replies View Related

Transact SQL :: Summarizing Data Returned By Join Query

Nov 20, 2015

I have a table (edw_sbx_bt.jjenkins_OVERAGE2) of 40,000 MA_NUM.  

I want to find occurrences of those specific MA_NUM in another table (edw_ar_fl.ARTBASE) with specific attributes (CONTRACT_NUM = '593' and TRANSACT_STATUS_CD = 'D').  

When I run the query below it returns 4 million rows.  How can I write a query that will return the 40,000 MA_NUM (in edw_sbx_bt.jjenkins_OVERAGE2) with the sum total of MA_PAID_AMT associated with each?

SELECT edw_ar_fl.ARTBASE.MA_NUM,
       edw_ar_fl.ARTBASE.MA_PAID_AMT
FROM   edw_ar_fl.ARTBASE
       JOIN edw_sbx_bt.jjenkins_OVERAGE2
         ON edw_ar_fl.ARTBASE.MA_NUM = edw_sbx_bt.jjenkins_OVERAGE2.MA_NUM
WHERE  edw_ar_fl.ARTBASE.CONTRACT_NUM = '593'
       AND edw_ar_fl.ARTBASE.TRANSACT_STATUS_CD = '

View 4 Replies View Related

SQL Server 2008 :: Reminder Emails - Records Created With Status

Jun 29, 2015

We have a difficult requirement.

When records are initially created, they are given statuses of New, Pending, Closed

By default, the status is New.

If no action has been taken after 15 days since the records were created, users are sent a reminder.

I have this part working.

The problem is that as long as the status is not equal to closed, start sending reminders every 10 days.

Here is what I am working with:

SELECT [ID] , [Name], [Email],
Status
FROMmyTable
WHERE Status_Name != 'Closed' AND Status_Name IS NOT NULL and Status_Name = 'New' and Status='Pending'
AND CONVERT(Char,DateAdd(day,-15,getdate()),101) = CONVERT(Char,Date_Entered,101)

View 2 Replies View Related







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