Showing posts with label clients. Show all posts
Showing posts with label clients. Show all posts

Wednesday, March 21, 2012

problem getting the most recent record for a range of clients

I have a fairly complex SP with 3 tables the idea being to display a Region, Client and Event
I want to show only the last event for each client

I have replaced my event table with a View which returns the TOP 1 but all I get is the most recent of all records
I want eg:
Region 1, Client 1, Most recent event
Region 1, Client 2, Most recent event
Region 1, Client 3, Most recent event

Not sure of the structure of your tables, but maybe you're looking for something like this?

SELECT RegionName, ClientName, EventName FROM Regions r INNER JOIN Clients c ON r.ClientID=c.ClientID INNER JOIN Events e ON c.ClientID=e.EventID WHERE EventDate=(SELECT MAX(EventDate) FROM Events WHERE ClientID=c.ClientID)

|||

Just the job Many thanks , I was not thinking right, this is a simplified version, unfortunatly I needed two MAX fields one for Date the other for EventID as the last ID may not be the most recent Date

exmple below gets all events with the most recent date then picks the most recent id from the most recent dates,

SELECT dbo.tblClients.FName, dbo.tblClients.SName, dbo.tblOCompEvents.CompEventID, dbo.tblOCompEvents.StartDate,
dbo.tblOCompEvents.IRef, dbo.tblClients.ClientID, dbo.tblOCompEvents.Status
FROM dbo.tblOCompEvents INNER JOIN
dbo.tblClients ON dbo.tblOCompEvents.ClientID = dbo.tblClients.ClientID
WHERE (dbo.tblOCompEvents.StartDate IN
(SELECT MAX(StartDate) AS sd
FROM dbo.tblOCompEvents AS tblOCompEvents_1
WHERE (ClientID = dbo.tblOCompEvents.ClientID))) AND (dbo.tblOCompEvents.CompEventID IN
(SELECT MAX(CompEventID) AS ceid
FROM dbo.tblOCompEvents AS tblOCompEvents_1
WHERE (ClientID = dbo.tblOCompEvents.ClientID))) AND (dbo.tblOCompEvents.Status = 25)
ORDER BY dbo.tblClients.ClientID

Wednesday, March 7, 2012

Problem creating Job from tsql

I'm attempting to create a job on a client's server using tsql over a VPN.
* I've created this procedure before using the same tsql and VPN
* The same tsql works presently on my server
* I'm not having any other problems on the server
* We're using NT auth, and my userid is sa
When I try to create a job from query analyzer, I get:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionWrite (send()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
Connection Broken
Any ideas?
Thanks!
Greg
Seems that 'sp_add_jobstep' is generating the error. Anyone have a similar experience?
Greg C
"Greg C" <uce@.ftc.com> wrote in message news:QAxoc.88432$Dn1.44627@.fe2.texas.rr.com...
I'm attempting to create a job on a client's server using tsql over a VPN.
* I've created this procedure before using the same tsql and VPN
* The same tsql works presently on my server
* I'm not having any other problems on the server
* We're using NT auth, and my userid is sa
When I try to create a job from query analyzer, I get:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionWrite (send()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
Connection Broken
Any ideas?
Thanks!
Greg

Monday, February 20, 2012

Problem connection to SQL Server with ODBC

What protocols are being used by the client and what is the
server listening on?
Are the client network utilities on the clients having the
connectivity problems?
Are you using an alias for the connection?
What version of MDAC on the clients?
From your description, it sounds like the app tries to
connect twice (which is fine) but that it's just not hitting
the right protocols. You can find information on how a
client runs through the protocols trying to connect in this
article:
INF: SQL Server Clients May Change Protocols When They Try
to Connect
http://support.microsoft.com/?id=328383
You can also find some general troubleshooting for the error
at:
INF: Potential Causes of the "SQL Server Does Not Exist or
Access Denied" Error Message
http://support.microsoft.com/?id=328306
-Sue
On Tue, 6 Apr 2004 10:12:37 +0100, "Ian Spanswick"
<ian.spanswick@.eps-hq.co.uk> wrote:

>Hi,
>Getting very frustrated by the following problem, using SQL Server 2000 (inc
>SP3a), using an application that connects to a DB via ODBC and the following
>error message comes up:
>Connection failed:
>SQLSTATE: '01000'
>SQL Server Error: 1703
>[Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionOpen
>(Connect()).
>Connection failed:
>SQLState: '08001'
>SQL Server Error:17
>[Microsoft][ODBC SQL Server Driver][Shared Memory]SQL Server does not exist
>or access denied
>When setting up the DSN the test works fine as does query analyzer, pretty
>sure it's not the application I'm using as the SQL server connection window
>that comes up after the initial error (above) gives the same error message.
>Any ideas? Help is definitely needed before I tear my hair out!
>Thanks
>Ian
>
Thanks for the links, studying them now but have moved my database to
another server and things are going better! Still want to get to the bottom
of the problem.
Ian
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:i3i670lutthh68l5mqlgn479ng66ornom3@.4ax.com...
> What protocols are being used by the client and what is the
> server listening on?
> Are the client network utilities on the clients having the
> connectivity problems?
> Are you using an alias for the connection?
> What version of MDAC on the clients?
> From your description, it sounds like the app tries to
> connect twice (which is fine) but that it's just not hitting
> the right protocols. You can find information on how a
> client runs through the protocols trying to connect in this
> article:
> INF: SQL Server Clients May Change Protocols When They Try
> to Connect
> http://support.microsoft.com/?id=328383
> You can also find some general troubleshooting for the error
> at:
> INF: Potential Causes of the "SQL Server Does Not Exist or
> Access Denied" Error Message
> http://support.microsoft.com/?id=328306
> -Sue
> On Tue, 6 Apr 2004 10:12:37 +0100, "Ian Spanswick"
> <ian.spanswick@.eps-hq.co.uk> wrote:
(inc
following
exist
pretty
window
message.
>