Question : SQL 2005 Query Help

First and foremost, the SQL is handled dynamically by the server, therefore items in my WHERE clause will look odd. Please ignore this as its not the issue.

I am trying to get the @FiscalYearStarts coded right in my report below, however every row is returned with a NULL. I think I goofed something. Any help is deeply appreciated.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
SET NOCOUNT ON

/********* Determine the beginning of the fiscal year ***************************/

DECLARE @FiscalYearMonth INT
DECLARE @RequestedMonth INT
DECLARE @PatientVisitId INT
DECLARE @PatientVisit DATETIME
DECLARE @FiscalYearStarts DATETIME

SELECT
   @FiscalYearMonth = 1
SELECT
   @FiscalYearMonth = ISNULL(otherlong , 1)
FROM
   medlists
WHERE
   tablename = 'fiscalyear'
SELECT
   @RequestedMonth = MONTH(CONVERT(DATETIME , pv.Visit))
FROM
   PatientVisit pv
 WHERE 
 pv.PatientVisitId = @PatientVisitId  
					

IF @FiscalYearMonth <= @RequestedMonth 
   BEGIN
      SELECT
         @FiscalYearStarts = CONVERT(VARCHAR , @FiscalYearMonth) + '/1/' + CONVERT(VARCHAR , YEAR(CONVERT(DATETIME , @PatientVisit)))
   END
ELSE 
   BEGIN
      SELECT
         @FiscalYearStarts = CONVERT(DATETIME , CONVERT(VARCHAR , @FiscalYearMonth) + '/1/' + CONVERT(VARCHAR , YEAR(CONVERT(DATETIME , @PatientVisit)) - 1))
   END
   
/******************************************************************************/

SELECT
	pv.TicketNumber,
	pv.Visit, 
	'01' AS EntityCode, 
	@FiscalYearStarts AS [Fiscal Year],
	'  ' AS [Fiscal Period],
	'GL' AS [Subsystem],
	'JRNENT' AS [Source Code],
	LEFT(ISNULL(doc.Ledger,'')+ SPACE(10),10) AS [Dept No],
	LEFT(LEFT(isnull(fac.Ledger,''),4) + LEFT(isnull(fin.Ledger,''),4) + SPACE(10) , 10) AS [SubAccount No],
	SUM(pvp.totalfee) AS [Amount],
	'C' AS [Debit/Credit], 
	'Centricity Entry' + SPACE(34) AS [Description],
	SPACE(6)AS [Proj Id],
	SPACE(16)AS [Filler]
FROM
	PatientVisit pv 
	INNER JOIN DoctorFacility comp ON pv.CompanyId = comp.DoctorFacilityId 
	INNER JOIN DoctorFacility fac ON pv.FacilityId = fac.DoctorFacilityId 
	INNER JOIN DoctorFacility doc ON pv.DoctorId = doc.DoctorFacilityId 
	LEFT OUTER JOIN Medlists fin ON pv.FinancialClassMId = fin.MedListsId 
	INNER JOIN PatientProfile pp ON pv.PatientProfileId = pp.PatientProfileId
	INNER JOIN PatientVisitProcs pvp ON pv.PatientVisitId = pvp.PatientVisitId 
	INNER JOIN Batch b ON pvp.BatchID = b.BatchID
	INNER JOIN PatientVisitProcsAgg pvpa ON pvp.PatientVisitProcsID = pvpa.PatientVisitProcsID 
	LEFT OUTER JOIN Procedures p ON pvp.ProceduresID = p.ProceduresID 
	LEFT JOIN MedLists Procs ON p.DepartmentMId = procs.MedListsId 

WHERE 
	b.entry >= ISNULL(NULL,'1/1/1900') 
	AND b.entry < DATEADD(DAY,1,ISNULL(NULL,'1/1/3000')
	)	
	AND  --Filter on Facility
	(
	(NULL IS NOT NULL AND pv.FacilityID IN (NULL)) OR
	(NULL IS NULL)
	)
	AND  --Filter on Company
	(
	(NULL IS NOT NULL AND pv.CompanyID IN (NULL)) OR
	(NULL IS NULL)
	)
	AND  --Filter on Financial Class
	(
	(NULL IS NOT NULL AND pv.FinancialClassMID IN (NULL)) OR
	(NULL IS NULL)
	)
	
GROUP BY 
	pv.TicketNumber,
	pv.Visit,
	doc.Ledger,
	fac.Ledger,
	fin.Ledger
	
HAVING SUM(pvp.TotalFee)<> 0 
	
ORDER BY pv.TicketNumber

Answer : SQL 2005 Query Help

well, if they're on different subnets, that won't work.

grab a laptop or desktop, and set its network info to a static ip address of 10.0.0.100, subnet 255.255.255.0, you can leave the gateway blank.

after that's done, you should be able to browse to http://10.0.0.50 (the lexmark)

set the lexmark's ip address to some unused ip address on your 10.10.100.x network, with a subnet of 255.255.255.0, and your gateway of 10.10.100.x

save the changes, it'll reboot.  at that point set your laptop/desktop back to what it was before, and tell the server the ip of the lexmark.  you should be good to go at that point.
Random Solutions  
 
programming4us programming4us